Skip to content

can't save screen: PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x04031C58> #17

Open

Description

@isarafx

ภาพ
whenever i try to save a screenshot it raise pillow unidentify io_byte(as show in the picture)
I already try to reinstall pillow and set DISPLAY_DATA_BYTES to 1152000 but still didn't work

Activity

  1. B-G-T commented on Nov 1, 2020

    @B-G-T

    The issue seems that in case of 800x480 scopes the PNG file is truncated even if you set DISPLAY_DATA_BYTES to 1152000 (= 800x480x3).
    Adding
    from PIL import ImageFile
    ImageFile.LOAD_TRUNCATED_IMAGES = True
    after the block with
    from PIL import Image, ImageOps, ImageEnhance
    in cli.py seems to solve it as a workaround but the real issue is obviously somewhere else and needs to be fixed there.

  2. added a commit that references this issue on Apr 24, 2023
    ddcc4b2
  3. ornea commented on Apr 12, 2026

    @ornea

    I have similar issues using ds1054z scope ver 00.04.03.SP2

    from PIL import ImageTk, Image
    ...
    img_data = self.scope.display_data

    img = Image.open(io.BytesIO(img_data)) <- this fails as does saving the file first then trying to

    img = Image.open(filename)

    The workarounds above from B-G-T did not work for me but if I change the following line in init ~line no 627

    self.write(":DISPlay:DATA? ON,OFF,PNG") to self.write(":DISPlay:DATA? ON,OFF,JPEG")

    it fixes my issues

    i can see in history that it was once

    self.write(":DISPlay:DATA? ON,OFF,BMP24")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions