[Image-SIG] PIL bug report: touble in save jpeg file with quality=100 and optimize=True

Fredrik Lundh fredrik at pythonware.com
Sun Jan 25 20:34:42 CET 2009


It's a limitation in the libjpeg library that PIL doesn't work around;
the approach described here should still work:

    http://mail.python.org/pipermail/image-sig/1999-August/000816.html

</F>

2009/1/24 Daniil Osokin <odaniil at gmail.com>:
> Hello
>
> I have try to save jpeg file with quality=100 and optimize but get this:
> -----------------------------------------------------------
> Traceback (most recent call last):
>  File "D:\temp\Python-PIL-test\pil_test.py", line 29, in <module>
>    main("image_test.jpg")
>  File "D:\temp\Python-PIL-test\pil_test.py", line 23, in main
>    img.save(file_out, "JPEG", quality=100, optimize=True)
>  File "C:\Python25\Lib\site-packages\PIL\Image.py", line 1405, in save
>    save_handler(self, fp, filename)
>  File "C:\Python25\lib\site-packages\PIL\JpegImagePlugin.py", line
> 409, in _save
>    ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
>  File "C:\Python25\Lib\site-packages\PIL\ImageFile.py", line 493, in _save
>    raise IOError("encoder error %d when writing image file" % s)
> IOError: encoder error -2 when writing image file
> -----------------------------------------------------------
>
> But this lines work fine:
> img.save(file_out, "JPEG", quality=80, optimize=True)
> or
> img.save(file_out, "JPEG", quality=100)
>
> PIL version 1.1.6
> Python 2.5.4
> Windows XP SP3
>
> test files are attached


More information about the Image-SIG mailing list