Page 1 of 1

PerlMagick - append images not working

Posted: 2009-11-19T13:34:05-07:00
by autsch
Hi,

I'm sure not if my question belongs to the user-forum or to the bug-forum.
After trying for several hours I believe that it could be a bug.
But because I'm new to this forum I decided to post in the user forum.
Perhaps am I doing something wrong.

I use PerlMagic which comes with ImageMagick-6.5.7-8.
My Perl Version is ActivePerl-5.8.9.826-MSWin32-x86-290470.
Operating System is Win XP Sp3.

Within Perl, the reading, manipulating (e.g. flop) and writing back of the images
is working without problems.

The problem starts, if I try to append 2 images to a single one :

Here ist my code :

my($image, $image2, $x);
$image = Image::Magick->new;
$image2 = Image::Magick->new;

$x = $image->Read("E:\\Tmp\\test\\test.bmp");
print ("read1 : $x\n");

$x = $image->Read("E:\\Tmp\\test\\test2.bmp");
print ("read2 : $x\n");

$x = $image->Append(stack=>true);
print ("append : >$x<\n");

$x = $image->Write("E:\\Tmp\\test\\new.bmp");
print ("write : $x\n");


outoput is :

read1 :
read2 :
append : >Image::Magick=ARRAY(0x1a183b0)<
write :


The result are 2 Files (new.bmp.0 and new.bmp.1) :(

I also tried this version :

my($image, $image2, $x);
$image = Image::Magick->new;
$image2 = Image::Magick->new;

$x = $image->Read("E:\\Tmp\\test\\test.bmp");
print ("read1 : $x\n");

$x = $image->Read("E:\\Tmp\\test\\test2.bmp");
print ("read2 : $x\n");

$x = $image_new = $image->Clone();
print ("Clone : $x\n");
$x = push (@$image_new, $image2);
print ("push : $x\n");
$x = $image_new->Append(stack=>true);
print ("append : >$x<\n");

$x = $image_new->Write("E:\\Tmp\\test\\new.bmp");
print ("write : $x\n");



outoput is :

read1 :
read2 :
Clone : Image::Magick=ARRAY(0x19e8e14)
push : 3
append : >Image::Magick=ARRAY(0x19e8c94)<
write :


The result ist the same; 2 Files. :(

What am I doing wrong ? ? ?
Shouldn't the code produce just a single file with the images appended ? :?:
The source files have the same width and height.

Could anyone help me ?

AUTSCH

Re: PerlMagick - append images not working

Posted: 2009-11-19T18:51:24-07:00
by magick
Append() returns a new image object:
  • $append = $image->Append(stack=>true);
    $append->Write('append.miff');

Re: PerlMagick - append images not working

Posted: 2009-11-21T06:44:37-07:00
by autsch
Thank you,

It's working.
I didn't realized that this method creates a new object.

Since now I made system calls from within a perl program to the Imagemagick 'convert'
commandline.

I made a comparison for the time needed for
'system commandline call for convert within Perl' and the
'append method from PerlMagick'.
The goal is to append 2 images and getting 1 image. So the function is identical.

I measured the time with Time::Hires.

result : commandline call : 0.9 seconds
append method : 0.005 seconds

That's about 200 times faster. PerlMagick is really a speed booster for my perl programms. :D

Thank you again for the quick answer.

AUTSCH