Skip to content

Animated GIF bugged colors #6

Open

Description

@jdecool

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

Activity

  1. rformato commented on Jun 4, 2015

    @rformato

    see #8

  2. MichelAraujo commented on Jul 22, 2015

    @MichelAraujo

    Some solution to this problem?

  3. yang-jandro commented on Jul 23, 2015

    @yang-jandro

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

  4. MichelAraujo commented on Jul 30, 2015

    @MichelAraujo

    Yes! Problem solved with pull request

  5. jdecool commented on Jul 30, 2015

    @jdecool
    Author

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions