mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	Merge pull request #2139 from SemanticsOS/lambdafu/multipage-tiff-palette
Force reloading palette when using mmap in ImageFile.
This commit is contained in:
		
						commit
						0902120f09
					
				| 
						 | 
				
			
			@ -170,6 +170,9 @@ class ImageFile(Image.Image):
 | 
			
		|||
                            self.map, self.size, d, e, o, a
 | 
			
		||||
                            )
 | 
			
		||||
                    readonly = 1
 | 
			
		||||
                    # After trashing self.im, we might need to reload the palette data.
 | 
			
		||||
                    if self.palette:
 | 
			
		||||
                        self.palette.dirty = 1
 | 
			
		||||
                except (AttributeError, EnvironmentError, ImportError):
 | 
			
		||||
                    self.map = None
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										
											BIN
										
									
								
								Tests/images/multipage-mmap.tiff
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/multipage-mmap.tiff
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -63,5 +63,14 @@ class TestImageSequence(PillowTestCase):
 | 
			
		|||
            self.assert_image_equal(frame, firstFrame)
 | 
			
		||||
            break
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    def test_palette_mmap(self):
 | 
			
		||||
        # Using mmap in ImageFile can require to reload the palette.
 | 
			
		||||
        im = Image.open('Tests/images/multipage-mmap.tiff')
 | 
			
		||||
        color1 = im.getpalette()[0:3]
 | 
			
		||||
        im.seek(0)
 | 
			
		||||
        color2 = im.getpalette()[0:3]
 | 
			
		||||
        self.assertEqual(color1, color2)
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    unittest.main()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user