-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for tags 50838 and 50839 in tif files #291
Comments
Thanks, can you send a pull request? |
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). |
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? |
Sorry about the delay, you can find an image here. |
@wiredfool Can this go in 2.2.0? |
Even without adding names for the ImageJ tags, PIL allows to access all known and unknown tiff tags using their numbers in the 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.
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. |
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. |
OK feel free to punt this to 2.3.0 or Future if you need more time |
If I understand correctly this is partially done and the rest can wait for 2.3.0 |
Yeah, it can wait. |
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)
|
IIUC I just merged everything related to this issue |
Updated NumPy to latest 1.21 on 32-bit
In some tif files saved by ImageJ, there is to tags unknown from TiffTags.py:
tag 50838 and 50839.
In the ImageJ source they are defined as:
It also would be useful if we could save them.
The text was updated successfully, but these errors were encountered: