Pillow
Pillow copied to clipboard
Libtiff metadata writing fixes
Fixes #1765, #1147, #1597 (among others, likely)
Libtiff's metadata support is tricky and dangerous. This patch is 1/3 of the work to clean up our support for it.
-
Understand and support writing basic metadata through libtiff. This includes casting numbers to the correct format and passing in arrays correctly for known items. (e.g., this fixes #1765, writing ints to dpi, and writing the colormap for
Pmode images) -
Consider supporting custom metadata tags safely. This is going to require reflection from libtiff to ensure that we're setting items correctly.
-
Coordinate this work with the python metadata implementation in two places: When reading images where the type conflicts with the spec, and when writing (in python) metadata of incorrect types.
While this is not finished, I believe that this is a material improvement in the support for tiff metadata, and can be merged (after I'm happy and rebased out some things) for 3.5.
Last few commits are the start of 2 and 3, but there's an issue with the sampleformat due to the differences between how we've had it defined and in tiff files, and how it's in the api. Additionally, I think the failures on appveyor are due to a libtiff5 vs libtiff4 difference.
Upshot is, I think I've got to handle most of this to do it right, and doing just 1 isn't going to cut it.
Note that PR #3338 added a fix for #1765, so this PR will have to consider that change, or maybe just revert it in favour of this work.