Changeset 11044


Ignore:
Timestamp:
May 25, 2011, 12:02:24 PM (13 years ago)
Author:
patdenice
Message:

feature:2284
Improve external image magick

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/image.class.php

    r10713 r11044  
    246246  }
    247247
    248   private function get_resize_result($destination_filepath, $width, $height, $time)
     248  private function get_resize_result($destination_filepath, $width, $height, $time=null)
    249249  {
    250250    return array(
     
    254254      'height'      => $height,
    255255      'size'        => floor(filesize($destination_filepath) / 1024).' KB',
    256       'time'          => number_format((get_moment() - $time) * 1000, 2, '.', ' ').' ms',
     256      'time'        => $time ? number_format((get_moment() - $time) * 1000, 2, '.', ' ').' ms' : null,
    257257      'library'     => $this->library,
    258258    );
     
    317317        {
    318318          // Requested library not available. Try another library
    319           return self::get_library('auto');
     319          return self::get_library('auto', $extension);
    320320        }
    321321    }
     
    399399  var $imagickdir = '';
    400400  var $source_filepath = '';
    401   var $image_data = array();
     401  var $width = '';
     402  var $height = '';
    402403  var $commands = array();
    403404
     
    407408    $this->imagickdir = $imagickdir;
    408409
    409     $command = $imagickdir.'identify -verbose "'.realpath($source_filepath).'"';
     410    $command = $imagickdir.'identify -format "%wx%h" "'.realpath($source_filepath).'"';
    410411    @exec($command, $returnarray, $returnvalue);
    411     if($returnvalue)
     412    if($returnvalue or !preg_match('/^(\d+)x(\d+)$/', $returnarray[0], $match))
    412413    {
    413414      die("[External ImageMagick] Corrupt image");
    414415    }
    415416
    416     foreach($returnarray as $value)
    417     {
    418       $arr = explode(':', $value, 2);
    419       if (count($arr) == 2)
    420       {
    421         $this->image_data[trim($arr[0])] = trim($arr[1]);
    422       }
    423     }
     417    $this->width = $match[1];
     418    $this->height = $match[2];
    424419  }
    425420
     
    431426  function get_width()
    432427  {
    433     preg_match('#^(\d+)x#', $this->image_data['Geometry'], $match);
    434     return isset($match[1]) ? $match[1] : false;
     428    return $this->width;
    435429  }
    436430
    437431  function get_height()
    438432  {
    439     preg_match('#^\d+x(\d+)(?:\+|$)#', $this->image_data['Geometry'], $match);
    440     return isset($match[1]) ? $match[1] : false;
     433    return $this->height;
    441434  }
    442435
Note: See TracChangeset for help on using the changeset viewer.