mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 16:07:30 +03:00 
			
		
		
		
	The .tar test requires both jpeg & zlib support. If one of the two is unavailable, run the test for the second one. If both are unavailable, skip the test.
		
			
				
	
	
		
			29 lines
		
	
	
		
			758 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			758 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from tester import *
 | |
| 
 | |
| from PIL import Image, TarIO
 | |
| 
 | |
| codecs = dir(Image.core)
 | |
| if "zip_decoder" not in codecs and "jpeg_decoder" not in codecs:
 | |
|     skip("neither jpeg nor zip support not available")
 | |
| 
 | |
| # sample ppm stream
 | |
| tarfile = "Images/lena.tar"
 | |
| 
 | |
| def test_sanity():
 | |
|     if "zip_decoder" in codecs:
 | |
|         tar = TarIO.TarIO(tarfile, 'lena.png')
 | |
|         im = Image.open(tar)
 | |
|         im.load()
 | |
|         assert_equal(im.mode, "RGB")
 | |
|         assert_equal(im.size, (128, 128))
 | |
|         assert_equal(im.format, "PNG")
 | |
| 
 | |
|     if "jpeg_decoder" in codecs:
 | |
|         tar = TarIO.TarIO(tarfile, 'lena.jpg')
 | |
|         im = Image.open(tar)
 | |
|         im.load()
 | |
|         assert_equal(im.mode, "RGB")
 | |
|         assert_equal(im.size, (128, 128))
 | |
|         assert_equal(im.format, "JPEG")
 | |
| 
 |