Skip to content

Automatic scaling of Image.MAXBLOCK #148

@acdha

Description

@acdha

There's a venerable old PIL bug which caused Image.save(optimize=True) to fail with JPEGs when the file size is over a certain threshold. The earliest reference I could find dates back to 1999:

http://mail.python.org/pipermail/image-sig/1999-December/000942.html

The workaround commonly used is to either hardcode something like this:

ImageFile.MAXBLOCK = <empirically determined constant (i.e. wild guess)>

or the more dynamic approach used in e.g. matthewwithanm/django-imagekit#50:

ImageFile.MAXBLOCK = max(img.size) ** 2

This seems like exactly the kind of thing Pillow could just fix once and for all.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions