mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
Use snake case
This commit is contained in:
parent
f338f35657
commit
7d97fa8b86
|
@ -404,13 +404,13 @@ def test_exif_transpose():
|
||||||
assert 0x0112 not in transposed_im.getexif()
|
assert 0x0112 not in transposed_im.getexif()
|
||||||
|
|
||||||
|
|
||||||
def test_exif_transpose_inplace():
|
def test_exif_transpose_in_place():
|
||||||
with Image.open("Tests/images/orientation_rectangle.jpg") as im:
|
with Image.open("Tests/images/orientation_rectangle.jpg") as im:
|
||||||
assert im.size == (2, 1)
|
assert im.size == (2, 1)
|
||||||
assert im.getexif()[0x0112] == 8
|
assert im.getexif()[0x0112] == 8
|
||||||
expected = im.rotate(90, expand=True)
|
expected = im.rotate(90, expand=True)
|
||||||
|
|
||||||
ImageOps.exif_transpose(im, inPlace=True)
|
ImageOps.exif_transpose(im, in_place=True)
|
||||||
assert im.size == (1, 2)
|
assert im.size == (1, 2)
|
||||||
assert 0x0112 not in im.getexif()
|
assert 0x0112 not in im.getexif()
|
||||||
assert_image_equal(im, expected)
|
assert_image_equal(im, expected)
|
||||||
|
|
|
@ -576,13 +576,13 @@ def solarize(image, threshold=128):
|
||||||
return _lut(image, lut)
|
return _lut(image, lut)
|
||||||
|
|
||||||
|
|
||||||
def exif_transpose(image, *, inPlace=False):
|
def exif_transpose(image, *, in_place=False):
|
||||||
"""
|
"""
|
||||||
If an image has an EXIF Orientation tag, other than 1, transpose the image
|
If an image has an EXIF Orientation tag, other than 1, transpose the image
|
||||||
accordingly, and remove the orientation data.
|
accordingly, and remove the orientation data.
|
||||||
|
|
||||||
:param image: The image to transpose.
|
:param image: The image to transpose.
|
||||||
:param inPlace: Boolean. Keyword-only argument.
|
:param in_place: Boolean. Keyword-only argument.
|
||||||
If ``True``, the original image is modified in-place, and ``None`` is returned.
|
If ``True``, the original image is modified in-place, and ``None`` is returned.
|
||||||
If ``False`` (default), a new :py:class:`~PIL.Image.Image` object is returned
|
If ``False`` (default), a new :py:class:`~PIL.Image.Image` object is returned
|
||||||
with the transposition applied. If there is no transposition, a copy of the
|
with the transposition applied. If there is no transposition, a copy of the
|
||||||
|
@ -601,11 +601,11 @@ def exif_transpose(image, *, inPlace=False):
|
||||||
}.get(orientation)
|
}.get(orientation)
|
||||||
if method is not None:
|
if method is not None:
|
||||||
transposed_image = image.transpose(method)
|
transposed_image = image.transpose(method)
|
||||||
if inPlace:
|
if in_place:
|
||||||
image.im = transposed_image.im
|
image.im = transposed_image.im
|
||||||
image.pyaccess = None
|
image.pyaccess = None
|
||||||
image._size = transposed_image._size
|
image._size = transposed_image._size
|
||||||
exif_image = image if inPlace else transposed_image
|
exif_image = image if in_place else transposed_image
|
||||||
|
|
||||||
exif = exif_image.getexif()
|
exif = exif_image.getexif()
|
||||||
if ExifTags.Base.Orientation in exif:
|
if ExifTags.Base.Orientation in exif:
|
||||||
|
@ -622,7 +622,7 @@ def exif_transpose(image, *, inPlace=False):
|
||||||
exif_image.info["XML:com.adobe.xmp"] = re.sub(
|
exif_image.info["XML:com.adobe.xmp"] = re.sub(
|
||||||
pattern, "", exif_image.info["XML:com.adobe.xmp"]
|
pattern, "", exif_image.info["XML:com.adobe.xmp"]
|
||||||
)
|
)
|
||||||
if not inPlace:
|
if not in_place:
|
||||||
return transposed_image
|
return transposed_image
|
||||||
elif not inPlace:
|
elif not in_place:
|
||||||
return image.copy()
|
return image.copy()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user