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

'float' object cannot be interpreted as an integer exception when applying point transforms #6187

Closed
avmusat opened this issue Apr 6, 2022 · 2 comments · Fixed by #6188
Closed
Labels
Anaconda Issues with Anaconda's Pillow

Comments

@avmusat
Copy link

avmusat commented Apr 6, 2022

What did you do?

Following the docs to apply point transforms:
https://pillow.readthedocs.io/en/stable/handbook/tutorial.html?highlight=.point(#applying-point-transforms

What actually happened?

The following exception was raised: 'float' object cannot be interpreted as an integer.

What are your OS, Python and Pillow versions?

  • OS: Windows 11 Pro (22000.556)
  • Python: 3.10.4 (packaged by conda-forge)
  • Pillow: 9.1.0

Code to reproduce

from PIL import Image

image = Image.open(image_path).convert('RGBA')
alpha_channel = image.getchannel('A')
image.putalpha(alpha_channel.point(lambda x: x * 0.5))

With Pillow 8.3.2 and Python 3.8, the above code worked well.

Edit: I've tested Pillow 9.1.0 with Python 3.9.12 and it works fine, so it seems to be an issue related to Python 3.10.x

@radarhere
Copy link
Member

Thanks. This would be because of https://docs.python.org/3/c-api/long.html#c.PyLong_AsLong

Changed in version 3.10: This function will no longer use __int__().

I've created PR #6188 to resolve this.

@avmusat
Copy link
Author

avmusat commented Apr 7, 2022

Great, it should do the trick. Thanks!

@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

Successfully merging a pull request may close this issue.

3 participants