How To Add Additional Tag For Tiff File
I am trying to read and save a tiff file with some additional Tags, when I make a new image that works well but when I open an image then trying to write some meta tags back it is
Solution 1:
The following works for me with Pillow version 2.3:
from PIL import Image
image_1 = Image.open('input.tiff')
image_1.tag[37000] = 'my special tiff tag'
image_1.save('output.tiff', tiffinfo=image_1.tag)
image_2 = Image.open('output.tiff')
print image_2.tag[37000]
This prints my special tiff tag
when running with an input.tiff
in the current folder.
My understanding is that this only works when you don't use libtiff for writing the file. When using libtiff custom tags are ignored.
Solution 2:
For someone interested that topic:
C/C++ method to add custom tag for tiff file
That will perfectly solve the problem
Post a Comment for "How To Add Additional Tag For Tiff File"