Discussion:
Converting tiff to PNG
Jeff van Aswegen
2007-08-02 10:18:30 UTC
Permalink
Hi there

I've written a script which converts around 20000 TIFF images to PNG images
everyday. The PIL module takes to long and I'm therefore using Imagemagick
to perform the conversion. My problem is I need to compress the tiff as much
as possible. The best I can do is get a 60kb TIFF Image to around a 100kb
PNG image. I can get it down an extra kb or 2 by running it through PNGCrush
but this takes way too long. The best command I can come up with is

convert img.tif -monochrome +matte -depth 8 -quality 100 img.png

-rw-r--r-- 1 jeffreyva jeffreyva 59328 2007-08-02 12:09 img.tif
***@jeffrey:$ time convert img.tif -monochrome +matte -depth 8
-quality 100 img.png

real 0m7.041s
user 0m6.664s
sys 0m0.160s

-rw-r--r-- 1 jeffreyva jeffreyva 99340 2007-08-02 12:10 img.png

Has anyone worked with any utilities or has been successful in converting a
TIFF image to a PNG which is almost the same size as the original TIFF?
Look forward to hearing from anyone.

Thanks

Jeffrey van Aswegen
Christopher Barker
2007-08-06 19:06:27 UTC
Permalink
Post by Jeff van Aswegen
convert img.tif -monochrome +matte -depth 8 -quality 100 img.png
This looks like you've got an 8-bit monochrome tiff.

From a quick glance at:

http://www.w3.org/TR/REC-png-multi.html

it looks like PNG should support that, but it is mostly used for 24bit
RGB and 32bit RGBA. I'm guessing that perhaps you're getting an RGB PNG,
which would explain why it's larger than the Tiff.

It does seem like the flags you're passing into convert should be doing
this right, but I'd check to see if they are.

You might see what PIL gives you, making sure you use the 'L' mode (8
bit greyscale)

-Chris
--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

***@noaa.gov
_______________________________________________
Image-SIG maillist - Image-***@python.org
http://mail.python.org/mailman/listinfo/image-sig
j***@gmail.com
2007-08-06 21:02:16 UTC
Permalink
Post by Jeff van Aswegen
Has anyone worked with any utilities or has been successful in converting a
TIFF image to a PNG which is almost the same size as the original TIFF?
Look forward to hearing from anyone.
Hi, could you post a sample image somewhere? I could have a go for you.

John
_______________________________________________
Image-SIG maillist - Image-***@python.org
http://mail.python.org/mailman/listinfo/image-sig

Loading...