Skip to content

Handle PNG cause exception: OSError: Truncated File Read #6118

@dxsooo

Description

@dxsooo

What did you do?

Open an image and get its width

What did you expect to happen?

width printed

What actually happened?

come into exception:
OSError: Truncated File Read
in convert

What are your OS, Python and Pillow versions?

  • OS: archlinux(5.16.12-arch1-1)
  • Python: 3.10
  • Pillow: 9.0.1
from PIL import Image
fn = '142fc7b8018343d43101dae4900c99a4c0de558e33f6da2d029320633aa01193'
with Image.open(fn) as fo:
    img = fo.convert('RGB')
    print(img.width)

the image:
142fc7b8018343d43101dae4900c99a4c0de558e33f6da2d029320633aa01193.zip

it can be viewed in Browser and image viewer but failed in pillow.

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