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
ImageOps.expand distorts image and converts png to grayscale #5375
Comments
The bug is because the image is in P mode. If you are interested in an immediate solution, convert it to RGB. from PIL import Image, ImageOps
i = Image.open('./bo.png')
i = i.resize((128,96))
# File saves correctly
i.save('./test.png')
i = ImageOps.expand(i.convert("RGB"), border=10, fill='black')
# File gets converted to grayscale and is distorted
i.save('./test.png') |
Thanks! Would this still be classified as a bug? I think it could be considered one? |
Yes, this is still a bug that we should address. |
I faced the same problem and solved it by converting it to RGB, Thanks. |
This was referenced Jun 19, 2021
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What did you do?
Resize an image and add a black border
What did you expect to happen?
Image would be resized with a black border
What actually happened?
Image is distorted converted to grayscale, resized and border added
What are your OS, Python and Pillow versions?
git clone https://github.com/hampusborgos/country-flags.git cd country-flags/png1000px
The text was updated successfully, but these errors were encountered: