Page 1 of 1

Speed Processing

Posted: 2008-04-15T11:49:57-07:00
by nonaguy
Hi guys, right now I am using Imagemagick quite a bit where I work, on several different functions. Right now what I am using it for is to load an image into memory, convert a high quality tiff into a jpeg that's a much smaller file size, all without touching the original file. This is all part of a larger web application that allows users to browse imaged historical documents. Here is the php script we are using for the process:

<?php
$resolution=$_GET["res"];
$presize=($resolution*2);
$photo="test.tif";
$cmd = "convert \"$photo\" -scale 50% -strip -unsharp 0.2x0.6+1.0 -quality 87 JPG:-";
header("Content-type: image/jpeg");
passthru($cmd, $retval);
?>

This takes some time to load an image, approximately seven seconds. We would like to get this load time reduced by as much as possible. Is there any way in imagemagick to reduce these load times, such as sacrificing some quality for speed? Or is there some kind of complementary program that can be used? Thank you.

Re: Speed Processing

Posted: 2008-04-15T12:05:19-07:00
by magick
Is the image new for each conversion instance? If so, the only speed up options are to rewrite your script using IMagick or MagickWand for PHP or run the process on a faster computer with plenty of memory or use a utility other than convert. If the image does not change, convert it to the MPC format which consumes lots of disk space but has near-zero overhead to load. In addition if the conversion often creates the same JPEG output file you can precompute and cache these images so not conversion need take place when they are requested.

For MPC:
  • convert image.tif image.mpc (one time conversion)
    convert image.mpc -scale 50% -strip -unsharp 0.2x0.6+1.0 -quality 87 JPG:-

Re: Speed Processing

Posted: 2008-04-15T13:14:10-07:00
by nonaguy
We have 65,000 images, and they may be called once a day, never, ten times a day, etc. These will be changed each time they are accessed (though as I said before, the original files will still remain untouched, just called into memory). Server platform is 4 way with 4 gig of RAM. What utility other than convert would you recommend? We are currently looking into imagick and magickwand, thanks. By the way, what kind of performance enhancement would we see with these?

Re: Speed Processing

Posted: 2008-04-15T16:40:11-07:00
by magick
If you enable OpenMP, unsharp will thread across 4 processors and the process should speed up considerably. Otherwise take your pick. There are probably at least 20 viable image-processing packages both free and commercial you can pick from. Start with NetPBM.

Re: Speed Processing

Posted: 2008-04-16T08:42:27-07:00
by dognose
Are you sure you can't pre generate them for multiple resolutions? flickr does this for their photos.

I'd think that any on the fly conversion would be a noticeable slowdown.