Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 668776 - dev-python/pillow-5.3.0 can't save JPEG files
Summary: dev-python/pillow-5.3.0 can't save JPEG files
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Virgil Dupras (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-16 13:42 UTC by Helmut Jarausch
Modified: 2018-10-29 22:35 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (pillow.info,20.66 KB, application/x-info)
2018-10-16 13:42 UTC, Helmut Jarausch
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Helmut Jarausch 2018-10-16 13:42:47 UTC
Created attachment 551446 [details]
emerge --info

The following trivial script

from PIL import Image
IM=Image.open('Testbild.jpeg')
IM.save('Testbild_mod.jpeg',optimize=False)

fails with
I/O suspension not supported in scan optimization
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/site-packages/PIL/Image.py", line 1969, in save
    save_handler(self, fp, filename)
  File "/usr/lib/python3.7/site-packages/PIL/JpegImagePlugin.py", line 761, in _save
    ImageFile._save(im, fp, [("jpeg", (0, 0)+im.size, 0, rawmode)], bufsize)
  File "/usr/lib/python3.7/site-packages/PIL/ImageFile.py", line 519, in _save
    raise IOError("encoder error %d when writing image file" % s)
OSError: encoder error -2 when writing image file

Testbild.jpeg has 4807077 bytes.

Is there any fix or work around?
Thanks,
Helmut
Comment 1 Virgil Dupras (RETIRED) gentoo-dev 2018-10-16 15:13:42 UTC
I have tried the same script with pillow 5.3 on python 3.6 on a jpeg I had lying around. It saved properly. Two possibilities I see:

1. Is it related to the image? Maybe try with other jpeg files to confirm.
2. python3.7? I'm not geared up to test this now, will try later. Or if you'd like to try with py36 on your end, it would be great.

"I/O suspension" looks like a py37-related problem...
Comment 2 Helmut Jarausch 2018-10-16 15:48:03 UTC
(In reply to Virgil Dupras from comment #1)
> I have tried the same script with pillow 5.3 on python 3.6 on a jpeg I had
> lying around. It saved properly. Two possibilities I see:
> 
> 1. Is it related to the image? Maybe try with other jpeg files to confirm.
> 2. python3.7? I'm not geared up to test this now, will try later. Or if
> you'd like to try with py36 on your end, it would be great.
> 
> "I/O suspension" looks like a py37-related problem...

It's exactly the same situation with Python3.6.

I have seen certain error reports on the net which claim that it might be
related with the MAXBUFFER size.

With an image of 458K it works just fine,
with an image of 645K or bigger it shows the error reported here.
Comment 3 Virgil Dupras (RETIRED) gentoo-dev 2018-10-16 22:12:26 UTC
I don't know, my test was made with a 1.66M jpeg file and didn't trigger the bug, so reproduction conditions don't seem so easy to gather.
Comment 4 Virgil Dupras (RETIRED) gentoo-dev 2018-10-16 22:14:48 UTC
Might it be related to https://github.com/python-pillow/Pillow/issues/539 ?
Comment 5 Helmut Jarausch 2018-10-28 15:08:17 UTC
(In reply to Virgil Dupras from comment #4)
> Might it be related to https://github.com/python-pillow/Pillow/issues/539 ?

Yes, I've removed media-libs/mozjpeg which solves the problem.
Thanks!
Comment 6 Virgil Dupras (RETIRED) gentoo-dev 2018-10-28 18:22:18 UTC
media-libs/mozjpeg isn't part of the gentoo tree. How come pillow built against it? Was it your sole installed jpeg library? What overlay did your version of media-libs/mozjpeg come from?
Comment 7 Helmut Jarausch 2018-10-28 18:47:26 UTC
(In reply to Virgil Dupras from comment #6)
> media-libs/mozjpeg isn't part of the gentoo tree. How come pillow built
> against it? Was it your sole installed jpeg library? What overlay did your
> version of media-libs/mozjpeg come from?

media-libs/mozjpeg came from my local overlay.
I'm not sure that mozjpeg was the culprit.
I have media-libs/openjpeg:0 and media-libs/openjpeg:2 as well as
media-libs/libjpeg-turbo installed here.