mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 07:57:27 +03:00 
			
		
		
		
	Corrected error when XMP is tuple
This commit is contained in:
		
							parent
							
								
									5d52ede584
								
							
						
					
					
						commit
						4161bb1645
					
				|  | @ -448,6 +448,15 @@ def test_exif_transpose() -> None: | |||
|     assert 0x0112 not in transposed_im.getexif() | ||||
| 
 | ||||
| 
 | ||||
| def test_exif_transpose_with_xmp_tuple() -> None: | ||||
|     with Image.open("Tests/images/xmp_tags_orientation.png") as im: | ||||
|         assert im.getexif()[0x0112] == 3 | ||||
| 
 | ||||
|         im.info["xmp"] = (b"test",) | ||||
|         transposed_im = ImageOps.exif_transpose(im) | ||||
|         assert 0x0112 not in transposed_im.getexif() | ||||
| 
 | ||||
| 
 | ||||
| def test_exif_transpose_xml_without_xmp() -> None: | ||||
|     with Image.open("Tests/images/xmp_tags_orientation.png") as im: | ||||
|         assert im.getexif()[0x0112] == 3 | ||||
|  |  | |||
|  | @ -729,11 +729,15 @@ def exif_transpose(image: Image.Image, *, in_place: bool = False) -> Image.Image | |||
|                         r"<tiff:Orientation>([0-9])</tiff:Orientation>", | ||||
|                     ): | ||||
|                         value = exif_image.info[key] | ||||
|                         exif_image.info[key] = ( | ||||
|                             re.sub(pattern, "", value) | ||||
|                             if isinstance(value, str) | ||||
|                             else re.sub(pattern.encode(), b"", value) | ||||
|                         ) | ||||
|                         if isinstance(value, str): | ||||
|                             value = re.sub(pattern, "", value) | ||||
|                         elif isinstance(value, tuple): | ||||
|                             value = tuple( | ||||
|                                 re.sub(pattern.encode(), b"", v) for v in value | ||||
|                             ) | ||||
|                         else: | ||||
|                             value = re.sub(pattern.encode(), b"", value) | ||||
|                         exif_image.info[key] = value | ||||
|         if not in_place: | ||||
|             return transposed_image | ||||
|     elif not in_place: | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user