-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Wrong file format for the tmp file #7510
Comments
Hi. https://pillow.readthedocs.io/en/stable/reference/ImageShow.html states that
The fact that the PNG format is used is intended as a feature, not a bug. Pillow supports some obscure formats, and not all applications support opening them. For example, on my Mac, Preview can't display MIC files, but it can display PNG files. By standardising the format, the support becomes better. 'But wait', you say, 'JPEG isn't obscure!' - true, but JPEG is a lossy format. This means that when an image is saved, it doesn't come out exactly the same. PNG, however, is lossless, meaning it does. https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.show says
If I'm debugging an image, I want the saved file to be exactly the same, not slightly different. As to why If we can find a viewer that is supported on your machine, and you do want to resave the image as a JPEG file before showing it, then you can change the ImageShow format with something like from PIL import Image, ImageShow
im = Image.open("Tests/images/hopper.jpg")
viewer = ImageShow.MacViewer()
del viewer.options["save_all"]
viewer.format = "JPEG"
viewer.show(im) |
Hmm u are right. In this image I marked 3 things, can u take a look? Do u have any idea how to fix it? |
Here is the code that Pillow is using to detect a program it can open images with. Lines 289 to 299 in c9f7a82
If Sorry, when I mentioned detecting from PIL import ImageShow
print(ImageShow.show(i)) |
Is there a way to point Python / PIL to the xdg-open? |
If you believe that from PIL import ImageShow
viewer = ImageShow.XDGViewer()
viewer.show(i) |
Alternatively, you could run from PIL import ImageShow
del ImageShow.UnixViewer.options["save_all"]
img.show() |
Cool that works! Thank you! del ImageShow.UnixViewer.options["save_all"] |
#6611 changed ImageShow so that if you are showing an animated image, all frames are visible. However, this has also had the effect of changing all still images from PNGs to APNGs - and you have said that gwenview does not support APNGs. So the code that I gave you stops ImageShow from saving animated images. I've created #7522 as a long-term solution, to save still images not as APNGs, but as PNGs instead. |
Hi everyone. I found a weird bug. When I try to use "show()" method to display images (that was opened with Image.open) it do not work. I found the problem (but not solution). When the "show()" actually do not open the image it self but rather creates a tmp file and opens it, but the tmp file is created with wrong format / extension (i.e image format is JPEG, but created tmp file is PNG)
what is also weird when I use the "format" function to check if the object has right format it displays right format (JPEG). Nevertheless the tmp file has PNG format.
PS. When I change the tmp file to the right format (via desktop env) then I can normally open the image via Desktop env. Also I can open the png files normally via desktop env but not the ones created by the "show()" function.
And I did tried to manually set the right format for the image but didn't work (which is not surprising because the "format" function shows the right format)
What did you do?
Tried to open images using "show()" function
What did you expect to happen?
I expected that the images will be displayed using default image viewer.
What actually happened?
The image was not displayed.
What are your OS, Python and Pillow versions?
*Default image viewer: gwenview version: 23.08.2-1
CODE that I used
IMAGES (actual img, tmp img and visual presentation that tmp files are created with different format)
The opened image: (JPEG)
The tmp image what is created when execute the code: (PNG)
The visual view of tmp folder vs images folder
The text was updated successfully, but these errors were encountered: