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

UnicodeDecodeError when calling put_photo with an image generated with PIL #43

Closed
honi opened this issue Aug 17, 2012 · 5 comments
Closed

Comments

@honi
Copy link

honi commented Aug 17, 2012

For some reason, images generated with PIL throw a UnicodeDecodeError when trying to upload to Facebook.

Tested opening the image in Photoshop and saved as a new copy, and that image uploaded fine.

@martey
Copy link
Member

martey commented Aug 17, 2012

Would it be possible for you to provide an image that is causing this error? This would help with debugging.

@honi
Copy link
Author

honi commented Aug 17, 2012

Yes, of course: http://imagebin.org/224882. This image was generated with PIL.

I'm also debugging on my side, will post if anything new.

@honi
Copy link
Author

honi commented Aug 17, 2012

I've managed to make it work like this:

image = Image.open('/path/to/image.jpg')
image_io = StringIO()
image.save(image_io, 'jpeg', quality=95)
image_io.seek(0)

api = GraphAPI('oauth_token')
api.put_photo(image_io, 'Uploaded image from Facebook SDK')

@honi
Copy link
Author

honi commented Aug 19, 2012

One more thing be careful with.

Everything was working fine, until I added album_id parameter in put_photo. Then I started getting:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 345: ordinal not in range(128)

Turns out my album_id was an int. Just had to cast it to str() when calling put_photo for everything to work.

@martey
Copy link
Member

martey commented Jan 26, 2015

I am pretty sure that this issue has been fixed by moving to requests (which involved significant changes to how put_photo works). Closing.

@martey martey closed this as completed Jan 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants