upload: Add test jpg image with no exif data.

This commit is contained in:
Shubham Padia 2018-05-31 16:55:55 +05:30 committed by Tim Abbott
parent a2c9517f8d
commit cd1233d3f7
3 changed files with 7 additions and 1 deletions

View File

@ -88,7 +88,7 @@ def exif_rotate(image: Image) -> Image:
if not hasattr(image, '_getexif'):
return image
exif_data = image._getexif()
if exif_data is None: # nocoverage # don't have a test image for this case, but it happens
if exif_data is None:
return image
exif_dict = dict(exif_data.items())

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -1317,6 +1317,12 @@ class ExifRotateTests(TestCase):
result = exif_rotate(img)
self.assertEqual(result, img)
# Image with no exif data.
img_data = get_test_image_file('img_no_exif.jpg').read()
img = Image.open(io.BytesIO(img_data))
result = exif_rotate(img)
self.assertEqual(result, img)
# Orientation of the image is 1.
img_data = get_test_image_file('img.jpg').read()
img = Image.open(io.BytesIO(img_data))