Let's say I have one input JPEG image (i.e. 3500 x 2500 px, around 3MB). Is there a way to read this file once and resize it to multiple output formats, without reading the source file again? Currently I'm doing something like this:
Code: Select all
my $img = Image::Magick->new;
foreach my $outputfile(@outfiles) {
$img->Read($inputfile);
$img->Scale(geometry => "${scale}x${scale}");
$img->Write($outputfile);
@$img = ();
}
undef $img;
If I put Read() outside loop then I do operations on the same picture. It's fast, but each scaling is using already scaled image. It causes problems when 1 format is very small and the next one is larger. I believe there has to be a way to always reach for source image without using the expensive Read() every time.
Thanks in advance for any hints or suggestions.
Yosh