kanegr has asked for the wisdom of the Perl Monks concerning the following question:

Hi I was wondering how to create an animated gif in perl when you have two image files that are the same size. The problem is that my library selection is limited. I don't have access to GD. I do have access to Tk::Animation but have not found a good tutorial on how to create an animated gif using it. If you know how or of other ways to do this please help.

Replies are listed 'Best First'.
Re: Create an animated gif
by poolpi (Hermit) on Nov 13, 2008 at 09:40 UTC
Re: Create an animated gif
by JavaFan (Canon) on Nov 13, 2008 at 01:14 UTC
Re: Create an animated gif
by zentara (Cardinal) on Nov 13, 2008 at 11:31 UTC
      Ok here's the problem I. The project I'm doing this for doesn't have access to any of those libraries. It has the Tk library wich includes Tk::animation which sounds like it should be able to do what I want but I haven't found any examples. I also have access to the CGI library. Is there a way to create and save gif animations with that?
        Are you on Windows? Tk::Animation dosn't have a method to save it's animation. Most installs have ImageMagick, are you sure you don't? There are two ImageMagicks to check for, the PerlMagick module, and the c utilities. Does your system have a command called "convert"? If so, you have it. Otherwise, you will need to download the images to another computer, animate them, then upload them back. If you google for "make gif animations" there are some online sites that will do it, and return them to you.

        I'm not really a human, but I play one on earth Remember How Lucky You Are
Re: Create an animated gif
by Anonymous Monk on Nov 13, 2008 at 09:22 UTC
Re: Create an animated gif
by poolpi (Hermit) on Nov 14, 2008 at 11:17 UTC

    Working solution with Tk::Animation :
    It's create an animated gif with some flat gif files

    #!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Animation; my $mw = MainWindow->new; $mw->title("Animated GIF"); my @gif_files = qw/mygif.gif mygif1.gif/; my $animate = $mw->Animation; for (@gif_files) { $animate->add_frame( $mw->Photo( -file => $_ ) ); } $animate->set_image(0); my $lab = $mw->Label( -image => $animate )->grid; my $start = $mw->Button( -text => 'Start', -command => [ $animate => 'start_animation', 500 ] )->grid; my $stop = $mw->Button( -text => 'Stop', -command => [ $animate => 'stop_animation' ] )->grid; MainLoop;

    Update : link to the gif files

    hth,
    PooLpi

    'Ebry haffa hoe hab im tik a bush'. Jamaican proverb
      Yes, but that script does NOT save the animated gif as a file. I think the OP needed to save the animation to be sent out in a non-Tk application, like in a mail or html file.

      I'm not really a human, but I play one on earth Remember How Lucky You Are
        Yes I need the gif saved as a file. Does that save it as a file?