Skip to content

Tiff: allow writing floating point tag values#1113

Merged
hugovk merged 6 commits intopython-pillow:masterfrom
bpedersen2:master
Apr 14, 2015
Merged

Tiff: allow writing floating point tag values#1113
hugovk merged 6 commits intopython-pillow:masterfrom
bpedersen2:master

Conversation

@bpedersen2
Copy link
Contributor

Use the inverse logic used for loading floating point tag
values to also write them out again.

Use the inverse logic used for loading floating point tag
values to also write them out again.
@hugovk hugovk changed the title Tiff: allow writing floating poitn tag values Tiff: allow writing floating point tag values Feb 23, 2015
@hugovk
Copy link
Member

hugovk commented Feb 23, 2015

@bpedersen2 Please can you add tests so this new code is covered?

https://coveralls.io/builds/1976951/source?filename=PIL%2FTiffImagePlugin.py#L520

Add tests for writing of float/double values in tiff file tags.
due to rounding, the values are just 'almost' equal.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 74.98% when pulling 47f5c9e on bpedersen2:master into 0bc24cb on python-pillow:master.

@wiredfool
Copy link
Member

Noting that this likely interacts with #1059.

anntzer added a commit to anntzer/Pillow that referenced this pull request Feb 26, 2015
@aclark4life aclark4life added this to the 2.9.0 milestone Apr 1, 2015
@aclark4life
Copy link
Member

@bpedersen2 Any progress on this?

@karimbahgat
Copy link
Contributor

This is great! I was just about to add a new issue on exactly the same. I had inserted my own custom code in TiffImagePlugin.py similar to @bpedersen2 but I like his code better.

Especially since it looks like the Travis CI tests passed I really hope there is nothing left in the way for this pull request to be merged. As evidenced by #983 and this post I think there is considerable interest from GIS developers in using Pillow to save GeoTIFFs (or at least there could and should be). And since #660 has demonstrated how to save custom TIFF tags, the inability to save float/double tags is really the last remaining obstacle to having fully blown support for GeoTIFF images in Pillow, since virtually all of the important GIS-specific tags (coordinate transform and projection definitions) in the GeoTIFF specification require decimal numbers of type double.

I have a GIS developers book coming out soon where I patch Pillow to support Python floats and then use it to save GeoTIFFs, so it would be especially great if this feature was already in the main branch so I can drop the part about patching. This could be a great encouragement to GIS developers and users to know that Pillow has at least basic out-of-the-box support for GeoTIFF.

If there is anything I could do to speed the process I would gladly do so.

@hugovk
Copy link
Member

hugovk commented Apr 14, 2015

Looks good to me, merging.

@karimbahgat Do you think it'd be useful to add any more tests for GIS-specific tags?

hugovk added a commit that referenced this pull request Apr 14, 2015
Tiff: allow writing floating point tag values
@hugovk hugovk merged commit b7bf299 into python-pillow:master Apr 14, 2015
@karimbahgat
Copy link
Contributor

That was fast, thanks!

Regarding the GIS tag tests, I don't think there would be a point. The GIS specific tags are just like any other tag, and since @bpedersen2 added successfull tests of saving floats and doubles to some generic tags, those tests apply equally much to any GIS-specific tags or any other specialized-tag for that matter. Or maybe I misunderstood?

I can testify that I was able to successfully save and reload a GeoTIFF of the world with the new Pillow code after your merge. The commonly used GIS-specific "nodata" tag was also successfully saved and reloaded as ascii type. I think all of the GIS-tags only use short, double, or ascii types so they should all be supported. There is however one tag that contains a nodata image mask of sorts but I haven't looked into which data type it uses. For another time I think :P

@hugovk
Copy link
Member

hugovk commented Apr 15, 2015

You understood :)

anntzer added a commit to anntzer/Pillow that referenced this pull request Jun 16, 2015
anntzer added a commit to anntzer/Pillow that referenced this pull request Jun 29, 2015
wiredfool pushed a commit to wiredfool/Pillow that referenced this pull request Sep 10, 2015
wiredfool pushed a commit to wiredfool/Pillow that referenced this pull request Sep 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants