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

I am trying to append 4 images left to right using ImageMagick but am getting an error.

Here is my code:

#!/usr/local/bin/perl use Image::Magick; my($image, $x); $image = Image::Magick->new; $x = $image->Read('im1.gif', 'im2.gif', 'im3.gif', 'im4.gif'); warn "$x" if "$x"; $x = $image->Append(stack=>{true,false}); warn "$x" if "$x"; $x->Write('appended.gif'); warn "$x" if "$x";

Replies are listed 'Best First'.
Re: Append images with ImageMagick
by jethro (Monsignor) on Jul 08, 2009 at 00:26 UTC
    It would be useful to know what error you are getting
      the line following:
      $x = $image->Append(stack=>{true,false});
      is throwing a HASH of $x
        I don't think that syntax is valid. Even if "true" and "false" were declared as constants that would be something like $image->Append(stack => { 1 => 0}) I think you really want to just do:
        $x = $image->Append(stack=>0);
        Update: After testing, I found you need to explicitly set stack to 0. Despite what the docs say, Image::Magick 6.4.8 seems to stack by Default.
        To clarify, the stack option is just there to allow you to append images from top to bottom, you want left to right. See the docs