1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-29 09:44:28 +01:00

convert: Don't rely on PHP GD to get the image dimensions; use identify.

This commit is contained in:
Michael Save 2012-03-17 22:49:56 +11:00
parent b6c2f91461
commit 2e1086e63d

View File

@ -220,14 +220,16 @@
}
public function from() {
if(!$size = @getimagesize($this->src))
return $this->image = false;
$size = trim(shell_exec('identify -format "%w %h" ' . escapeshellarg($this->src . '[0]')));
if(preg_match('/^(\d+) (\d+)$/', $size, $m)) {
$this->width = $m[1];
$this->height = $m[2];
$this->width = $size[0];
$this->height = $size[1];
// mark as valid
$this->image = true;
$this->image = true;
} else {
// mark as invalid
$this->image = false;
}
}
public function to($src) {
rename($this->temp, $src);
@ -247,7 +249,7 @@
$quality = $config['thumb_quality'] * 10;
if(shell_exec("convert -flatten -antialias -filter Point -scale {$this->width}x{$this->height} -quality {$quality} " . escapeshellarg($this->src . '[0]') . " " . escapeshellarg($this->temp)))
if(shell_exec("convert -flatten -antialias -filter Point -scale {$this->width}x{$this->height} -quality {$quality} " . escapeshellarg($this->src . '[0]') . " " . escapeshellarg($this->temp)) || !file_exists($this->temp))
error('Failed to resize image!');
}
}