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

imager speed versus shell commands

From: David Lai (
Date: Wed 12 Sep 2001 - 18:53:51 UTC

  • Next message: Tony Cook: "Re: imager speed versus shell commands"


    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);
    for $file (@allfiles) {
      # print STDERR "reading $srcdir/$file\n";
      $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};
      # print STDERR "making icon_imager/$file\n";

    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?