Discussion:
TIFF_SETGET_C0_DOUBLE handling missing?
Jürgen Buchmüller
2014-01-22 03:07:26 UTC
Permalink
It looks like TIFF_SETGET_C0_DOUBLE has no case in the switch in
tif_dirread.c

I would have liked to use it to support TIFFTAG_GPSIFD reading/writing
through a custom TIFFFieldArray, where several tags expect a fixed
number of 3 rationals, i.e. degrees, minutes, seconds.

I could of course go back to TIFF_SETGET_C0_FLOAT in my custom TIFFField
array, which may be sufficiently precise for almost any use case. Or I
could use TIFF_SETGET_C16_DOUBLE, which it looks like has its case in
the switch statement...

However the entire recently included exifFields[] array in tif_dirinfo.c
uses double for the rational fields defined in EXIF, so may I ask if the
omission of TIFF_SETGET_C0_DOUBLE is intentional or just because no one
realized it's missing?

Jürgen


_______________________________________________
Tiff mailing list: ***@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://w
Bob Friesenhahn
2014-01-22 15:11:29 UTC
Permalink
Post by Jürgen Buchmüller
However the entire recently included exifFields[] array in tif_dirinfo.c
uses double for the rational fields defined in EXIF, so may I ask if the
omission of TIFF_SETGET_C0_DOUBLE is intentional or just because no one
realized it's missing?
Problems are not intentional. Contributions of well tested source
patches are appreciated.

Bob
--
Bob Friesenhahn
***@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
Jürgen Buchmüller
2014-01-23 19:45:05 UTC
Permalink
Post by Bob Friesenhahn
Problems are not intentional. Contributions of well tested source
patches are appreciated.
Well tested it isn't, because I have just one application using it. It
is rather straightforward, though, which is why it will almost certainly
be ok. See attached diff against 4.0.3.

What doesn't work is to declare a TIFFField with field_type ==
TIFF_RATIONAL and then use TIFF_GETSET_C0_DOUBLE, because there is an
array conversion to rational just for float arrays, not for double
arrays.

The combination TIFF_RATIONAL vs. DOUBLE just works for single values,
since TIFFWriteDirectoryTagRational() expects a double value.

In other words: in tif_dirwrite.c there is no implementation of a
TIFFWriteDirectoryTagCheckedRationalArrayDouble() function with "double*
value" as its last parameter. It would have to be written and used for
the case where the field_type is TIFF_RATIONAL and the passed in array
type is TIFF_.._DOUBLE.

I tried to add this type of conversion to libtiff-4.0.3, but then
stumbled across the fact that the TIFF_RATIONAL and TIFF_SRATIONAL types
are implicitly converted to float arrays in tif_dirread.c and there is
no (easy) way to make that conversion depend on the field declaration.

If there is interest, I could try to implement the TIFFFieldArray for
the EXIF_TAG_GPS_... and also the TIFFReadGPSDirectory() and
TIFFCreateGPSDirectory() functions, analogous to TIFFReadEXIFDirectory()
and TIFFCreateEXIFDirectory().

I have it running with a private TIFFFieldArray which, to avoid
inconsistent use of float and double, defines TIFF_SETGET_FLOAT and
TIFF_GETSET_C0_FLOAT for all rationals in EXIF-GPS.

JÃŒrgen

Loading...