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

Added in_place argument to ImageOps.exif_transpose() #7092

Merged
merged 7 commits into from
Jun 14, 2023

Conversation

radarhere
Copy link
Member

Resolves #7086

If there is no transposition required, ImageOps.exif_transpose() performs a copy() operation. This is to provide consistency with when there is transposition required and transpose() is called, so that whether or not there is a change made, a new image instance is returned.

#7086 (and effectively #5574 as well) dislike the performance cost of the copy() operation.

This PR introduces a new argument, inPlace, copying the API of ImageCms.applyTransform(). It is False by default, to continue to provide the existing behaviour. If it is True, then the provided image instance is modified, and nothing is returned. This means that copy() does not have to be called, as no changes need to be made to the provided image.

src/PIL/ImageOps.py Outdated Show resolved Hide resolved
@Yay295
Copy link
Contributor

Yay295 commented Apr 15, 2023

Exif tag 0x0112 is ExifTags.Base.Orientation if you want to import that instead of using the number directly.

@radarhere
Copy link
Member Author

Ok, I've pushed a commit for that.

src/PIL/ImageOps.py Outdated Show resolved Hide resolved
src/PIL/ImageOps.py Outdated Show resolved Hide resolved
src/PIL/ImageOps.py Outdated Show resolved Hide resolved
src/PIL/ImageOps.py Outdated Show resolved Hide resolved
Tests/test_imageops.py Outdated Show resolved Hide resolved
Tests/test_imageops.py Outdated Show resolved Hide resolved
@hugovk hugovk changed the title Added inPlace argument to ImageOps.exif_transpose() Added in_place argument to ImageOps.exif_transpose() Jun 14, 2023
@hugovk hugovk added the automerge Automatically merge PRs that are ready label Jun 14, 2023
@mergify mergify bot merged commit 561986e into python-pillow:main Jun 14, 2023
@radarhere radarhere deleted the exif_transpose branch June 14, 2023 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Automatically merge PRs that are ready Exif
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a switch to control whether image.copy() or not in ImageOps.exif_transpose
4 participants