mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-10 08:12:33 +03:00
two additional tags for saving color images with libtiff
This commit is contained in:
parent
ac25dab915
commit
d2f1fa0e5f
|
@ -923,6 +923,9 @@ def _save(im, fp, filename):
|
||||||
"tiff_sgilog", "tiff_sgilog24",
|
"tiff_sgilog", "tiff_sgilog24",
|
||||||
"tiff_raw_16"]
|
"tiff_raw_16"]
|
||||||
|
|
||||||
|
# required for color libtiff images
|
||||||
|
ifd[PLANAR_CONFIGURATION] = getattr(im, '_planar_configuration', 1)
|
||||||
|
|
||||||
# -- multi-page -- skip TIFF header on subsequent pages
|
# -- multi-page -- skip TIFF header on subsequent pages
|
||||||
if not libtiff and fp.tell() == 0:
|
if not libtiff and fp.tell() == 0:
|
||||||
# tiff header (write via IFD to get everything right)
|
# tiff header (write via IFD to get everything right)
|
||||||
|
@ -1014,6 +1017,8 @@ def _save(im, fp, filename):
|
||||||
|
|
||||||
blocklist = [STRIPOFFSETS, STRIPBYTECOUNTS, ROWSPERSTRIP, ICCPROFILE] # ICC Profile crashes.
|
blocklist = [STRIPOFFSETS, STRIPBYTECOUNTS, ROWSPERSTRIP, ICCPROFILE] # ICC Profile crashes.
|
||||||
atts={}
|
atts={}
|
||||||
|
# bits per sample is a single short in the tiff directory, not a list.
|
||||||
|
atts[BITSPERSAMPLE] = bits[0]
|
||||||
# Merge the ones that we have with (optional) more bits from
|
# Merge the ones that we have with (optional) more bits from
|
||||||
# the original file, e.g x,y resolution so that we can
|
# the original file, e.g x,y resolution so that we can
|
||||||
# save(load('')) == original file.
|
# save(load('')) == original file.
|
||||||
|
|
|
@ -179,3 +179,31 @@ def test_g4_string_info():
|
||||||
assert_equal('temp.tif', reread.tag[269])
|
assert_equal('temp.tif', reread.tag[269])
|
||||||
|
|
||||||
|
|
||||||
|
def test_blur():
|
||||||
|
# test case from irc, how to do blur on b/w image and save to compressed tif.
|
||||||
|
from PIL import ImageFilter
|
||||||
|
out = tempfile('temp.tif')
|
||||||
|
im = Image.open('Tests/images/pport_g4.tif')
|
||||||
|
im = im.convert('L')
|
||||||
|
|
||||||
|
im=im.filter(ImageFilter.GaussianBlur(4))
|
||||||
|
im.save(out, compression='tiff_adobe_deflate')
|
||||||
|
|
||||||
|
im2 = Image.open(out)
|
||||||
|
im2.load()
|
||||||
|
|
||||||
|
assert_image_equal(im, im2)
|
||||||
|
|
||||||
|
|
||||||
|
def test_packbits():
|
||||||
|
#im.info['compression']='packbits'
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def test_cmyk_save():
|
||||||
|
im = lena('CMYK')
|
||||||
|
out = tempfile('temp.tif')
|
||||||
|
|
||||||
|
im.save(out, compression='tiff_adobe_deflate')
|
||||||
|
im2 = Image.open(out)
|
||||||
|
assert_image_equal(im, im2)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user