List Info

Thread: Error when saving JPEG with quality above 85 and optimize




Error when saving JPEG with quality above 85 and optimize
user name
2006-04-02 15:38:01
When I try to save JPEG files with quality above 85 and
optimize=1, I 
get this traceback:

 >>> image.save("foo.jpg", quality=86,
optimize=1)

Suspension not allowed here
Traceback (most recent call last):
   File "<stdin>", line 2, in ?
   File "<stdin>", line 2, in save
   File
"/opt/local/lib/python2.4/site-packages/PIL/Image.py&
quot;, line 
1305, in save
     save_handler(self, fp, filename)
   File
"/opt/local/lib/python2.4/site-packages/PIL/JpegImageP
lugin.py", 
line 409, in _save
     ImageFile._save(im, fp, [("jpeg",
(0,0)+im.size, 0, rawmode)])
   File
"/opt/local/lib/python2.4/site-packages/PIL/ImageFile.
py", line 
491, in _save
     raise IOError("encoder error %d when writing
image file" % s)
IOError: encoder error -2 when writing image file

For publishing photographs in both full size and thumbnails,
I find 
quality level of 90-95 to give the best results. I hoped
that optimize 
would give even better results 

I compared PIL, GIMP and Photoshop output, seems that all
give almost 
identical results for the same output file size. PIL seems
to give 
little sharper results - maybe because I resized the images
using 
ANTIALIAS and both Photoshop and GIMP support only BICUBIC
filter?

Last, a note about the docs:

	"Keyword options can be used to provide additional
instructions to the 
writer. If a writer
	doesn't recognise an option, it is silently
ignored."

Thats evil - if an option is not recognized, it should
raise.

	"The available options are described later in this
handbook."

Where is the link to the options? at least where is
"later"?


Best Regards,

Nir Soffer

_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig
Error when saving JPEG with quality above 85 and optimize
user name
2006-04-02 23:40:56
On Apr 3, 2006, at 00:38, Nir Soffer wrote:
> When I try to save JPEG files with quality above 85 and
optimize=1, I
> get this traceback:
>>>> image.save("foo.jpg",
quality=86, optimize=1)
>
> Suspension not allowed here

Try this workaround for the way the JPEG library works:
   http://mail.python.org/pipermail/image-sig/199
9-August/000816.html

> 	"The available options are described later in
this handbook."
> Where is the link to the options? at least where is
"later"?

There is an appendix titled "Image File Formats"
that includes notes  
including the options accepted by save() and the 'info'
properties  
supported by each format.  In the online version, it is
here:
   http://www.pythonware.com/library/pil/handbook/formats
.htm

Of course, looking through the code is the best method to
get up to  
date information.  


-- 
Jim Tittsler  7J1AJH/AI8A  Tokyo                     GPG:
0x01159DB6
http://www.qsl.net/7j1ajh/
                       QRP/Satellites/APRS
                                                         
AMSAT/NZART


_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )