Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feature:2284
Improve external image magick

git-svn-id: http://piwigo.org/svn/trunk@11044 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
patdenice committed May 25, 2011
1 parent 563637d commit a2b9024
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions admin/include/image.class.php
Expand Up @@ -245,15 +245,15 @@ static function get_rotation_angle($source_filepath)
return $rotation;
}

private function get_resize_result($destination_filepath, $width, $height, $time)
private function get_resize_result($destination_filepath, $width, $height, $time=null)
{
return array(
'source' => $this->source_filepath,
'destination' => $destination_filepath,
'width' => $width,
'height' => $height,
'size' => floor(filesize($destination_filepath) / 1024).' KB',
'time' => number_format((get_moment() - $time) * 1000, 2, '.', ' ').' ms',
'time' => $time ? number_format((get_moment() - $time) * 1000, 2, '.', ' ').' ms' : null,
'library' => $this->library,
);
}
Expand Down Expand Up @@ -316,7 +316,7 @@ static function get_library($library=null, $extension=null)
if ($library != 'auto')
{
// Requested library not available. Try another library
return self::get_library('auto');
return self::get_library('auto', $extension);
}
}
return false;
Expand Down Expand Up @@ -398,29 +398,24 @@ class image_ext_imagick implements imageInterface
{
var $imagickdir = '';
var $source_filepath = '';
var $image_data = array();
var $width = '';
var $height = '';
var $commands = array();

function __construct($source_filepath, $imagickdir='')
{
$this->source_filepath = $source_filepath;
$this->imagickdir = $imagickdir;

$command = $imagickdir.'identify -verbose "'.realpath($source_filepath).'"';
$command = $imagickdir.'identify -format "%wx%h" "'.realpath($source_filepath).'"';
@exec($command, $returnarray, $returnvalue);
if($returnvalue)
if($returnvalue or !preg_match('/^(\d+)x(\d+)$/', $returnarray[0], $match))
{
die("[External ImageMagick] Corrupt image");
}

foreach($returnarray as $value)
{
$arr = explode(':', $value, 2);
if (count($arr) == 2)
{
$this->image_data[trim($arr[0])] = trim($arr[1]);
}
}
$this->width = $match[1];
$this->height = $match[2];
}

function add_command($command, $params=null)
Expand All @@ -430,14 +425,12 @@ function add_command($command, $params=null)

function get_width()
{
preg_match('#^(\d+)x#', $this->image_data['Geometry'], $match);
return isset($match[1]) ? $match[1] : false;
return $this->width;
}

function get_height()
{
preg_match('#^\d+x(\d+)(?:\+|$)#', $this->image_data['Geometry'], $match);
return isset($match[1]) ? $match[1] : false;
return $this->height;
}

function crop($width, $height, $x, $y)
Expand Down

0 comments on commit a2b9024

Please sign in to comment.