Fix animated thumbnails with convert and Imagick

This commit is contained in:
Michael Save 2012-04-18 00:07:37 +10:00
parent 1d93aa51b0
commit 3592913249
2 changed files with 14 additions and 5 deletions

View File

@ -431,10 +431,10 @@
$config['spoiler_image'] = 'static/spoiler.png';
// Thumbnail quality (compression level), from 0 to 9
$config['thumb_quality'] = 7;
$config['thumb_quality'] = 8;
// When a thumbnailed image is going to be the same (in dimension), just copy the entire file and use that as a thumbnail instead of resizing/redrawing
$config['minimum_copy_resize'] = true;
$config['minimum_copy_resize'] = false;
// Store image hash in the database for r9k-like boards implementation soon
// Function name for hashing

View File

@ -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))
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!');
}
}
}