mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-01 00:17:27 +03:00 
			
		
		
		
	Pad COLORMAP to 768 items
This commit is contained in:
		
							parent
							
								
									c6637bc4de
								
							
						
					
					
						commit
						1e3fdb3055
					
				|  | @ -497,8 +497,8 @@ class TestFileLibTiff(LibTiffTestCase): | ||||||
|         im.save(out, compression="tiff_adobe_deflate") |         im.save(out, compression="tiff_adobe_deflate") | ||||||
|         assert_image_equal_tofile(im, out) |         assert_image_equal_tofile(im, out) | ||||||
| 
 | 
 | ||||||
|     def test_palette_save(self, tmp_path): |     @pytest.mark.parametrize("im", (hopper("P"), Image.new("P", (1, 1), "#000"))) | ||||||
|         im = hopper("P") |     def test_palette_save(self, im, tmp_path): | ||||||
|         out = str(tmp_path / "temp.tif") |         out = str(tmp_path / "temp.tif") | ||||||
| 
 | 
 | ||||||
|         TiffImagePlugin.WRITE_LIBTIFF = True |         TiffImagePlugin.WRITE_LIBTIFF = True | ||||||
|  |  | ||||||
|  | @ -1676,7 +1676,12 @@ def _save(im, fp, filename): | ||||||
| 
 | 
 | ||||||
|     if im.mode in ["P", "PA"]: |     if im.mode in ["P", "PA"]: | ||||||
|         lut = im.im.getpalette("RGB", "RGB;L") |         lut = im.im.getpalette("RGB", "RGB;L") | ||||||
|         ifd[COLORMAP] = tuple(v * 256 for v in lut) |         colormap = [] | ||||||
|  |         colors = len(lut) // 3 | ||||||
|  |         for i in range(3): | ||||||
|  |             colormap += [v * 256 for v in lut[colors * i : colors * (i + 1)]] | ||||||
|  |             colormap += [0] * (256 - colors) | ||||||
|  |         ifd[COLORMAP] = colormap | ||||||
|     # data orientation |     # data orientation | ||||||
|     stride = len(bits) * ((im.size[0] * bits[0] + 7) // 8) |     stride = len(bits) * ((im.size[0] * bits[0] + 7) // 8) | ||||||
|     # aim for given strip size (64 KB by default) when using libtiff writer |     # aim for given strip size (64 KB by default) when using libtiff writer | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user