-
-
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)
![img1](https://private-user-images.githubusercontent.com/72615211/279451920-286878c5-ceb0-4fe6-a185-22b46416dc0f.jpeg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU1MzI2MjYsIm5iZiI6MTcyNTUzMjMyNiwicGF0aCI6Ii83MjYxNTIxMS8yNzk0NTE5MjAtMjg2ODc4YzUtY2ViMC00ZmU2LWExODUtMjJiNDY0MTZkYzBmLmpwZWc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTA1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkwNVQxMDMyMDZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mY2MwYzIwYWIyOTgzNGZlYzE1NTIxYTBhNDdlMmUxYTdhOWUwZGRiY2Q4YWVhZDFmOTBhOGQxZTE1N2I2MThkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.FVSFiqz54PNU_YLP9rwUPCJc3ztCQby_0SHLdDlt1FY)
The opened image: (JPEG)
The tmp image what is created when execute the code: (PNG)
![tmp0cclb1xd](https://private-user-images.githubusercontent.com/72615211/279452147-ad141dc2-d3ce-44ad-889f-380b2b4da0bb.PNG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU1MzI2MjYsIm5iZiI6MTcyNTUzMjMyNiwicGF0aCI6Ii83MjYxNTIxMS8yNzk0NTIxNDctYWQxNDFkYzItZDNjZS00NGFkLTg4OWYtMzgwYjJiNGRhMGJiLlBORz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA1VDEwMzIwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWIyY2Q4NGU3NDE0ZDYxOWNjMzA0MjE4YjAzMGY5OTVmYmQ0NjZmYzlhMjg3MjFhY2VjYWUzNGM5NDM2YWVmZmMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.WUvd614AfRsSQXqAipwmEFzA1_91mi4VJzh_3m3X52Y)
The visual view of tmp folder vs images folder
![dir-comapre](https://private-user-images.githubusercontent.com/72615211/279455610-018edf13-ed2d-46a2-8338-b2212d165788.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU1MzI2MjYsIm5iZiI6MTcyNTUzMjMyNiwicGF0aCI6Ii83MjYxNTIxMS8yNzk0NTU2MTAtMDE4ZWRmMTMtZWQyZC00NmEyLTgzMzgtYjIyMTJkMTY1Nzg4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA1VDEwMzIwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM1MmI1MGRjZmVkZDE3ZmNiMjcwMWMyYjI1N2UwODY1ZWJkMGZmYjRjMTQyOGZkNDhkZTlmZTA2ZWI0ZDQ3MzImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.3yvSZcJ8FiDur4ZYx06vkqmtiX0sV_BZ9HwPVpTh92w)
The text was updated successfully, but these errors were encountered: