Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed Image.open formats parameter to be case-insensitive #5250

Merged
merged 4 commits into from Feb 8, 2021

Conversation

Piolie
Copy link
Contributor

@Piolie Piolie commented Feb 5, 2021

Changes proposed in this pull request:

  • Make formats parameter in Image.open accept aNy cAsE.

Before this commit

Image.open("Tests/images/hopper.png", formats=['png'])

would fail, because the format is not upper case ('PNG'). This PR makes 'PNG', 'Png', 'pNG' and all other variants equivalent in the formats list (or tuple).

@radarhere radarhere changed the title Make formats parameter in Image.open accept aNy cAsE Make formats parameter in Image.open accept any case Feb 5, 2021
Tests/test_image.py Outdated Show resolved Hide resolved
Piolie and others added 2 commits February 5, 2021 12:21
Keep the original test cases; add the most likely non-uppercase versions.

Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
Moved case transformation before initialization check
@radarhere radarhere changed the title Make formats parameter in Image.open accept any case Changed Image.open formats parameter to be case-insensitive Feb 8, 2021
@radarhere radarhere merged commit bc0c0cb into python-pillow:master Feb 8, 2021
@Piolie Piolie deleted the open_formats_case branch February 9, 2021 01:32
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.

None yet

2 participants