mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 16:07:30 +03:00 
			
		
		
		
	Merge pull request #3520 from pirate486743186/mime-types
Add missing MIME types and extensions
This commit is contained in:
		
						commit
						de75132a14
					
				
							
								
								
									
										
											BIN
										
									
								
								Tests/images/hopper.pnm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/hopper.pnm
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							|  | @ -14,6 +14,7 @@ class TestFileIco(PillowTestCase): | |||
|         self.assertEqual(im.mode, "RGBA") | ||||
|         self.assertEqual(im.size, (16, 16)) | ||||
|         self.assertEqual(im.format, "ICO") | ||||
|         self.assertEqual(im.get_format_mimetype(), "image/x-icon") | ||||
| 
 | ||||
|     def test_invalid_file(self): | ||||
|         with open("Tests/images/flower.jpg", "rb") as fp: | ||||
|  |  | |||
|  | @ -13,6 +13,7 @@ class TestFilePcx(PillowTestCase): | |||
|         self.assertEqual(im2.mode, im.mode) | ||||
|         self.assertEqual(im2.size, im.size) | ||||
|         self.assertEqual(im2.format, "PCX") | ||||
|         self.assertEqual(im2.get_format_mimetype(), "image/x-pcx") | ||||
|         self.assert_image_equal(im2, im) | ||||
| 
 | ||||
|     def test_sanity(self): | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| from .helper import PillowTestCase | ||||
| from .helper import PillowTestCase, hopper | ||||
| 
 | ||||
| from PIL import Image | ||||
| 
 | ||||
|  | @ -36,6 +36,16 @@ class TestFilePpm(PillowTestCase): | |||
|         reloaded = Image.open(f) | ||||
|         self.assert_image_equal(im, reloaded) | ||||
| 
 | ||||
|     def test_pnm(self): | ||||
|         im = Image.open('Tests/images/hopper.pnm') | ||||
|         self.assert_image_similar(im, hopper(), 0.0001) | ||||
| 
 | ||||
|         f = self.tempfile('temp.pnm') | ||||
|         im.save(f) | ||||
| 
 | ||||
|         reloaded = Image.open(f) | ||||
|         self.assert_image_equal(im, reloaded) | ||||
| 
 | ||||
|     def test_truncated_file(self): | ||||
|         path = self.tempfile('temp.pgm') | ||||
|         with open(path, 'w') as f: | ||||
|  |  | |||
|  | @ -37,6 +37,8 @@ class TestFileTga(PillowTestCase): | |||
|                         path_no_ext, origin, "rle" if rle else "raw") | ||||
| 
 | ||||
|                     original_im = Image.open(tga_path) | ||||
|                     self.assertEqual(original_im.format, "TGA") | ||||
|                     self.assertEqual(original_im.get_format_mimetype(), "image/x-tga") | ||||
|                     if rle: | ||||
|                         self.assertEqual( | ||||
|                             original_im.info["compression"], "tga_rle") | ||||
|  |  | |||
|  | @ -553,7 +553,7 @@ The :py:meth:`~PIL.Image.Image.save` method supports the following options: | |||
| PPM | ||||
| ^^^ | ||||
| 
 | ||||
| Pillow reads and writes PBM, PGM and PPM files containing ``1``, ``L`` or | ||||
| Pillow reads and writes PBM, PGM, PPM and PNM files containing ``1``, ``L`` or | ||||
| ``RGB`` data. | ||||
| 
 | ||||
| SGI | ||||
|  |  | |||
|  | @ -295,3 +295,5 @@ class IcoImageFile(ImageFile.ImageFile): | |||
| Image.register_open(IcoImageFile.format, IcoImageFile, _accept) | ||||
| Image.register_save(IcoImageFile.format, _save) | ||||
| Image.register_extension(IcoImageFile.format, ".ico") | ||||
| 
 | ||||
| Image.register_mime(IcoImageFile.format, "image/x-icon") | ||||
|  |  | |||
|  | @ -180,3 +180,5 @@ Image.register_open(PcxImageFile.format, PcxImageFile, _accept) | |||
| Image.register_save(PcxImageFile.format, _save) | ||||
| 
 | ||||
| Image.register_extension(PcxImageFile.format, ".pcx") | ||||
| 
 | ||||
| Image.register_mime(PcxImageFile.format, "image/x-pcx") | ||||
|  |  | |||
|  | @ -164,6 +164,6 @@ def _save(im, fp, filename): | |||
| Image.register_open(PpmImageFile.format, PpmImageFile, _accept) | ||||
| Image.register_save(PpmImageFile.format, _save) | ||||
| 
 | ||||
| Image.register_extensions(PpmImageFile.format, [".pbm", ".pgm", ".ppm"]) | ||||
| Image.register_extensions(PpmImageFile.format, [".pbm", ".pgm", ".ppm", ".pnm"]) | ||||
| 
 | ||||
| Image.register_mime(PpmImageFile.format, "image/x-portable-anymap") | ||||
|  |  | |||
|  | @ -226,4 +226,6 @@ def _save(im, fp, filename): | |||
| Image.register_open(TgaImageFile.format, TgaImageFile) | ||||
| Image.register_save(TgaImageFile.format, _save) | ||||
| 
 | ||||
| Image.register_extension(TgaImageFile.format, ".tga") | ||||
| Image.register_extensions(TgaImageFile.format, [".tga", ".icb", ".vda", ".vst"]) | ||||
| 
 | ||||
| Image.register_mime(TgaImageFile.format, "image/x-tga") | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user