Start with our sweet 'rose:' ...
Code: Select all
#!/usr/bin/perl --
use Image::Magick;
$image = new Image::Magick;
$image->Read("rose:");
Code: Select all
$image1 = $image->Clone();
$image1->Border(width=>4, color=>'blue');
$image1->Write('bordertest-w4.png');
Whoa! The above won't do. I just meant a border of constant thickness 4. Like so, using the 'geometry' version:
Code: Select all
$image2 = $image->Clone();
$image2->Border(geometry => '4x', color=>'blue');
$image2->Write('bordertest-4x.png');
Yes, exactly. Now let's try the experiment with 'height'.
Code: Select all
$image3 = $image->Clone();
$image3->Border(height=>8, fill=>'green');
$image3->Write('bordertest-h8.png');
Not good. So we'll try 'geometry again'.
Code: Select all
$image4 = $image->Clone();
$image4->Border(geometry => 'x8', color=>'green');
$image4->Write('bordertest-x8.png');
What the ...? Well, a zero width border when no width is given does make sense. I approve, but these two 'geometry' versions do not seem consistent.
On the other hand, these are fine and identical:
Code: Select all
$image5 = $image->Clone();
$image5->Border(width=>4, height=>8, color=>'red');
$image5->Write('bordertest-w4h8.png');
$image6 = $image->Clone();
$image6->Border(geometry => '4x8', color=>'red');
$image6->Write('bordertest-4x8.png');
Here's the lot:
http://sun.cs.lsus.edu/~rmabry/magick/border/
Also, the 'fill' option is mentioned in the PerlMagick doc, but 'color' is presently synonymous - should that be mentioned? What about 'bordercolor' to be consistent with the commandline version? But then there are 'border' and 'borderwidth' that could also be given their commandline meanings...
I presume that the super-elongated versions are not desired but that the answer is to "always specify what you want". Fair enough. And the difference between the 'geometry' versions of width and height, which are like the command line -border option, are not going to change, as 'width' is probably meant to be synonymous with 'borderwidth' in this context. Okay, okay.
On a slightly different front, shouldn't one of the following give a red border? I'm trying -bordercolor, -fill, -background, but all give a border of correct dimensions but a gray color, the background default color.
Code: Select all
convert rose: -border 4x8 -bordercolor red bordertest-cmd-b4x8.png
Code: Select all
convert rose: -border 4x8 -fill red bordertest-cmd-b4x8.png
Code: Select all
convert rose: -border 4x8 -background red bordertest-cmd-b4x8.png
Rick