python-pillow / Pillow

Python Imaging Library (Fork)
https://python-pillow.org
Other
12.32k stars 2.23k forks source link

Do not create new image when exif_transpose() is used in place #8555

Open radarhere opened 6 days ago

radarhere commented 6 days ago

im.transpose() loads the image, calls the core transpose() method and returns a new image instance. https://github.com/python-pillow/Pillow/blob/5bff2f3b2894ec6923c590d0c37b18177d0634bd/src/PIL/Image.py#L2982-L2994

When im.transpose() is called from ImageOps.exif_transpose(), if it is in_place, then the image is already loaded, and the new image instance is quickly abandoned. https://github.com/python-pillow/Pillow/blob/5bff2f3b2894ec6923c590d0c37b18177d0634bd/src/PIL/ImageOps.py#L701-L705

So this can be simplified to just calling the core transpose() method directly.