Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to recompress and save a tiff that gets created from a HylaFax server. The reason for me doing this is the faxes are often "squished" at the top or bottom. I've found that ImageMagick does the job quite well in perl, but lately i've been receiving large faxes (40 pages or so) the system is running out of memory while reading the tiff. Does anyone know of a better way to re-save/compress tiff? Just reading the tiff is using over 400 MB of RAM and eventually dies. Any suggestions?
  • Comment on Image Magick, Tiffs, and Memory (or lack thereof)

Replies are listed 'Best First'.
Re: Image Magick, Tiffs, and Memory (or lack thereof)
by matty (Initiate) on Nov 17, 2003 at 22:09 UTC
    Well, just for anyone else's sake. What I ended up doing was just dropping the use of Image Magick, as it is terrible. After looking at some of the documentation, it looks like Image Magick does all kinds of unneccisary conversions which cause it to use more memory than it should.

    I then tried using just the Imager module. That would've worked great, but it didn't seem to support multi-page tiff's.

    So, on to my solution. I used tifftools (available on sourceforge), specifically tiffcp to recompress the file. I wrote a simple perl script to run the command line arguments (and watch for errors). The solution that worked fastest, and best for me was to compress the tiff with tiffcp -t in tile mode. Then, turn around and recompress that tile mode tiff in strip mode. That fixed the "squished" tiff problem and took up little memory and time.