diff options
| author | Michael Save <savetheinternet@tinyboard.org> | 2012-03-17 22:49:56 +1100 |
|---|---|---|
| committer | Michael Save <savetheinternet@tinyboard.org> | 2012-03-17 22:49:56 +1100 |
| commit | c6478b378fffe075e5b28ac3165a6854fd21c69d (patch) | |
| tree | c5af906ee6130652d879a6f6e33480b176bccce4 /inc | |
| parent | fe7182404fb4d8253086c35537352bcdcfad2057 (diff) | |
convert: Don't rely on PHP GD to get the image dimensions; use `identify`.
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/image.php | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/inc/image.php b/inc/image.php index 40f2aa34..c78e290d 100644 --- a/inc/image.php +++ b/inc/image.php @@ -219,15 +219,17 @@ $this->temp = tempnam($config['tmp'], 'imagick'); } - public function from() { - if(!$size = @getimagesize($this->src)) - return $this->image = false; - - $this->width = $size[0]; - $this->height = $size[1]; - - // mark as valid - $this->image = true; + public function from() { + $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->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!'); } } |
