summaryrefslogtreecommitdiff
path: root/inc/image.php
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-03-10 22:56:28 +1100
committerMichael Save <savetheinternet@tinyboard.org>2012-03-10 22:56:28 +1100
commit3c4d8843ba828b3fa2513d6122b74352d03dfa33 (patch)
tree89bc4bde06dce5a26e3c5d26db21e5e350e8aa80 /inc/image.php
parent5c5cfa28e039a4ad4c282cd9984501fb55571722 (diff)
experimental animated GIF thumbnails
Diffstat (limited to 'inc/image.php')
-rw-r--r--inc/image.php37
1 files changed, 34 insertions, 3 deletions
diff --git a/inc/image.php b/inc/image.php
index 08888851..8b644ac9 100644
--- a/inc/image.php
+++ b/inc/image.php
@@ -155,7 +155,10 @@
}
}
public function to($src) {
- $this->image->writeImage($src);
+ if(preg_match('/\.gif$/', $src))
+ $this->image->writeImages($src, true);
+ else
+ $this->image->writeImage($src);
}
public function width() {
return $this->image->getImageWidth();
@@ -167,9 +170,37 @@
return $this->image->destroy();
}
public function resize() {
- $this->image = clone $this->original;
+ global $config;
- $this->image->scaleImage($this->width, $this->height, false);
+ if($config['thumb_ext'] == 'gif') {
+ $this->image = new Imagick();
+ $this->image->setFormat('gif');
+
+ $keep_frames = Array();
+ for($i = 1; $i < $this->original->getNumberImages(); $i += floor($this->original->getNumberImages() / $config['thumb_keep_animation_frames']))
+ $keep_frames[] = $i;
+
+ $i = 0;
+ $delay = 0;
+ foreach($this->original as $frame) {
+ $delay += $frame->getImageDelay();
+
+ //if($i < $config['thumb_keep_animation_frames']) {
+ if(in_array($i, $keep_frames)) {
+ $frame->scaleImage($this->width, $this->height, false);
+ $frame->setImagePage($this->width, $this->height, 0, 0);
+ $frame->setImageDelay($delay);
+ $delay = 0;
+
+ $this->image->addImage(clone $frame->getImage());
+ }
+ $i++;
+ }
+ } else {
+ $this->image = clone $this->original;
+ // only resize one frame
+ $this->image->scaleImage($this->width, $this->height, false);
+ }
}
}