Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting Pillow .tiff image to numpy uint8 produces TypeError on Windows 10 #4447

Closed
mvanlierBCG opened this issue Feb 24, 2020 · 5 comments
Labels
Anaconda Issues with Anaconda's Pillow

Comments

@mvanlierBCG
Copy link

mvanlierBCG commented Feb 24, 2020

What did you do?

Loading a .tiff image:

img = Image.open(img_name)

Convert the loaded image to a NumPy array:

image_array = np.array(img, dtype='uint8')

What did you expect to happen?

That I am able to covert the loaded image to a NumPy array.
In OS: Ubuntu 18.04.5 the environment, same version names don't throw an error and it works.

What actually happened?

TypeError:
int() argument must be a string, a bytes-like object or a number, not 'TiffImageFile'

What are your OS, Python and Pillow versions?

  • OS: Windows 10
  • Python: 3.7
  • Pillow: 7.0.0
from PIL import Image
import numpy as np
img = Image.open(img_name)
image_array = np.array(img, dtype='uint8')

Tiff image
test_tiff.zip

@cgohlke
Copy link
Contributor

cgohlke commented Feb 25, 2020

Cannot reproduce:

Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
>>> import numpy as np
>>> img = Image.open('test_tiff.tiff')
>>> image_array = np.array(img, dtype='uint8')
>>> image_array.shape
(1028, 2448, 3)
>>> np.__version__
'1.16.6'

@kmilos
Copy link
Contributor

kmilos commented Feb 25, 2020

This is a compressed TIFF file, and I suspect, the same libtiff build problem as #4237

But Pillow should really handle this better, i.e. I don't think #3863 is fully closed.

@radarhere radarhere changed the title Converting Pillow .tiff image to numpy uinit8 produces TypeError on Windows 10 Converting Pillow .tiff image to numpy uint8 produces TypeError on Windows 10 Feb 29, 2020
@radarhere
Copy link
Member

radarhere commented May 15, 2020

Could we get a complete traceback for the error?

Could you check if your Windows and Ubuntu systems are using different versions of libtiff? That could also be helpful.

>>> from PIL import Image
>>> Image.core.libtiff_version
'LIBTIFF, Version 4.1.0\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc.'
>>> 

@radarhere
Copy link
Member

I'm not able to reproduce this on our GitHub Actions or AppVeyor jobs, so closing due to lack of response.

@zhangsan5213
Copy link

zhangsan5213 commented Jun 5, 2021

I just got the same thing on conda 4.9.2 python 3.7

image

I'm using also python 3.7 on my laptop and it worked fine. My PC was not good and threw me the error above.

@aclark4life aclark4life added the Anaconda Issues with Anaconda's Pillow label May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Anaconda Issues with Anaconda's Pillow
Projects
None yet
Development

No branches or pull requests

6 participants