Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animated GIF bugged colors #6

Open
jdecool opened this issue Mar 28, 2015 · 5 comments
Open

Animated GIF bugged colors #6

jdecool opened this issue Mar 28, 2015 · 5 comments

Comments

@jdecool
Copy link

jdecool commented Mar 28, 2015

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 :
Before

After :
After

@rformato
Copy link

rformato commented Jun 4, 2015

see #8

@MichelAraujo
Copy link

Some solution to this problem?

@yang-jandro
Copy link

@MichelAraujo Have you tried @rformato pull request? #8

@MichelAraujo
Copy link

Yes! Problem solved with pull request

@jdecool
Copy link
Author

jdecool commented Jul 30, 2015

@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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants