Skip to content

Image.open on Ubuntu 20.04 gives the error "No images found" in the viewer #5945

@abarker

Description

@abarker

The viewer is opened, but a "No images found" error is displayed. Pillow version pillow-9.0.0. This may be the same bug: https://stackoverflow.com/questions/63579415/why-does-pil-fail-to-display-images-with-error-no-images-found-in-file-tmp

Code to reproduce:

from PIL import Image

im = Image.open(r"/var/lib/app-info/icons/ubuntu-focal-updates-universe/48x48/inkscape_inkscape.png")
im.show()

Changing the code in the UnixViewer class in ImageShow.py seems to fix it. I'm not sure why the current code is writing the filename to a file and then reading it back from stdin, using shell=True in Popen. Deleting the rm -f $im" command in the Popen call seems to fix the problem. It also seems to work using cat | xargs -L1 in the Popen command instead of setting the shell variable im.

This simpler code replacement also seems to work, without setting shell=True:

def show_file(self, file, **options):
    """Display given file"""
    command = self.get_command_ex(file, **options)[0]
    subprocess.Popen([command, file])
    return 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions