diff options
| author | Michael Save <savetheinternet@tinyboard.org> | 2012-04-18 00:07:37 +1000 |
|---|---|---|
| committer | Michael Save <savetheinternet@tinyboard.org> | 2012-04-18 00:07:37 +1000 |
| commit | cde7da9c4fe07334ea8040c4037a0dac1db50300 (patch) | |
| tree | a6f20cbe1b4efa5d6251677e38b2721b62ee4064 /inc/image.php | |
| parent | 795ef54370d527a40eff0fc7a3f5794061071fe9 (diff) | |
Fix animated thumbnails with `convert` and Imagick
Diffstat (limited to 'inc/image.php')
| -rw-r--r-- | inc/image.php | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/inc/image.php b/inc/image.php index e27364cb..7899ba99 100644 --- a/inc/image.php +++ b/inc/image.php @@ -57,6 +57,7 @@ class Image { $thumb = new $classname(false); $thumb->src = $this->src; + $thumb->format = $this->format; $thumb->original_width = $this->size->width; $thumb->original_height = $this->size->height; @@ -75,6 +76,7 @@ class Image { } $thumb->_resize($this->image->image, $width, $height); + return $thumb; } @@ -181,7 +183,7 @@ class ImageImagick extends ImageBase { public function resize() { global $config; - if (preg_match('/\.gif$/i', $this->src) && $config['thumb_ext'] == 'gif') { + if ($this->format == 'gif' && $config['thumb_ext'] == 'gif') { $this->image = new Imagick(); $this->image->setFormat('gif'); @@ -264,8 +266,15 @@ class ImageConvert extends ImageBase { $quality = $config['thumb_quality'] * 10; - if (shell_exec("convert -flatten -filter Point -scale {$this->width}x{$this->height} +antialias -quality {$quality} " . escapeshellarg($this->src . '[0]') . " " . escapeshellarg($this->temp)) || !file_exists($this->temp)) - error('Failed to resize image!'); + if ($this->format == 'gif' && $config['thumb_ext'] == 'gif' && $config['thumb_keep_animation_frames'] > 1) { + if (shell_exec("convert -filter Point -sample {$this->width}x{$this->height} +antialias -quality {$quality} " . + escapeshellarg($this->src . '') . " " . escapeshellarg($this->temp)) || !file_exists($this->temp)) + error('Failed to resize image!'); + } else { + if (shell_exec("convert -flatten -filter Point -scale {$this->width}x{$this->height} +antialias -quality {$quality} " . + escapeshellarg($this->src . '[0]') . " " . escapeshellarg($this->temp)) || !file_exists($this->temp)) + error('Failed to resize image!'); + } } } |
