[Image-SIG] 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 ctimmerman2 at gmail.com
Mon Jun 6 16:45:11 CEST 2011


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20110606/72910314/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: resize.7z
Type: application/octet-stream
Size: 4618811 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/image-sig/attachments/20110606/72910314/attachment-0001.obj>


More information about the Image-SIG mailing list