You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Save custom TIFF tags in LZW-compressed TIFFs #660
If I understand correctly, the recent changes (#369) have not made it possible to write custom TIFF tags. I would like to do the following:
info=TiffImagePlugin.ImageFileDirectory()
CustomTagId=37000info[CustomTagId] =6info.tagtype[CustomTagId] =3# 'short' according to TiffTags.TYPESimg.save(pathname, tiffinfo=info)
Unfortunately, I observe that this only works with TiffImagePlugin.WRITE_LIBTIFF = False, so I cannot use it for LZW-compressed TIFFs, see #659.
(I have tested the standalone version:
# Tested with WinPython-32bit-3.3.5.0fromPILimportImage, TiffImagePluginfromnose.toolsimportassert_equaldeftest_custom_metadata():
img=Image.new('L', (300, 300))
img.putpixel((150,150), 255)
info=TiffImagePlugin.ImageFileDirectory()
CustomTagId=37000info[CustomTagId] =6info.tagtype[CustomTagId] =3# 'short' according to TiffTags.TYPESImage.DEBUG=TrueTiffImagePlugin.WRITE_LIBTIFF=False# Set to True to see it break.img.save('temp.tiff', tiffinfo=info)
reloaded=Image.open('temp.tiff')
assert_equal(6, reloaded.tag.getscalar(CustomTagId))
test_custom_metadata()
Activity
wiredfool commentedon May 24, 2014
Sorry I missed this earlier.
I think this works. The following code writes your custom tag, and will read it back in with the correct value.
jondo commentedon May 26, 2014
Unfortunately, I observe that this only works with
TiffImagePlugin.WRITE_LIBTIFF = False, so I cannot use it for LZW-compressed TIFFs, see #659.(I have tested the standalone version:
)
wiredfool commentedon May 26, 2014
I don't remember anything special for custom tags when I did the work on libtiff, so I'm pretty sure that they're not in there yet.
[-]Save custom TIFF tags[/-][+]Save custom TIFF tags in LZW-compressed TIFFs[/+]radarhere commentedon Aug 25, 2018
The custom tag is skipped here - https://github.com/python-pillow/Pillow/blob/f115546b56a54b6458f189/src/PIL/TiffImagePlugin.py#L1512
So this looks like it is part of the 'UNDONE -- add code for the custom dictionary'
radarhere commentedon Oct 16, 2018
I've created PR #3350 for this