mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 07:57:27 +03:00 
			
		
		
		
	Allow FotoStation tags
This commit is contained in:
		
							parent
							
								
									6bd3ed439a
								
							
						
					
					
						commit
						b37ca350a8
					
				|  | @ -1,5 +1,5 @@ | ||||||
| import sys | import sys | ||||||
| from io import StringIO | from io import BytesIO, StringIO | ||||||
| 
 | 
 | ||||||
| from PIL import Image, IptcImagePlugin | from PIL import Image, IptcImagePlugin | ||||||
| 
 | 
 | ||||||
|  | @ -30,6 +30,23 @@ def test_getiptcinfo_jpg_found(): | ||||||
|     assert iptc[(2, 101)] == b"Hungary" |     assert iptc[(2, 101)] == b"Hungary" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | def test_getiptcinfo_fotostation(): | ||||||
|  |     # Arrange | ||||||
|  |     with open(TEST_FILE, "rb") as fp: | ||||||
|  |         data = bytearray(fp.read()) | ||||||
|  |     data[86] = 240 | ||||||
|  |     f = BytesIO(data) | ||||||
|  |     with Image.open(f) as im: | ||||||
|  |         # Act | ||||||
|  |         iptc = IptcImagePlugin.getiptcinfo(im) | ||||||
|  | 
 | ||||||
|  |     # Assert | ||||||
|  |     for tag in iptc.keys(): | ||||||
|  |         if tag[0] == 240: | ||||||
|  |             return | ||||||
|  |     assert False, "FotoStation tag not found" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def test_getiptcinfo_zero_padding(): | def test_getiptcinfo_zero_padding(): | ||||||
|     # Arrange |     # Arrange | ||||||
|     with Image.open(TEST_FILE) as im: |     with Image.open(TEST_FILE) as im: | ||||||
|  |  | ||||||
|  | @ -64,7 +64,7 @@ class IptcImageFile(ImageFile.ImageFile): | ||||||
|         tag = s[1], s[2] |         tag = s[1], s[2] | ||||||
| 
 | 
 | ||||||
|         # syntax |         # syntax | ||||||
|         if s[0] != 0x1C or tag[0] < 1 or tag[0] > 9: |         if s[0] != 0x1C or tag[0] not in [1, 2, 3, 4, 5, 6, 7, 8, 9, 240]: | ||||||
|             msg = "invalid IPTC/NAA file" |             msg = "invalid IPTC/NAA file" | ||||||
|             raise SyntaxError(msg) |             raise SyntaxError(msg) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user