Enlarging the canvas

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
maxgraphic
Posts: 3
Joined: 2007-12-17T02:22:32-07:00

Enlarging the canvas

Post by maxgraphic »

Hello. I'm sorry if this has been answered elsewhere, but I've haven't had any luck finding a solution.

I'm trying to enlarge the canvas of an existing image. It seems that Crop will reduce the canvas, but not enlarge it, even with judicious use of exclamation marks. I don't want to scale the image itself, just the canvas or page size. Along the lines of Photoshop's "Canvas Size" feature.

More specifically, I'm trying to "embolden" an image by compositing it with itself, offset one pixel. This part works:

my $image = Image::Magick->new;
$image->Read($fn);
my $image2 = $image->Clone;
$image->Composite(compose => 'Darken', x => 1, y => 0, image => $image2);

But I'd like to add one pixel to the width of $image so that the final column is duplicated.

Thanks in advance!

Max
RetroJ
Posts: 108
Joined: 2006-10-25T08:12:50-07:00

Re: Enlarging the canvas

Post by RetroJ »

You want Extent.
maxgraphic
Posts: 3
Joined: 2007-12-17T02:22:32-07:00

Re: Enlarging the canvas

Post by maxgraphic »

RetroJ wrote:You want Extent.
I agree. Unfortunately, $image->Extent gives me:

[error] Can't locate auto/Image/Magick/Extent.al in @INC (@INC contains: /home/max /etc/perl /usr/local/lib/perl/5.8.4 /usr/local/share/perl/5.8.4 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl /usr/local/lib/perl/5.8.3 /usr/local/share/perl/5.8.3 /usr/local/lib/perl/5.8.0 /usr/local/share/perl/5.8.0 . /etc/apache/ /etc/apache/lib/perl) at Item2.pm line 3642

Is it something I need to install separately?

Thanks for your response.
RetroJ
Posts: 108
Joined: 2006-10-25T08:12:50-07:00

Re: Enlarging the canvas

Post by RetroJ »

I can only guess that you are running an old PerlMagick.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Enlarging the canvas

Post by anthony »

You could try using splice with appropriate gravity options to add the one pixel column and row. It is a older function than extent.

Before that function the best method would be to append a single pixel image to the existing image.

Sorry I do not use PerlMagick often enough to know the function calls without looking them up myself.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply