mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 16:07:30 +03:00 
			
		
		
		
	
		
			
				
	
	
		
			30 lines
		
	
	
		
			704 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			704 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from tester import *
 | |
| 
 | |
| from PIL import Image
 | |
| 
 | |
| codecs = dir(Image.core)
 | |
| 
 | |
| if "gif_encoder" not in codecs or "gif_decoder" not in codecs:
 | |
|     skip("gif support not available") # can this happen?
 | |
| 
 | |
| # sample gif stream
 | |
| file = "Images/lena.gif"
 | |
| with open(file, "rb") as f:
 | |
|     data = f.read()
 | |
| 
 | |
| def test_sanity():
 | |
|     im = Image.open(file)
 | |
|     im.load()
 | |
|     assert_equal(im.mode, "P")
 | |
|     assert_equal(im.size, (128, 128))
 | |
|     assert_equal(im.format, "GIF")
 | |
| 
 | |
| def test_optimize():
 | |
|     def test(optimize):
 | |
|         im = Image.new("L", (1, 1), 0)
 | |
|         file = BytesIO()
 | |
|         im.save(file, "GIF", optimize=optimize)
 | |
|         return len(file.getvalue())
 | |
|     assert_equal(test(0), 800)
 | |
|     assert_equal(test(1), 38)
 |