Skip to content

Handle PCX images with an odd stride#5214

Merged
hugovk merged 1 commit intopython-pillow:masterfrom
radarhere:pcx
Mar 7, 2021
Merged

Handle PCX images with an odd stride#5214
hugovk merged 1 commit intopython-pillow:masterfrom
radarhere:pcx

Conversation

@radarhere
Copy link
Copy Markdown
Member

Resolves #5203

The PCX specification states that 'BytesPerLine' 'MUST be an EVEN number.'
The two images that are failing in the issue list the BytesPerLine as 371 and 409. So they are malformed.

This may not be uncommon, since it has been noted in an earlier issue

Unfortunately, both Gimp and ImageMagick both write images with odd strides

The images started to fail after #5174 (ping @wiredfool) abandoned the image's reported stride in favour of calculating it ourselves. This PR relaxes that slightly, by allowing the reported stride to tell us whether this is a well-formed image with an even stride, or a malformed image with an odd stride.

If the thinking is that we should just reject the malformed images, then this can be closed.

@hugovk hugovk merged commit f9b830f into python-pillow:master Mar 7, 2021
@radarhere radarhere deleted the pcx branch March 7, 2021 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some PCX files trigger OSError since 8.1.0

2 participants