(none) imager-devel
/ help / lists / applications / search /
 

Re: imager speed versus shell commands

From: Greg Krieser (
03949@xyz.molar.is)
Date: Tue 27 Nov 2001 - 16:02:57 UTC


[ Eftirfarandi var sent af vef molar.is í frh. af bréfi
  http://www.molar.is/listar/imager-devel/2001-09/0002.shtml ]

Could someone please take a moment to help me understand
the shell script shown in the earlier message (attached below). I'm trying to resize photos through a perl script.
I've asked my host provider to install the Imager
module, so I can us it for resizing, but they appear
to be hesitant. Perhaps I could use this shell
script. Where can I learn more about the commands
used? Could these commands be incorporated into a perl script?

Thanks for any help you might be able to provide!

QUOTED_MESSAGE:
> Hi
>
> I have a job which scales an image to a smaller image,
> then scales the smaller image to an even smaller image.
> Using imager the code looks like this:
>
> %opts1 = (scalefactor=>.333334); %opts2 =
> (scalefactor=>.25); %exopts=();
> for $file (@allfiles) {
>   # print STDERR "reading
> $srcdir/$file\n";
>   $img=Imager->new();
>   $img->read(file=>"$srcdir/$file")
> or die "error on \"$srcdir/$file\":
> ".$img->{ERRSTR}."\n";
>   # print STDERR "making
> med_res_imager/$file\n";
>   $scale=$img->scale(%opts1) or die
> "error on scale: ".$img->{ERRSTR};
>   $scale->write(file=>"med_res_imager/$file",%exopts);
>   # print STDERR "making
> icon_imager/$file\n";
>   $scale2=$scale->scale(%opts2);
>   $scale2->write(file=>"icon_imager/$file",%exopts);
> }
>
>
> I benchmarked this against the dumb shell
> script:
>
> for $file (@allfiles) {
>   # print STDERR "djpeg $srcdir/$file |
> pnmscale 0.33334 | cjpeg > med_res_pnm/$file\n";
>   system("djpeg $srcdir/$file | pnmscale
> 0.33334 | cjpeg > med_res_pnm/$file");
>   # print STDERR "djpeg
> med_res_pnm/$file | pnmscale 0.25 | cjpeg -quality 60 >
> icon_pnm/$file\n";
>   system("djpeg med_res_pnm/$file |
> pnmscale 0.25 | cjpeg -quality 60 > icon_pnm/$file");
> }
>
>
> I found that imager was 2X slower on a sample of 120
> image. I would have expected the large amount of fork/exec
> and pipe overhead in the latter program to make it slower,
> and I thought Imager's routines are mostly done in C
> anyways. Any thoughts on this? Or am I not using Imager's
> routines correctly?
>
> Thanks