Skip to content

wl-paste with image copied from browser results in ImageGrab.grabclipboard error  #7093

@rrcgat

Description

@rrcgat

What did you do?

When source application offered multiple MIME type, wl-paste without -t mime/type maybe result in other MEME type instead of image. ImageGrab.grabclipboard use only wl-paste without arguments, which reports error whenever calling it with multiple MEME type. For example, open some website with images, copy the image, it will offer multiple MIME type.

What did you expect to happen?

No error reports.

What actually happened?

Error reports like this:

Traceback (most recent call last):
  File "/home/user/workspace/grab.py", line 9, in <module>
    main()
  File "/home/user/workspace/grab.py", line 5, in main
    ImageGrab.grabclipboard()
  File "/home/user/.local/lib/python3.10/site-packages/PIL/ImageGrab.py", line 146, in grabclipboard
    im = Image.open(filepath)
  File "/home/user/.local/lib/python3.10/site-packages/PIL/Image.py", line 3298, in open
    raise UnidentifiedImageError(msg)
PIL.UnidentifiedImageError: cannot identify image file '/tmp/tmpvi9tcfs3'

What are your OS, Python and Pillow versions?

  • OS: Arch Linux
  • Python: CPython 3.10.10
  • Pillow: 9.5.0
from PIL import ImageGrab


def main():
    ImageGrab.grabclipboard()


if __name__ == "__main__":
    main()

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