Combine a animated GIF with a static PNG

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
sroBandit
Posts: 3
Joined: 2011-09-25T03:00:43-07:00
Authentication code: 8675308

Combine a animated GIF with a static PNG

Post by sroBandit »

Hi folks,

i tried a whole day now for my problem and googling my hands off but couldnt find a real solution for my problem:
I have an animated gif and a static PNG. The static PNG should get the "background" of the animated GIF (the animated GIF also has a transparency).

I tried things like:

Code: Select all

$a = new Imagick('../a.gif');
$b = new Imagick('../b.png');

$b->compositeimage($a, imagick::COMPOSITE_MULTIPLY, 0, 0);
$b->writeimages('../img/test.gif', true);
	
$a->compositeimage($b, imagick::COMPOSITE_MULTIPLY, 0,0 );
$a->writeimages('../img/test2.gif', TRUE);
but i get an image with the animated GIF visible only or a static pic where with one of the first frames of the animated GIF + the static PNG as background.. but not animated.

Any hints would be great..

Thanks in advance
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Combine a animated GIF with a static PNG

Post by fmw42 »

sroBandit
Posts: 3
Joined: 2011-09-25T03:00:43-07:00
Authentication code: 8675308

Re: Combine a animated GIF with a static PNG

Post by sroBandit »

Sorry for delayed answer..

Thanks for the link, i "understand" what happens there or what should be done, but i dunno know how to solve my problem in PHP.
I dont wanna use the commandline version, i want to use the lib itself.

Do i need an imagick() and an imagickDraw() object and combine them? If so, would be great, if you can gimme some help.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Combine a animated GIF with a static PNG

Post by fmw42 »

sorry I don't code Imagick, only command line. But see if you can find similar commands at http://us3.php.net/manual/en/book.imagick.php
sroBandit
Posts: 3
Joined: 2011-09-25T03:00:43-07:00
Authentication code: 8675308

Re: Combine a animated GIF with a static PNG

Post by sroBandit »

Ok,

tried a few other things.. Would be great, if someone could gimme a hint, i dont get any correct image..
An example would be great!

Thanks in advance..
Post Reply