GifFrameExtractor
GifFrameExtractor copied to clipboard
Animated GIF bugged colors
This is a bug reported in ImageWorkshop library but concerning this repository.
Created by @Kekke88 :
Hello, I've been trying to add an image upon a GIF image using your libraries.
However, it turns the gif image into some weird blue color. I have tried to debug but I can't find what's wrong, I tried using getResult with a background color but it still didn't help.
I printed the frames as images and it seems that image #2 is the first image to get weird colors.
Here is the picture before: http://i.imgur.com/M3bM7yP.gif
and after: http://i.imgur.com/lyMu2P0.gif
All the images extracted: http://imgur.com/2kFqUzw,TAxAjeC,YzM4ztE,alotpAS,CdUTa7a,IQQiylp,BjI14CD,IlrQZiC,mo2vrs1,QPEsR67,ohFZ4sN,xM9jzvC,GyA3Toa,Eepmqhv,O5vxpfc,IE1lKG9,EqP9foq,VAtE7oY,sVsteMd,NtQziAE,YVKMGfz,4GEgyBf,3cvPE7m,hgJtWCt,dbbQSNe,mrBjnRN,MgAbBqi,1i3yhLn,43GUKOu,hkmXP0n,ysajT72#1
Regards
Code sample :
<?php
include 'GifFrameExtractor.php';
include 'GifCreator.php';
include 'ImageWorkshop.php';
$gifPath = 'teac.gif';
if(GifFrameExtractor::isAnimatedGif($gifPath)) {
$gfe = new GifFrameExtractor();
$frames = $gfe->extract($gifPath);
$watermarkLayer = ImageWorkshop::initFromPath('wm.png');
$retouchedFrames = array();
//$it = 0;
foreach ($frames as $frame) {
$frameLayer = ImageWorkshop::initFromResourceVar($frame['image']);
$frameLayer->resizeInPixel($frameLayer->width, $frameLayer->height, false);
$frameLayer->addLayerOnTop($watermarkLayer, 20, 20, 'LB');
$image = $frameLayer->getResult();
// Creating all the GIF Images
//imagejpeg($image, 'test' . $it . '.jpg', 95);
$retouchedFrames[] = $frameLayer->getResult();
//$it++;
}
// Then we re-generate the GIF
$gc = new GifCreator();
$gc->create($retouchedFrames, $gfe->getFrameDurations(), 0);
// And now save it !
file_put_contents('newgif.gif', $gc->getGif());
}
?>
Before :
After :
see #8
Some solution to this problem?
@MichelAraujo Have you tried @rformato pull request? #8
Yes! Problem solved with pull request
@gpv-dev Thanks for your contribution @MichelAraujo Thanks for your feedback on the PR
@Sybio Could you look at the PR to solve this bug ?