mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	Get IPTC info from tag_v2
This commit is contained in:
		
							parent
							
								
									eeb3d04843
								
							
						
					
					
						commit
						f26b47595b
					
				| 
						 | 
					@ -77,6 +77,16 @@ def test_getiptcinfo_zero_padding() -> None:
 | 
				
			||||||
    assert len(iptc) == 3
 | 
					    assert len(iptc) == 3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def test_getiptcinfo_tiff() -> None:
 | 
				
			||||||
 | 
					    # Arrange
 | 
				
			||||||
 | 
					    with Image.open("Tests/images/hopper.Lab.tif") as im:
 | 
				
			||||||
 | 
					        # Act
 | 
				
			||||||
 | 
					        iptc = IptcImagePlugin.getiptcinfo(im)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Assert
 | 
				
			||||||
 | 
					    assert iptc == {(1, 90): b"\x1b%G", (2, 0): b"\xcf\xc0"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_getiptcinfo_tiff_none() -> None:
 | 
					def test_getiptcinfo_tiff_none() -> None:
 | 
				
			||||||
    # Arrange
 | 
					    # Arrange
 | 
				
			||||||
    with Image.open("Tests/images/hopper.tif") as im:
 | 
					    with Image.open("Tests/images/hopper.tif") as im:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -213,7 +213,7 @@ def getiptcinfo(
 | 
				
			||||||
        # get raw data from the IPTC/NAA tag (PhotoShop tags the data
 | 
					        # get raw data from the IPTC/NAA tag (PhotoShop tags the data
 | 
				
			||||||
        # as 4-byte integers, so we cannot use the get method...)
 | 
					        # as 4-byte integers, so we cannot use the get method...)
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            data = im.tag.tagdata[TiffImagePlugin.IPTC_NAA_CHUNK]
 | 
					            data = im.tag_v2[TiffImagePlugin.IPTC_NAA_CHUNK]
 | 
				
			||||||
        except (AttributeError, KeyError):
 | 
					        except (AttributeError, KeyError):
 | 
				
			||||||
            pass
 | 
					            pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user