Pillow & Tkinter doesn't show PNGs with transparency2019 Community Moderator ElectionCapture HTML Canvas as gif/jpg/png/pdf?favicon.png vs favicon.ico - why should I use PNG instead of ICO?How to convert a PNG image to a SVG?Replace transparency in PNG images with white backgroundWhat are the different usecases of PNG vs. GIF vs. JPEG vs. SVG?Change color of PNG image via CSS?How to convert a SVG to a PNG with Image Magick?Stacking Transparent GIF with Pillow Errors [Fixed!]How to put a Tkinter Image into background? keep getting same error msg no matter the file type:Python 3.7, tkinter, jpg: couldn't recognize data in image file
Instead of Universal Basic Income, why not Universal Basic NEEDS?
Why does Deadpool say "You're welcome, Canada," after shooting Ryan Reynolds in the end credits?
How could a female member of a species produce eggs unto death?
Brexit - No Deal Rejection
Could the Saturn V actually have launched astronauts around Venus?
SQL Server Primary Login Restrictions
Why do passenger jet manufacturers design their planes with stall prevention systems?
Bash: What does "masking return values" mean?
Provisioning profile doesn't include the application-identifier and keychain-access-groups entitlements
Old race car problem/puzzle
Did CPM support custom hardware using device drivers?
Can the damage from a Talisman of Pure Good (or Ultimate Evil) be non-lethal?
Have researchers managed to "reverse time"? If so, what does that mean for physics?
Good allowance savings plan?
Why did it take so long to abandon sail after steamships were demonstrated?
Humanity loses the vast majority of its technology, information, and population in the year 2122. How long does it take to rebuild itself?
Should we release the security issues we found in our product as CVE or we can just update those on weekly release notes?
Employee lack of ownership
Sword in the Stone story where the sword was held in place by electromagnets
How to answer questions about my characters?
Happy pi day, everyone!
Life insurance that covers only simultaneous/dual deaths
How to simplify this time periods definition interface?
Do I need life insurance if I can cover my own funeral costs?
Pillow & Tkinter doesn't show PNGs with transparency
2019 Community Moderator ElectionCapture HTML Canvas as gif/jpg/png/pdf?favicon.png vs favicon.ico - why should I use PNG instead of ICO?How to convert a PNG image to a SVG?Replace transparency in PNG images with white backgroundWhat are the different usecases of PNG vs. GIF vs. JPEG vs. SVG?Change color of PNG image via CSS?How to convert a SVG to a PNG with Image Magick?Stacking Transparent GIF with Pillow Errors [Fixed!]How to put a Tkinter Image into background? keep getting same error msg no matter the file type:Python 3.7, tkinter, jpg: couldn't recognize data in image file
My application was recently working fine, but when I upgraded Python to v3.7.2, which solved another problem I was having, the images are either no longer shown or of poor quality.
After doing some testing, I've concluded that I can display any PNG without transparency, but PNGs with transparency exhibit this problem. I can recreate it with this code:
import tkinter as tk
from PIL import Image, ImageTk
root = tk.Tk()
path = 'png-transparent.png'
img = Image.open(path)
imgtk = ImageTk.PhotoImage(img)
panel = tk.Label(root, image=imgtk).pack()
root.mainloop()
If I use a label to display the image, it doesn't show at all. If I use a button to display the image, which is what I really need to do, it is poor quality (which means not displaying properly, no definition, coarse edges).
They are very small (16x16), but you can see two different icons here, the ones in the boxes are the distorted ones and the ones not in boxes are how they are supposed to look.
Current versions: Python 3.7.2, Pillow 5.4.1, OS X 10.13.6
python-3.x macos tkinter png python-imaging-library
|
show 2 more comments
My application was recently working fine, but when I upgraded Python to v3.7.2, which solved another problem I was having, the images are either no longer shown or of poor quality.
After doing some testing, I've concluded that I can display any PNG without transparency, but PNGs with transparency exhibit this problem. I can recreate it with this code:
import tkinter as tk
from PIL import Image, ImageTk
root = tk.Tk()
path = 'png-transparent.png'
img = Image.open(path)
imgtk = ImageTk.PhotoImage(img)
panel = tk.Label(root, image=imgtk).pack()
root.mainloop()
If I use a label to display the image, it doesn't show at all. If I use a button to display the image, which is what I really need to do, it is poor quality (which means not displaying properly, no definition, coarse edges).
They are very small (16x16), but you can see two different icons here, the ones in the boxes are the distorted ones and the ones not in boxes are how they are supposed to look.
Current versions: Python 3.7.2, Pillow 5.4.1, OS X 10.13.6
python-3.x macos tkinter png python-imaging-library
Please upload and add a link to the image to your question. Also note that the value assigned topanel
will beNone
because thepack()
method doesn't return a value.
– martineau
Mar 6 at 18:50
Edited the post to add an image.
– Ste Bunting
Mar 6 at 19:09
Hmm, are you sure that image has some transparent areas because it doesn't look like it does in my image editor (Photoshop)—it appears to be a 24-bit RGB image (i.e. has 3 x 8-bit channels) as opposed to a 4-channel RGBA image (one that also has an "alpha" channel).
– martineau
Mar 6 at 19:23
Edited to show original un-edited correct images. The distorted buttons are screenshots.
– Ste Bunting
Mar 6 at 19:32
1
Both of those two original images seem to work properly for me. I'm using Python 3.7.2, Pillow 5.4.1, on Windows 7 Pro. Seems like I've seen numerous questions here about difficulties using Python on Macos (because the OS comes with some version of it), so perhaps the upgrade you did messed-up your custom Python installation.
– martineau
Mar 6 at 19:52
|
show 2 more comments
My application was recently working fine, but when I upgraded Python to v3.7.2, which solved another problem I was having, the images are either no longer shown or of poor quality.
After doing some testing, I've concluded that I can display any PNG without transparency, but PNGs with transparency exhibit this problem. I can recreate it with this code:
import tkinter as tk
from PIL import Image, ImageTk
root = tk.Tk()
path = 'png-transparent.png'
img = Image.open(path)
imgtk = ImageTk.PhotoImage(img)
panel = tk.Label(root, image=imgtk).pack()
root.mainloop()
If I use a label to display the image, it doesn't show at all. If I use a button to display the image, which is what I really need to do, it is poor quality (which means not displaying properly, no definition, coarse edges).
They are very small (16x16), but you can see two different icons here, the ones in the boxes are the distorted ones and the ones not in boxes are how they are supposed to look.
Current versions: Python 3.7.2, Pillow 5.4.1, OS X 10.13.6
python-3.x macos tkinter png python-imaging-library
My application was recently working fine, but when I upgraded Python to v3.7.2, which solved another problem I was having, the images are either no longer shown or of poor quality.
After doing some testing, I've concluded that I can display any PNG without transparency, but PNGs with transparency exhibit this problem. I can recreate it with this code:
import tkinter as tk
from PIL import Image, ImageTk
root = tk.Tk()
path = 'png-transparent.png'
img = Image.open(path)
imgtk = ImageTk.PhotoImage(img)
panel = tk.Label(root, image=imgtk).pack()
root.mainloop()
If I use a label to display the image, it doesn't show at all. If I use a button to display the image, which is what I really need to do, it is poor quality (which means not displaying properly, no definition, coarse edges).
They are very small (16x16), but you can see two different icons here, the ones in the boxes are the distorted ones and the ones not in boxes are how they are supposed to look.
Current versions: Python 3.7.2, Pillow 5.4.1, OS X 10.13.6
python-3.x macos tkinter png python-imaging-library
python-3.x macos tkinter png python-imaging-library
edited Mar 6 at 19:30
Ste Bunting
asked Mar 6 at 18:35
Ste BuntingSte Bunting
14119
14119
Please upload and add a link to the image to your question. Also note that the value assigned topanel
will beNone
because thepack()
method doesn't return a value.
– martineau
Mar 6 at 18:50
Edited the post to add an image.
– Ste Bunting
Mar 6 at 19:09
Hmm, are you sure that image has some transparent areas because it doesn't look like it does in my image editor (Photoshop)—it appears to be a 24-bit RGB image (i.e. has 3 x 8-bit channels) as opposed to a 4-channel RGBA image (one that also has an "alpha" channel).
– martineau
Mar 6 at 19:23
Edited to show original un-edited correct images. The distorted buttons are screenshots.
– Ste Bunting
Mar 6 at 19:32
1
Both of those two original images seem to work properly for me. I'm using Python 3.7.2, Pillow 5.4.1, on Windows 7 Pro. Seems like I've seen numerous questions here about difficulties using Python on Macos (because the OS comes with some version of it), so perhaps the upgrade you did messed-up your custom Python installation.
– martineau
Mar 6 at 19:52
|
show 2 more comments
Please upload and add a link to the image to your question. Also note that the value assigned topanel
will beNone
because thepack()
method doesn't return a value.
– martineau
Mar 6 at 18:50
Edited the post to add an image.
– Ste Bunting
Mar 6 at 19:09
Hmm, are you sure that image has some transparent areas because it doesn't look like it does in my image editor (Photoshop)—it appears to be a 24-bit RGB image (i.e. has 3 x 8-bit channels) as opposed to a 4-channel RGBA image (one that also has an "alpha" channel).
– martineau
Mar 6 at 19:23
Edited to show original un-edited correct images. The distorted buttons are screenshots.
– Ste Bunting
Mar 6 at 19:32
1
Both of those two original images seem to work properly for me. I'm using Python 3.7.2, Pillow 5.4.1, on Windows 7 Pro. Seems like I've seen numerous questions here about difficulties using Python on Macos (because the OS comes with some version of it), so perhaps the upgrade you did messed-up your custom Python installation.
– martineau
Mar 6 at 19:52
Please upload and add a link to the image to your question. Also note that the value assigned to
panel
will be None
because the pack()
method doesn't return a value.– martineau
Mar 6 at 18:50
Please upload and add a link to the image to your question. Also note that the value assigned to
panel
will be None
because the pack()
method doesn't return a value.– martineau
Mar 6 at 18:50
Edited the post to add an image.
– Ste Bunting
Mar 6 at 19:09
Edited the post to add an image.
– Ste Bunting
Mar 6 at 19:09
Hmm, are you sure that image has some transparent areas because it doesn't look like it does in my image editor (Photoshop)—it appears to be a 24-bit RGB image (i.e. has 3 x 8-bit channels) as opposed to a 4-channel RGBA image (one that also has an "alpha" channel).
– martineau
Mar 6 at 19:23
Hmm, are you sure that image has some transparent areas because it doesn't look like it does in my image editor (Photoshop)—it appears to be a 24-bit RGB image (i.e. has 3 x 8-bit channels) as opposed to a 4-channel RGBA image (one that also has an "alpha" channel).
– martineau
Mar 6 at 19:23
Edited to show original un-edited correct images. The distorted buttons are screenshots.
– Ste Bunting
Mar 6 at 19:32
Edited to show original un-edited correct images. The distorted buttons are screenshots.
– Ste Bunting
Mar 6 at 19:32
1
1
Both of those two original images seem to work properly for me. I'm using Python 3.7.2, Pillow 5.4.1, on Windows 7 Pro. Seems like I've seen numerous questions here about difficulties using Python on Macos (because the OS comes with some version of it), so perhaps the upgrade you did messed-up your custom Python installation.
– martineau
Mar 6 at 19:52
Both of those two original images seem to work properly for me. I'm using Python 3.7.2, Pillow 5.4.1, on Windows 7 Pro. Seems like I've seen numerous questions here about difficulties using Python on Macos (because the OS comes with some version of it), so perhaps the upgrade you did messed-up your custom Python installation.
– martineau
Mar 6 at 19:52
|
show 2 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55030015%2fpillow-tkinter-doesnt-show-pngs-with-transparency%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55030015%2fpillow-tkinter-doesnt-show-pngs-with-transparency%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please upload and add a link to the image to your question. Also note that the value assigned to
panel
will beNone
because thepack()
method doesn't return a value.– martineau
Mar 6 at 18:50
Edited the post to add an image.
– Ste Bunting
Mar 6 at 19:09
Hmm, are you sure that image has some transparent areas because it doesn't look like it does in my image editor (Photoshop)—it appears to be a 24-bit RGB image (i.e. has 3 x 8-bit channels) as opposed to a 4-channel RGBA image (one that also has an "alpha" channel).
– martineau
Mar 6 at 19:23
Edited to show original un-edited correct images. The distorted buttons are screenshots.
– Ste Bunting
Mar 6 at 19:32
1
Both of those two original images seem to work properly for me. I'm using Python 3.7.2, Pillow 5.4.1, on Windows 7 Pro. Seems like I've seen numerous questions here about difficulties using Python on Macos (because the OS comes with some version of it), so perhaps the upgrade you did messed-up your custom Python installation.
– martineau
Mar 6 at 19:52