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

accept pathlib.Path instances #452

Closed
thijstriemstra opened this issue Dec 30, 2019 · 4 comments
Closed

accept pathlib.Path instances #452

thijstriemstra opened this issue Dec 30, 2019 · 4 comments
Labels

Comments

@thijstriemstra
Copy link
Contributor

@thijstriemstra thijstriemstra commented Dec 30, 2019

Would be nice if Image (and others?) would accept a pathlib.Path instance.

from pathlib import Path

fpath = Path('/media/bar/Lake_town-home.jpg')

with Image(filename=fpath):
    pass

Traceback (most recent call last):
  File "/home/bar/.virtualenvs/foo/lib/python3.7/site-packages/wand/image.py", line 8762, in save
    repr(filename))
TypeError: filename must be a string, not PosixPath('/media/bar/Lake_town-home.jpg')
@emcconville
Copy link
Owner

@emcconville emcconville commented Dec 30, 2019

It should! Or, perhaps, you located an area/method that does not. Could that error message be coming from another code-location then the one you posted? Just tested with Python 3.7 & 3.8 images load fine from PosixPath instances.

@thijstriemstra
Copy link
Contributor Author

@thijstriemstra thijstriemstra commented Dec 30, 2019

you're right, it's save that triggered the traceback.

main_img.save(filename=fpath)

@emcconville
Copy link
Owner

@emcconville emcconville commented Dec 30, 2019

Got it. 9d4ca66 should fix it.

@thijstriemstra
Copy link
Contributor Author

@thijstriemstra thijstriemstra commented Dec 30, 2019

Afaik it's not documented anywhere that Path's are accepted..

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

No branches or pull requests

2 participants