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

On Windows, opening a TIFF with a pathlib.Path argument fails #3823

Closed
anntzer opened this issue May 2, 2019 · 3 comments · Fixed by #3825
Closed

On Windows, opening a TIFF with a pathlib.Path argument fails #3823

anntzer opened this issue May 2, 2019 · 3 comments · Fixed by #3825
Labels

Comments

@anntzer
Copy link
Contributor

anntzer commented May 2, 2019

What did you do?

  1. Create a tiff file (e.g. from pylab import *; savefig("test.tiff") using matplotlib).
  2. Try to load it with Pillow, passing the path as pathlib.Path: from PIL import Image; from pathlib import Path; Image.open(Path("test.tiff")).tobytes()

What did you expect to happen?

The image is correctly loaded (the same as Image.open("test.tiff").tobytes(); using a pathlib.Path also works just fine on Linux).

What actually happened?

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "...\Miniconda3\lib\site-packages\PIL\Image.py", line 746, in tobytes
    self.load()
  File "...\Miniconda3\lib\site-packages\PIL\TiffImagePlugin.py", line 1078, in load
    return super(TiffImageFile, self).load()
  File "...\Miniconda3\lib\site-packages\PIL\ImageFile.py", line 177, in load
    self.map = Image.core.map(self.filename)
TypeError: argument 1 must be str, not WindowsPath

What are your OS, Python and Pillow versions?

  • OS: Windows 10
  • Python: 3.7
  • Pillow: 6.0.0
@radarhere
Copy link
Member

I wasn't able to replicate this on AppVeyor. I don't suppose you could say if you're only experiencing this on Windows 10, and not Windows 7?

Also, while you would think this should be easy to reproduce in the right environment, could you provide a script from start to end, attaching a file if necessary, without matplotlib?

@anntzer
Copy link
Contributor Author

anntzer commented May 3, 2019

from pathlib import Path
from PIL import Image

Image.new("RGBA", (100, 100)).save("test.tiff")
Image.open(Path("test.tiff")).tobytes()

reproes the bug for me.

I don't have readily access to a win7 machine with python.

This Pillow install is from PyPI, fwiw.

@radarhere
Copy link
Member

Thanks. I've created PR #3825 to resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants