We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
from PIL import Image img = Image.open('p.png') print('P->L: ', img.convert('L').getpixel((0, 0))) print('P->RGB: ', img.convert('RGB').getpixel((0, 0))) print('P->RGB->L: ', img.convert('RGB').convert('L').getpixel((0, 0)))
p.png:
Old PIL: 6.2.2 P->L: 175 P->RGB: (177, 175, 175) P->RGB->L: 175
7.0.0+ After commit #4320 PIL: 8.3.2 P->L: 175 P->RGB: (177, 175, 175) P->RGB->L: 176
The text was updated successfully, but these errors were encountered:
This is because P->L uses the L macro, but RGB->L uses the L24 macro.
So this change would make P->L be 176 as well.
diff --git a/src/libImaging/Convert.c b/src/libImaging/Convert.c index 9012cfcd7..cd6e536cb 100644 --- a/src/libImaging/Convert.c +++ b/src/libImaging/Convert.c @@ -1013,7 +1013,7 @@ p2l(UINT8 *out, const UINT8 *in, int xsize, const UINT8 *palette) { int x; /* FIXME: precalculate greyscale palette? */ for (x = 0; x < xsize; x++) { - *out++ = L(&palette[in[x] * 4]) / 1000; + *out++ = L24(&palette[in[x] * 4]) >> 16; } }
But I'm by no means certain that this is the correct solution.
Sorry, something went wrong.
I've created #5824 to fix this by applying rounding to palette conversion methods.
Successfully merging a pull request may close this issue.
p.png:
Old
PIL: 6.2.2
P->L: 175
P->RGB: (177, 175, 175)
P->RGB->L: 175
7.0.0+
After commit #4320
PIL: 8.3.2
P->L: 175
P->RGB: (177, 175, 175)
P->RGB->L: 176
The text was updated successfully, but these errors were encountered: