Repository navigation
Closed
Description
What did you do?
Following on from #4509 after the 7.1.0 release, we have a new issue that cropped up opening a png from scikit-image.
What did you expect to happen?
Not error.
What actually happened?
It errored.
What are your OS, Python and Pillow versions?
- OS: Linux
- Python: 3.8.2
- Pillow: 7.1.0
The code should just be loading a scikit-image PNG data:
from skimage import data
original = data.camera().astype('float')The error message is:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/miniconda/envs/sunpy/lib/python3.8/site-packages/skimage/data/__init__.py", line 109, in camera
return _load("camera.png")
File "/opt/miniconda/envs/sunpy/lib/python3.8/site-packages/skimage/data/__init__.py", line 96, in _load
return imread(_os.path.join(data_dir, f), plugin='pil', as_gray=as_gray)
File "/opt/miniconda/envs/sunpy/lib/python3.8/site-packages/skimage/io/_io.py", line 48, in imread
img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
File "/opt/miniconda/envs/sunpy/lib/python3.8/site-packages/skimage/io/manage_plugins.py", line 210, in call_plugin
return func(*args, **kwargs)
File "/opt/miniconda/envs/sunpy/lib/python3.8/site-packages/skimage/io/_plugins/pil_plugin.py", line 36, in imread
return pil_to_ndarray(im, dtype=dtype, img_num=img_num)
File "/opt/miniconda/envs/sunpy/lib/python3.8/site-packages/skimage/io/_plugins/pil_plugin.py", line 66, in pil_to_ndarray
image.seek(i)
File "/opt/miniconda/envs/sunpy/lib/python3.8/site-packages/PIL/PngImagePlugin.py", line 748, in seek
self._seek(f)
File "/opt/miniconda/envs/sunpy/lib/python3.8/site-packages/PIL/PngImagePlugin.py", line 791, in _seek
cid, pos, length = self.png.read()
AttributeError: 'NoneType' object has no attribute 'read'Since this is scikit image loading one of their PNGs, I wonder if it's actually a bug there.
Reacted by Talley Lambert, Raphael Preston, davidb1 and klezm
Activity
pmrowla commentedon Apr 3, 2020
I'll look into this, I think the issue is
seek(1)(or anything > 0) not raising EOFError for regular png'ssetup: pin Pillow to 7.0.0
hugovk commentedon Apr 6, 2020
We've merged a fix for this (#4528). Before we release, it would be helpful if people could run their test suites with the
masterbranch to check if there are other regressions. Thanks!nabobalis commentedon Apr 6, 2020
I just pip installed master and run the given example (and my local test suite), and everything is working. Thanks!
aderchox commentedon Apr 20, 2020
I have the same issue, could someone tell me how I can get it fixed please? I bumped into this problem when using scikit-image (in a line with
data.coins()in it, which is supposed to read an image of some coins as a numpy object) and reading the error messages it seems to be an issue with pillow. I'm using the pillow-7.1.1, is there a newer one I should install using pip?radarhere commentedon Apr 20, 2020
Hi @aderchox. Here are three options
Downgrate Pillow to 7.0.0 until the next version is released
pythonic2020 commentedon Apr 23, 2020
Hmm, option # 3 above worked for me, but I had to leave this in the plugin file:
I did delete this:
radarhere commentedon Apr 26, 2020
Pillow 7.1.2 has now been released with the fix for this.
Remove pin now Pillow issue is fixed
pythonic2020 commentedon Apr 26, 2020
Excellent! When will it be up on conda forge?
hugovk commentedon Apr 26, 2020
We don't maintain the conda forge package, but see conda-forge/pillow-feedstock#78.
TOUATI-MOHAMED commentedon Apr 29, 2020
try ti upgrade Pillow
apt update
apt install python3-pip -y
apt install libjpeg8-dev zlib1g-dev libtiff-dev libfreetype6 libfreetype6-dev libwebp-dev libopenjp2-7-dev libopenjp2-7-dev -y
pip3 install pillow --global-option="build_ext" --global-option="--enable-zlib" --global-option="--enable-jpeg" --global-option="--enable-tiff" --global-option="--enable-freetype" --global-option="--enable-webp" --global-option="--enable-webpmux" --global-option="--enable-jpeg2000"
Use latest version of Pillow
Update package pillow: