mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	Merge pull request #1152 from hugovk/1104
Fix: Cannot identify EPS images
This commit is contained in:
		
						commit
						0925c4adbb
					
				| 
						 | 
				
			
			@ -275,13 +275,13 @@ class EpsImageFile(ImageFile.ImageFile):
 | 
			
		|||
 | 
			
		||||
            s = fp.readline().strip('\r\n')
 | 
			
		||||
 | 
			
		||||
            if s[0] != "%":
 | 
			
		||||
            if s[:1] != "%":
 | 
			
		||||
                break
 | 
			
		||||
 | 
			
		||||
        #
 | 
			
		||||
        # Scan for an "ImageData" descriptor
 | 
			
		||||
 | 
			
		||||
        while s[0] == "%":
 | 
			
		||||
        while s[:1] == "%":
 | 
			
		||||
 | 
			
		||||
            if len(s) > 255:
 | 
			
		||||
                raise SyntaxError("not an EPS file")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										
											BIN
										
									
								
								Tests/images/illu10_no_preview.eps
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/illu10_no_preview.eps
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Tests/images/illu10_preview.eps
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/illu10_preview.eps
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Tests/images/illuCS6_no_preview.eps
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/illuCS6_no_preview.eps
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Tests/images/illuCS6_preview.eps
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/illuCS6_preview.eps
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -223,6 +223,21 @@ class TestFileEps(PillowTestCase):
 | 
			
		|||
 | 
			
		||||
            self._test_readline_file_psfile(s, ending)
 | 
			
		||||
 | 
			
		||||
    def test_open_eps(self):
 | 
			
		||||
        # https://github.com/python-pillow/Pillow/issues/1104
 | 
			
		||||
        # Arrange
 | 
			
		||||
        FILES = ["Tests/images/illu10_no_preview.eps",
 | 
			
		||||
                 "Tests/images/illu10_preview.eps",
 | 
			
		||||
                 "Tests/images/illuCS6_no_preview.eps",
 | 
			
		||||
                 "Tests/images/illuCS6_preview.eps"]
 | 
			
		||||
 | 
			
		||||
        # Act
 | 
			
		||||
        for filename in FILES:
 | 
			
		||||
            img = Image.open(filename)
 | 
			
		||||
 | 
			
		||||
        # Assert
 | 
			
		||||
        self.assertEqual(img.mode, "RGB")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    unittest.main()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user