I have a bunch of scanned images that people are accessing via a web app. The original images are monochrome TIF format and around 2200x1600 pixels. I need to convert them to a format that browsers can display and resize them to a range of smaller sizes. We have a working solution that converts the images on the fly and caches the results but it's a little slow so I'm looking for advice on alternative tools.
The current code calls the 'convert' program from the ImageMagick suite via the system function. It takes approximately 1.5 seconds to resize an image to a 1024x768 PNG. The originals are quite small (40KB) since they're 1 bit per pixel. The PNG is truecolour and closer to 300KB. So far I haven't found the magic combination of command-line arguments to the 'convert' program to make it produce an indexed color PNG. The large file sizes add network delays on top of the file conversion delay.
The first thing I tried was using the Image::Magick module rather than shelling out to the 'convert' command. As far as I can tell I'm using equivalent options, but the run time increases to 2.5 seconds per image and the resulting files are nearly 400KB. I've also been unable to get a conversion to indexed colour working with the module.
Next I tried the Imager module. It is able to produce indexed colour images and with a palette of 8 colours the file size is down to 70KB. Unfortunately the run time is up to 2.5 seconds and the images are rather blurry. Adding an 'unsharp' transform fixes the blur but adds another second of run time.
Finally, I tried the GD module. Unfortunately GD doesn't support TIF format so I read the source files in via a tifftopnm $in_file | pnmtopng pipeline. At 8 colour output the file size is down to a respectable 60KB and the image quality is fine but the run time is around 2 seconds per image.
The 'solution' is likely to involve pre-caching the resized images so that users don't see the delay. However, given that new images are coming in at a rate of thousands per day, reducing the conversion run time would still be useful. Can anyone suggest any other Perl modules or image conversion tools worth checking out?
In reply to Resizing large TIF files by grantm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |