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
Add support for tags 50838 and 50839 in tif files #291
publicstaticfinalintMETA_DATA_BYTE_COUNTS = 50838; // private tag registered with AdobepublicstaticfinalintMETA_DATA = 50839; // private tag registered with Adobe
It is just a question of adding them to TAGS dictionary in TiffTags.py (for what I understood). Should it be with tags below the comment "Adobe DNG" or we need to create another comment and if so, which one?
My problem is also that I do not know about the saving part (see issue #290).
Sorry about the delay, you can find an image here.
You will also see that use of the show and getdata methods will give you errors as well scipy.fromimage. This might be the subject of a new issue.
Even without adding names for the ImageJ tags, PIL allows to access all known and unknown tiff tags using their numbers in the tag or ifd attributes, e.g. img.tag[50838].
I don't think it is a good idea to preserve software/application specific tags when saving in general and specifically not in this case.
For example, the imagej tags in graphite1-1024.tif contain the following meta data:
Processing the image (e.g. crop, re-sample, type conversion) with PIL and saving the metadata unchanged along with the processed image data will probably leave the file in an inconsistent or corrupt state.
It looks like tiffs with a mode of 'F;32BF' wasn't getting a proper mode/rawmode set to actually load the data.
I'm guessing that there's actually a bunch of (potential) float 32 tiff modes that aren't properly loaded -- previously we interpreted F;32F (little endian floats) correctly, messed up F;32BF (big endian), and are totally missing the rest of the floats defined in Unpack.c, including 64 bit versions. Not that I'm convinced that any of the other ones show up in the wild, since the bug here is from the initial import into Pillow and we're only just finding it.
It appears that we're only supporting writing certain tags into tiff files at all. The save process is essentially: Make a new tag directory, pull in some tags and encoder info, then write that. There's no option for adding any user generated stuff, explicitly or not.
I'm looking at adding support for specific tags that users want to save, similar to how pnginfo is used on pings, but I'm running into type errors. Still digging on that.
I've added support in my tree for adding arbitrary tags to a tiff image by populating an ImageFileDirectory and sending that into the save method. Code is at https://github.com/wiredfool/Pillow/tree/tifftags . I'd like some more testing prior to actually merging this one, since I've done a good bit of mucking with the ImageFileDirectory internals. I may do even more, since there's a good bit of confusion between values and (type,value) tuples in the storage at this point.
How to use: (alternately, checkout the test_file_tiff_metadata.py file)
Activity
aclark4life commentedon Jul 17, 2013
Thanks, can you send a pull request?
PhML commentedon Jul 18, 2013
It is just a question of adding them to TAGS dictionary in TiffTags.py (for what I understood). Should it be with tags below the comment "Adobe DNG" or we need to create another comment and if so, which one?
My problem is also that I do not know about the saving part (see issue #290).
wiredfool commentedon Jul 18, 2013
It looks like there's some need to add the tags that are preserved in the TiffImagePlugin save method: https://github.com/python-imaging/Pillow/blob/master/PIL/TiffImagePlugin.py#L923 . I'd have to check in more detail if there's some way that any tags not explicitly included are kept, but I don't think so. The default in other places in Pillow is to only include metadata that's explicitly specified.
Do you have a redistributable test image that has the tags included?
PhML commentedon Aug 5, 2013
Sorry about the delay, you can find an image here.
You will also see that use of the
showandgetdatamethods will give you errors as wellscipy.fromimage. This might be the subject of a new issue.aclark4life commentedon Sep 27, 2013
@wiredfool Can this go in 2.2.0?
cgohlke commentedon Sep 27, 2013
Even without adding names for the ImageJ tags, PIL allows to access all known and unknown tiff tags using their numbers in the
tagorifdattributes, e.g.img.tag[50838].I don't think it is a good idea to preserve software/application specific tags when saving in general and specifically not in this case.
For example, the imagej tags in graphite1-1024.tif contain the following meta data:
Processing the image (e.g. crop, re-sample, type conversion) with PIL and saving the metadata unchanged along with the processed image data will probably leave the file in an inconsistent or corrupt state.
wiredfool commentedon Sep 27, 2013
It looks like tiffs with a mode of 'F;32BF' wasn't getting a proper mode/rawmode set to actually load the data.
I'm guessing that there's actually a bunch of (potential) float 32 tiff modes that aren't properly loaded -- previously we interpreted F;32F (little endian floats) correctly, messed up F;32BF (big endian), and are totally missing the rest of the floats defined in Unpack.c, including 64 bit versions. Not that I'm convinced that any of the other ones show up in the wild, since the bug here is from the initial import into Pillow and we're only just finding it.
wiredfool commentedon Sep 28, 2013
WRT to the tags, from https://github.com/python-imaging/Pillow/blob/master/PIL/TiffImagePlugin.py#L923
It appears that we're only supporting writing certain tags into tiff files at all. The save process is essentially: Make a new tag directory, pull in some tags and encoder info, then write that. There's no option for adding any user generated stuff, explicitly or not.
I'm looking at adding support for specific tags that users want to save, similar to how pnginfo is used on pings, but I'm running into type errors. Still digging on that.
aclark4life commentedon Sep 28, 2013
OK feel free to punt this to 2.3.0 or Future if you need more time
aclark4life commentedon Oct 2, 2013
If I understand correctly this is partially done and the rest can wait for 2.3.0
wiredfool commentedon Oct 2, 2013
Yeah, it can wait.
wiredfool commentedon Oct 3, 2013
I've added support in my tree for adding arbitrary tags to a tiff image by populating an ImageFileDirectory and sending that into the save method. Code is at https://github.com/wiredfool/Pillow/tree/tifftags . I'd like some more testing prior to actually merging this one, since I've done a good bit of mucking with the ImageFileDirectory internals. I may do even more, since there's a good bit of confusion between values and (type,value) tuples in the storage at this point.
How to use: (alternately, checkout the test_file_tiff_metadata.py file)
aclark4life commentedon Dec 28, 2013
IIUC I just merged everything related to this issue
Merge pull request python-pillow#291 from radarhere/numpy