Skip to content

Some PCX files trigger OSError since 8.1.0 #5203

@glx22

Description

@glx22

What did you do?

In OpenTTD/nml we use pillow to manipulate images, mainly cropping, but I also tested with show() and save().

I think it's related to 2f40926

What did you expect to happen?

I expect the images to be loaded as they were with previous (<8.1.0) pillow versions.

What actually happened?

Depending on the used file it fails to load with OSError: buffer overrun when reading image file or OSError: image file is truncated (0 bytes not processed). But not all images fail to load.

What are your OS, Python and Pillow versions?

  • OS: Any (tested on Ubuntu, MacOS and Windows)
  • Python: >3.5 (tested on 3.6, 3.7, 3.8)
  • Pillow: 8.1.0

This is a simple test case with images that used to load fine. One still works, the two others trigger the different OSError

from PIL import Image

files = ["arctic_railwagons.pcx", "opengfx_generic_trams1.pcx", "opengfx_trains_start.pcx"]

for file in files:
    try:
        with Image.open(file) as im:
            print("{}:{} {} {}".format(file,im.format, im.size, im.mode))
            im.save(file + ".png")
    except OSError as e:
        print("Failed with '{}'".format(str(e)))

Images and test code in pillow-test.zip

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