mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-01 00:17:27 +03:00 
			
		
		
		
	Flatten sampleformat to initial value, fixes #1466
This commit is contained in:
		
							parent
							
								
									fbfa292204
								
							
						
					
					
						commit
						93e688cc2b
					
				|  | @ -180,8 +180,6 @@ OPEN_INFO = { | |||
|     (MM, 2, (1,), 1, (8, 8, 8, 8), (2,)): ("RGBA", "RGBA"), | ||||
|     (II, 2, (1,), 1, (8, 8, 8, 8), (999,)): ("RGBA", "RGBA"),  # Corel Draw 10 | ||||
|     (MM, 2, (1,), 1, (8, 8, 8, 8), (999,)): ("RGBA", "RGBA"),  # Corel Draw 10 | ||||
|     (II, 2, (1, 1, 1, 1), 1, (8, 8, 8, 8), (1,)): ("RGBA", "RGBA"),  # OSX Grab | ||||
|     (MM, 2, (1, 1, 1, 1), 1, (8, 8, 8, 8), (1,)): ("RGBA", "RGBA"),  # OSX Grab | ||||
|     (II, 3, (1,), 1, (1,), ()): ("P", "P;1"), | ||||
|     (MM, 3, (1,), 1, (1,), ()): ("P", "P;1"), | ||||
|     (II, 3, (1,), 2, (1,), ()): ("P", "P;1R"), | ||||
|  | @ -967,6 +965,13 @@ class TiffImageFile(ImageFile.ImageFile): | |||
|             print("- size:", self.size) | ||||
| 
 | ||||
|         format = self.tag_v2.get(SAMPLEFORMAT, (1,)) | ||||
|         if len(format) > 1 and max(format) == min(format) == 1: | ||||
|             # SAMPLEFORMAT is properly per band, so an RGB image will | ||||
|             # be (1,1,1).  But, we don't support per band pixel types, | ||||
|             # and anything more than one band is a uint8. So, just | ||||
|             # take the first element. Revisit this if adding support | ||||
|             # for more exotic images. | ||||
|             format = (1,) | ||||
| 
 | ||||
|         # mode: check photometric interpretation and bits per pixel | ||||
|         key = ( | ||||
|  |  | |||
							
								
								
									
										
											BIN
										
									
								
								Tests/images/copyleft.tiff
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/copyleft.tiff
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							|  | @ -70,6 +70,11 @@ class TestFileTiff(PillowTestCase): | |||
|                 ]) | ||||
|         im.load() | ||||
| 
 | ||||
|     def test_sampleformat(self): | ||||
|         # https://github.com/python-pillow/Pillow/issues/1466 | ||||
|         im = Image.open("Tests/images/copyleft.tiff") | ||||
|         self.assertEqual(im.mode, 'RGB') | ||||
| 
 | ||||
|     def test_xyres_tiff(self): | ||||
|         from PIL.TiffImagePlugin import X_RESOLUTION, Y_RESOLUTION | ||||
|         filename = "Tests/images/pil168.tif" | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user