mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 09:44:31 +03:00
Merge pull request #669 from wiredfool/tiff_compression
Use libtiff for writing any compressed tiff files
This commit is contained in:
commit
26b0f20763
|
@ -984,11 +984,7 @@ def _save(im, fp, filename):
|
||||||
|
|
||||||
compression = im.encoderinfo.get('compression',im.info.get('compression','raw'))
|
compression = im.encoderinfo.get('compression',im.info.get('compression','raw'))
|
||||||
|
|
||||||
libtiff = WRITE_LIBTIFF or compression in ["tiff_ccitt", "group3", "group4",
|
libtiff = WRITE_LIBTIFF or compression != 'raw'
|
||||||
"tiff_jpeg", "tiff_adobe_deflate",
|
|
||||||
"tiff_thunderscan", "tiff_deflate",
|
|
||||||
"tiff_sgilog", "tiff_sgilog24",
|
|
||||||
"tiff_raw_16"]
|
|
||||||
|
|
||||||
# required for color libtiff images
|
# required for color libtiff images
|
||||||
ifd[PLANAR_CONFIGURATION] = getattr(im, '_planar_configuration', 1)
|
ifd[PLANAR_CONFIGURATION] = getattr(im, '_planar_configuration', 1)
|
||||||
|
|
|
@ -258,9 +258,6 @@ def test_compressions():
|
||||||
im = lena('RGB')
|
im = lena('RGB')
|
||||||
out = tempfile('temp.tif')
|
out = tempfile('temp.tif')
|
||||||
|
|
||||||
TiffImagePlugin.READ_LIBTIFF = True
|
|
||||||
TiffImagePlugin.WRITE_LIBTIFF = True
|
|
||||||
|
|
||||||
for compression in ('packbits', 'tiff_lzw'):
|
for compression in ('packbits', 'tiff_lzw'):
|
||||||
im.save(out, compression=compression)
|
im.save(out, compression=compression)
|
||||||
im2 = Image.open(out)
|
im2 = Image.open(out)
|
||||||
|
@ -270,11 +267,6 @@ def test_compressions():
|
||||||
im2 = Image.open(out)
|
im2 = Image.open(out)
|
||||||
assert_image_similar(im, im2, 30)
|
assert_image_similar(im, im2, 30)
|
||||||
|
|
||||||
TiffImagePlugin.READ_LIBTIFF = False
|
|
||||||
TiffImagePlugin.WRITE_LIBTIFF = False
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_cmyk_save():
|
def test_cmyk_save():
|
||||||
im = lena('CMYK')
|
im = lena('CMYK')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user