Animating Woes.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Handle

Animating Woes.

Post by Handle »

Code: Select all

<?php

header("Content-Type: image/gif");

$im1 = imagecreatefromPNG("image1.gif");
$im2 = imagecreatefromPNG("image2.gif");

imageGIF($im1);
imagedestroy($im1);

imageGIF($im2);
imagedestroy($im2);

?> 
Hi,

I've spent the best part of a day trying to find an answer to this, basically I would like to make an animated Gif which loops between these two images, can anyone help?

Thanks
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Animating Woes.

Post by anthony »

You will need to append one image into the wand of the other image and set the delay, disposal and looping metadata as appropriate.

A good start is understanding the GIF animation handling which IM Examples, Animation Basics goes into, though only using the command line version of IM. However everything the command line can do, the various API's should also be able to do.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Handle

Re: Animating Woes.

Post by Handle »

I'm not sure I follow mate, I'm quite new to all this :D

do I need to use the convert command, and is there anyway to do it without using commands?

Thanks
Handle

Re: Animating Woes.

Post by Handle »

Code: Select all

<?php

$namestring = "Name";

$im = '1.gif';
$im1 = '2.gif';

passthru("convert -delay 500 -loop 0 '$im' '$im1' gif:-" );

?> 
ok I've made some progress, it now animates between each picture. I now need to add some text ($namestring) to the first image ($im), can anyone help?

thanks
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Animating Woes.

Post by anthony »

See IM examples, Text Handling, and Annotating.
Also look at Animation Modification where I draw a copyright notice onto separate frames on an animation
http://www.imagemagick.org/Usage/anim_mods/#frame_mod

NOTE you should be able to do this without using the command line version, though thanks to IM examples there is a lot more examples in using IM via the command line version, weather it run from PHP or from Shell.

NOTE; PHP actually runs commands through Shell as well making three API layers to deal with. I have not seen a simple 'exec()' type system call in the PHP api to allow you to avoid having a IM command parsed by the shell as well (changling the initial quoting and command argument seperation). This is a real security problem for PHP!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Handle

Re: Animating Woes.

Post by Handle »

Code: Select all

<?
  header('Content-Type: image/gif');

  $im = 'image1.gif';

exec("convert $im -font Fonts/arial.ttf \\
-pointsize 50 -draw \"gravity north fill black text 0,-5 'TEXT' \");

  $im1 = 'image2.gif';

  passthru("convert -delay 500 -loop 0 '$im' '$im1' gif:-" );

?>
could I not draw onto the first image and the create an animation? I tried it above but it didn't work, so maybe not?

Thanks
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Animating Woes.

Post by anthony »

Should be able to. test it out on the command line first.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply