Skip to content

ImageShow.show on a PNG file returned True without displaying the image #9422

@kailizcatman

Description

@kailizcatman

What did you do?

  1. Download this PNG image from Wikipedia. https://en.wikipedia.org/wiki/PNG#/media/File:PNG_transparency_demonstration_1.png Save it as test.png.
  2. Run the test script shown below.
from PIL import Image, ImageShow
img=Image.open("test.png")
print(ImageShow.show(img))

What did you expect to happen?

I expected a new window to be created in which the downloaded image was displayed.

What actually happened?

The command printed "True" on the command line and exited without displaying the image.

I think the cause of the issue is that in my environment, the first viewer tried by pillow was the XDGViewer. Unfortunately, xdg-open was not correctly configured. When I ran xdg-open test.png directly, the command exited with code 4 without displaying anything.

At the moment, XDGViewer.show_file does not check the return code of xdg-open, and always returns 1 after launching the xdg-open subprocess. This caused ImageShow.show to not bother trying the DisplayViewer option.

As far as I can tell, none of the viewers check the return code of the viewer subprocess. Is this a deliberate design decision?

What are your OS, Python and Pillow versions?

  • OS: SLES15
  • Python: 3.10.11
  • Pillow: 11.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions