Affine matte stack
Posted: 2007-01-01T22:40:12-07:00
I don't know if this is a bug, an undesirable effect or an expected result. But I was surprised to find that under some conditions (which I have not pinned down), stacked (appended) images behave differently depending on the order of the images, even when of the same size, perhaps with some dependence on which has a matte channel. The following perl script illustrates it, the results being at the link below.
http://sun.cs.lsus.edu/~rmabry/magick/m ... ndtest.plx
Bug or feature? And bug or feature of what? (AffineTransform? Append?) And what happens when either of the two commented-out commands is included? What then makes it come out "right"?
While I'm at it, I am surprised at the way Border works on the stacked images, too.
This is 6.3.1-4 12/24/06 Q16
I hope everyone stayed home last night and got 'pixellated'.
Rick
http://sun.cs.lsus.edu/~rmabry/magick/m ... ndtest.plx
Code: Select all
#!/usr/bin/perl --
use Image::Magick;
$image1 = new Image::Magick;
$image1->Read("logo:");
$image1->Resize('50%'); #needn't be so big for this demo
$image1->Border(width=>4, height=>4, color=>'blue'); #shows up better
($w,$h) = $image1->Get('width', 'height');
$image2 = $image1->Clone(); # two identical images
$image1->AffineTransform(affine=>[1,1,-1,1,0,0]); # any affine matrix can be used here
$image1->Resize("$w x $h!"); # make both images the same size
#uncomment either of the two following and rerun for comparison
# $image2->Draw(primitive=>'line', stroke=>'black', points=>sprintf("0,0 %d,%d", $w-1,$h-1));
# $image2->Set(matte=>'true');
# Now make two stacked images, each stack having the two images in different orders
$image12 = $image1->Clone();
$image21 = $image2->Clone();
$image12->[1] = $image2;
$image21->[1] = $image1;
$image12 = $image12->Append(stack=>'false');
$image21 = $image21->Append(stack=>'false');
# the two images differ, but not in the way I'd have expected
$image12->Border(width=>4, height=>4, color=>'#eeccee'); #shows up better
$image21->Border(width=>4, height=>4, color=>'#eeccee'); #shows up better
$image12->Write("image12.png");
$image21->Write("image21.png");
While I'm at it, I am surprised at the way Border works on the stacked images, too.
This is 6.3.1-4 12/24/06 Q16
I hope everyone stayed home last night and got 'pixellated'.
Rick