Select rectangular region -- Clone & Crop?

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
Posts: 2
Joined: 2019-08-13T03:49:52-07:00
Authentication code: 1152

Select rectangular region -- Clone & Crop?

Post by Clarke »

Hello everyone,,
Is Clone & Crop the only way to get a rectangular region from an image (leaving the original intact)??

(something like
$original=Image::Magick->[whichever way];
$rectangle->Crop(geometry=>'80x80+25+50'); )

Is there a way to get/select a rectangular region without having to clone the whole thing first? Or perhaps the overhead is not as scary as I imagine it might be?

I mean, if you're dealing with 100MB (uncompressed) images, and you want to process 1000 rectangular regions... seems like a waste of CPU

It also seems like, with ImageMagick being so versatile and powerful, it would have a more runtime-efficient alternative.

I haven't thoroughly explored the differences yet, but, on cursory research, GTK2 might do this, with its pixel buffers
User avatar
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Select rectangular region -- Clone & Crop?

Post by fmw42 »

Cloning is not needed in command line. I am not sure why it would be needed in PerlMagick if cropping is all you want to do. The actual input file is not changed by reading it into memory. So you can crop it without affecting the disk file. You can just crop the original and save to a new disk file.

If you have further processing that you want to do, then you may want to clone.

Perhaps I do not understand your final goal.
Post Reply