Page 1 of 1

PNG + GIF combine questions

Posted: 2014-03-19T03:30:21-07:00
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?

Re: PNG + GIF combine questions

Posted: 2014-03-20T15:18:02-07:00
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

Re: PNG + GIF combine questions

Posted: 2014-03-20T16:15:54-07:00
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.

Re: PNG + GIF combine questions

Posted: 2014-03-21T04:24:48-07:00
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.