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

Problem rotating P images #5643

Closed
LIMr1209 opened this issue Jul 29, 2021 · 5 comments · Fixed by #5647
Closed

Problem rotating P images #5643

LIMr1209 opened this issue Jul 29, 2021 · 5 comments · Fixed by #5647
Labels

Comments

@LIMr1209
Copy link

LIMr1209 commented Jul 29, 2021

from PIL import Image
import random

img = Image.open('test.png')
rate = random.randint(30, 330)
img = img.rotate(rate)
img.show()
img.save('test_rotate.png')

test
test_rotate

@LIMr1209
Copy link
Author

The image generated by rotating the picture is a binary image

@radarhere radarhere changed the title pillow 8.3.1 rotate problem Pillow 8.3.1 rotate problem Jul 29, 2021
@radarhere
Copy link
Member

If you're looking for an immediate solution, you can convert it to RGB after opening.

from PIL import Image
import random

img = Image.open('test.png').convert('RGB')
rate = random.randint(30, 330)
img = img.rotate(rate)
img.show()
img.save('test_rotate.png')

@LIMr1209
Copy link
Author

Thank you for your answer. It's useful

@radarhere
Copy link
Member

This problem was introduced by #5552

@radarhere radarhere changed the title Pillow 8.3.1 rotate problem Problem rotating P images Jul 30, 2021
@radarhere
Copy link
Member

I've created PR #5647 to resolve this. If you want, you can test it to confirm that it fixes your problem.

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