From 413a086c09a5456ec13729cc4619707280de69bf Mon Sep 17 00:00:00 2001 From: wiredfool Date: Tue, 20 May 2014 10:13:48 -0700 Subject: [PATCH 1/2] Remove READ|WRITE_LIBTIFF guards for LZW/packbits compression tests --- Tests/test_file_libtiff.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index a53593a9e..58fa75239 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -258,9 +258,6 @@ def test_compressions(): im = lena('RGB') out = tempfile('temp.tif') - TiffImagePlugin.READ_LIBTIFF = True - TiffImagePlugin.WRITE_LIBTIFF = True - for compression in ('packbits', 'tiff_lzw'): im.save(out, compression=compression) im2 = Image.open(out) @@ -270,11 +267,6 @@ def test_compressions(): im2 = Image.open(out) assert_image_similar(im, im2, 30) - TiffImagePlugin.READ_LIBTIFF = False - TiffImagePlugin.WRITE_LIBTIFF = False - - - def test_cmyk_save(): im = lena('CMYK') From edd75ceb918be2f299109998bca323886c7af9b9 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Tue, 20 May 2014 10:14:41 -0700 Subject: [PATCH 2/2] Use libtiff for writing any compressed tiff files, Fixes #659, #431 --- PIL/TiffImagePlugin.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py index fe658d22c..11b92747c 100644 --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -984,11 +984,7 @@ def _save(im, fp, filename): compression = im.encoderinfo.get('compression',im.info.get('compression','raw')) - libtiff = WRITE_LIBTIFF or compression in ["tiff_ccitt", "group3", "group4", - "tiff_jpeg", "tiff_adobe_deflate", - "tiff_thunderscan", "tiff_deflate", - "tiff_sgilog", "tiff_sgilog24", - "tiff_raw_16"] + libtiff = WRITE_LIBTIFF or compression != 'raw' # required for color libtiff images ifd[PLANAR_CONFIGURATION] = getattr(im, '_planar_configuration', 1)