experimental animated GIF thumbnails
This commit is contained in:
parent
5c5cfa28e0
commit
3c4d8843ba
@ -155,6 +155,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function to($src) {
|
public function to($src) {
|
||||||
|
if(preg_match('/\.gif$/', $src))
|
||||||
|
$this->image->writeImages($src, true);
|
||||||
|
else
|
||||||
$this->image->writeImage($src);
|
$this->image->writeImage($src);
|
||||||
}
|
}
|
||||||
public function width() {
|
public function width() {
|
||||||
@ -167,11 +170,39 @@
|
|||||||
return $this->image->destroy();
|
return $this->image->destroy();
|
||||||
}
|
}
|
||||||
public function resize() {
|
public function resize() {
|
||||||
$this->image = clone $this->original;
|
global $config;
|
||||||
|
|
||||||
|
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);
|
$this->image->scaleImage($this->width, $this->height, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class ImagePNG extends ImageBase {
|
class ImagePNG extends ImageBase {
|
||||||
|
Loading…
Reference in New Issue
Block a user