Image Magick: read once, make copies

From: david (signdavidup_at_yahoo.com)
Date: 02/25/04


Date: 25 Feb 2004 07:58:47 -0800

Hi, I've been searching the archives for an answer to this but
unfortunately the search terms I could think of are rather generic...

I want to read an image into ImageMagick (no problem there) and then
resize it to 4 different sizes, and write the image back out to 4
different files.

So I'd like to avoid re-reading the image 4 times:

# create image objects
my $image = Image::Magick->new;
my $large_image = Image::Magick->new;
my $small_image = Image::Magick->new;
my $tiny_image = Image::Magick->new;

# read same image 4 times
$image->Read('image.jpg');
$large_image->Read('image.jpg');
$small_image->Read('image.jpg');
$tiny_image->Read('image.jpg');

# resize each image
$image->Resize( width => 270, height => 400);
$large_image->Resize( width => 405, height => 600);
$small_image->Resize( width => 101, height => 150);
$tiny_image->Resize( width => 27, height => 40);

I'd like to instead read the image once, and then somehow copy the
$image object, and the image data, to new objects -- wouldn't this
save some overhead? However, I know if I copy $image I'm just going
to get another reference to the original, and I need fresh copies of
the original.

thanks for any help

David Blaikie



Relevant Pages

  • Re: Does XST support global signals?
    ... the google news archives from time to time; my replies sometimes ... Note that although the search terms are filled in again ... It's good to know someone else has managed to use global signals with ...
    (comp.arch.fpga)
  • Re: chemical questions
    ... > i've been looking in the archives, but i also like to post these questions ... >> You have some excellent search terms there for Google groups (in ... >> rec.pyroetchnics) or a WWW search engine. ... living, and the amateurs with long experience, are not replying, possibly ...
    (rec.pyrotechnics)
  • Re: chemical questions
    ... i've been looking in the archives, but i also like to post these questions ... how is copper carbonate used in a comp to make color? ... > You have some excellent search terms there for Google groups (in ...
    (rec.pyrotechnics)