Hi, I have a weird issue where I save a png image, windows preview displays the image correctly while opening in an editor shows a blank image
code: https://paste.pythondiscord.com/MZMA
and yes, there is no errors
#π blank png image (PIL)
29 messages Β· Page 1 of 1 (latest)
@tall axle
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
interesting
indeed
why do you think that the preview is correct?
hm, hard to tell what the issue might be. is there perhaps some transparency issue (shown differently for some weird reason)? Maybe, just to see what happens, try to convert the image to just RGB before showing preview and saving the file?
all alpha values are 0.
okay... that would make it transparent, and the "blank image" would be the expected result, and the previews would be wrong.
not really wrong.. but a preview cannot be fully invisible. it has to show something. so instead, it shows as fully black. i think this is an extreme border case.
changing the index, changes the pos of the pixels in the preview, like I am getting live update in the preview while opening in the editor just show a blank image
that sounds abt right
as I don't actually understand transparenty
changing transparent to 255
yup, png previews just don't support transparenty for some reason
if I have an issue rn, it will be how calculate_position, calculates the pos, as it's incorrect
they support transparency. just can't be completely empty. at least one pixel needs to have a alpha between 1 and 255.
0 is not a thing?
if every pixel has an alpha of 0 then there is no image.
right
i think that might be hard-coded somewhere in the preview generator. "if there is no image then display a black area instead."
okay solved
def calculate_position(index: int) -> tuple[int, int]:
width = image.width
row = index // width
col = index % width
return col, row
had to switch col and row
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.