Ignore:
Timestamp:
Jul 6, 2011, 5:48:09 PM (13 years ago)
Author:
patdenice
Message:

Avoid errors with some pictures...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/external_ImageMagick/trunk/imagick.class.php

    r9860 r11650  
    77  var $imagemagickdir = '';
    88  var $commands = array();
     9  var $width = '';
     10  var $height = '';
    911
    1012  const INTERLACE_NO = 'none';
     
    5052      $this->imagemagickdir = rtrim($conf['imagick_dir'], ' /\\').'/';
    5153
    52     $command = $this->imagemagickdir."identify -verbose ".realpath($this->source_path);
     54    $command = $this->imagemagickdir.'identify -format "%wx%h" "'.realpath($this->source_path).'"';
    5355    @exec($command, $returnarray, $returnvalue);
    54     if($returnvalue)
     56    if($returnvalue or !preg_match('/^(\d+)x(\d+)$/', $returnarray[0], $match))
    5557    {
    56       die("ImageMagick: Corrupt image");
     58      die("[External ImageMagick] Corrupt image");
    5759    }
    58     else
    59     {
    60       foreach($returnarray as $value)
    61       {
    62         $arr = explode(':', $value, 2);
    63         if (count($arr) == 2)
    64         {
    65           $this->image_data[trim($arr[0])] = trim($arr[1]);
    66         }
    67       }
    68     }
     60
     61    $this->width = $match[1];
     62    $this->height = $match[2];
    6963  }
    7064
     
    7670  function getImageWidth()
    7771  {
    78     preg_match('#^(\d+)x#', $this->image_data['Geometry'], $match);
    79     return isset($match[1]) ? $match[1] : false;
     72    return $this->width;
    8073  }
    8174
    8275  function getImageHeight()
    8376  {
    84     preg_match('#^\d+x(\d+)(?:\+|$)#', $this->image_data['Geometry'], $match);
    85     return isset($match[1]) ? $match[1] : false;
     77    return $this->height;
    8678  }
    8779
     
    128120
    129121    $exec = $this->imagemagickdir.'convert';
    130     $exec .= ' '.realpath($this->source_path);
     122    $exec .= ' "'.realpath($this->source_path).'"';
    131123
    132124    foreach ($this->commands as $command => $params)
     
    140132
    141133    $dest = pathinfo($destination_filepath);
    142     $exec .= ' '.realpath($dest['dirname']).'/'.$dest['basename'];
     134    $exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'"';
    143135    @exec($exec, $returnarray, $returnvalue);
    144136  }
Note: See TracChangeset for help on using the changeset viewer.