#πŸ”’ blank png image (PIL)

29 messages Β· Page 1 of 1 (latest)

tall axle
#

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

lethal acornBOT
#

@tall axle

Python help channel opened

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.

spare pendant
#

interesting

tall axle
spare pendant
#

why do you think that the preview is correct?

summer canopy
#

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?

spare pendant
#

all alpha values are 0.

summer canopy
#

okay... that would make it transparent, and the "blank image" would be the expected result, and the previews would be wrong.

spare pendant
#

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.

tall axle
tall axle
#

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

spare pendant
#

they support transparency. just can't be completely empty. at least one pixel needs to have a alpha between 1 and 255.

spare pendant
#

if every pixel has an alpha of 0 then there is no image.

tall axle
#

right

spare pendant
#

i think that might be hard-coded somewhere in the preview generator. "if there is no image then display a black area instead."

tall axle
spare pendant
#

both look fine.

#

:)

#

ΓΌ

tall axle
#

now time to add math πŸ™ƒ

#

!solved ty everyone

lethal acornBOT
#
Python help channel closed

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.