PNG + GIF combine questions

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
gormonn
Posts: 8
Joined: 2014-03-19T03:09:41-07:00
Authentication code: 6789

PNG + GIF combine questions

Post by gormonn »

Hello!
I am developing a service that will combine static images with animated pictures. In howling script I use the following PHP algorithm:

Code: Select all

$animation = new Imagick();
$animation->setFormat("GIF");
$gif = new Imagick('img/gif/anim.gif'); 
$gif = $gif->coalesceImages(); 
foreach ($gif as $frame) { 
  $canvas -> compositeImage($frame , imagick::COMPOSITE_DEFAULT , 0,0);
  $animation->addImage($canvas);
  $animation->nextImage();
}
$animation->writeImages('gallery/gif/'.$fileName.'.gif', true); 
echo "/gallery/gif/".$fileName.".gif";
Then get on the file using AJAX.

Picture generated about 30 seconds, which in itself - quite a lot.
1. Are there ways to increase the speed s software image generation?
2. Is it possible to combine with a translucent gradient PNG and GIF, while maintaining transparency gradient? How do previous frames without layering on each other?
gormonn
Posts: 8
Joined: 2014-03-19T03:09:41-07:00
Authentication code: 6789

Re: PNG + GIF combine questions

Post by gormonn »

Now i use this:

Code: Select all

$cmd = "  convert $path \( $gif -repage 0x0+300+53\! \) \
          -coalesce -delete 0 -deconstruct -loop 0 ".$nickName.".gif
  gif_anim_montage  ".$nickName.".gif  bunny_bgnd_frames.gif ";
And i have a problem. Aplha channell is'not support?
How to be:
Image

Problem edged aplha channel:
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PNG + GIF combine questions

Post by fmw42 »

GIF only supports binary transparency. PNG supports 8-bit alpha transparency. So if you input PNG has 8-bit alpha, it will get converted to binary transparency and may not look the way you want. You should preprocess your PNGs to binary transparency GIFs first using some method such as -threshold so that you can control the way the binary transparency will look.
gormonn
Posts: 8
Joined: 2014-03-19T03:09:41-07:00
Authentication code: 6789

Re: PNG + GIF combine questions

Post by gormonn »

Thank you very much! I did not know this subtleties.
Binary - a 2 state - or transparency is, or e not is not it?
That is possible only with the flow of the background.
Post Reply