Creating a 187x250 thumbnail from this (CMYK) JPG results in a 1.91 MB PNG; 32-bit data written instead of reported 24-bit?

"C. Timmerman" <[email protected]>
Newsgroups gmane.comp.python.image
Message-ID <[email protected]>
Creating a max. 250x250 thumbnail from attached 3.55 MB CMYK JPG using PIL
1.1.7 results in a 1.91 MB PNG.

Re-saving the thumbnail with even the lowest (0) compression and ASCII
encoding in IrfanView 4.28 produces a much smaller file: 0.14 MB.

Paint.NET 3.5.8 can create a 1.91 MB version by setting Bit Depth to 32.

Comparing image info with IrfanView, PIL's PNG has blank DPI instead of
96x96, and 24 BitsPerPixel instead of 32.

Platform: 32-bit Windows 7 Enterprise SP1, Python 2.7, PIL 1.1.7.

Code used:

# image_convert.py
# by CT.
# 2011-05-13 v1.0

import glob, os
import Image

input_pics = glob.glob(r"resize\*.jpg")
if input_pics:
print("Resizing pics...")
for pic in input_pics:
print pic
outfile = pic
try:
im = Image.open(pic)
 print "ORG: %s" % ["%s: %r" % (k, str(im.info[k])[:20]) for k in
im.info.keys()]
#continue  # info only.
 im = im.convert("RGB")
print "RGB: %s" % ["%s: %r" % (k, str(im.info[k])[:20]) for k in
im.info.keys()]
 im.thumbnail((250, 250), Image.ANTIALIAS)
 path, ext = os.path.splitext(outfile)
#im.save(path + "_thumb.jpg", quality=96, dpi=(96, 96))
im.save(path + "_250px_PIL_1.1.7.png")
except IOError, er:
print "cannot create thumbnail for", pic
print er
resize.7z (application/octet-stream, 740.7 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.