I'm new to Perl. I am trying to write out an animated .gif file using Image::Magick. The directions I have seen say to use <*.png> to pick up all the .png originals from a directory. The problem is that I don't want them in the order they appear in the directory (alphabetical). I therefore put them in an array, in the order I need for the output to look correct. However, when the animated .gif is produced, anytime there is a repeat of a .png image, the next frame in the animated .gif is incorrect - it will only include the top portion of the image. However, if I fool it by adding a blank image to the mix, after each of the input images, it works fine. My question is: what kind of regex would I need that would look at the array and only add the 66.png blank image after each Repeating numbers instead of after each image. Or is there a better way to fix the script for Image::Magick not to stutter on my array of png inputs?? Any help you can offer to a new kid?

Here's the basic script...(before I added use strict etc)

#!/usr/bin/perl print "Content-type: text/html\n\n"; use Image::Magick; srand(); $ext = ".gif"; $front = "FL"; $numb = (int (rand(6969) + 1)); $name = qq~$front$numb$ext~; my $image = Image::Magick->new; @files = ("12.png","06.png","06.png","03.png","07.png","07.png"); foreach $one (@files) { $image->Read($one); } $image->Set ( loop=>'0', delay=>'40', adjoin=>'True', dispose=>'2' ); $image->Write( "$name" ); This produces an animated .gif, but with a stutter in it after the first repeat of 06.png. If I change the array to add a blank image (66.png) after each image, this works fine: @files = ("12.png","66.png","06.png","66.png","06.png","66.png", "03.png","66.png","07.png","66.png","07.png");
Update: Thanks very much - that works !

In reply to Help with Image Magic by gringocharlie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.