aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-12-12 00:21:04 +0100
committerPřemysl Eric Janouch <p@janouch.name>2021-12-12 00:22:21 +0100
commit2147dba8c433c48058b815f5cffd525dd11ddccc (patch)
tree8bc8d8ad2148af2b362dc2a201b22b967061951d
parent121c63e35e667a841380f4d405cc47ce0f50b2e9 (diff)
downloadfiv-2147dba8c433c48058b815f5cffd525dd11ddccc.tar.gz
fiv-2147dba8c433c48058b815f5cffd525dd11ddccc.tar.xz
fiv-2147dba8c433c48058b815f5cffd525dd11ddccc.zip
Add a comment about TIFF/EP vs libtiff
-rw-r--r--fastiv-io.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/fastiv-io.c b/fastiv-io.c
index ba2861f..372a9f0 100644
--- a/fastiv-io.c
+++ b/fastiv-io.c
@@ -1492,6 +1492,26 @@ open_libtiff(const gchar *data, gsize len, const gchar *path, GError **error)
if (!tiff)
goto fail;
+ // In Nikon NEF files, IFD0 is a tiny uncompressed thumbnail with SubIFDs--
+ // two of them JPEGs, the remaining one is raw. libtiff cannot read either
+ // of those better versions.
+ //
+ // TODO(p): If NewSubfileType is ReducedImage, and it has SubIFDs compressed
+ // as old JPEG (6), decode JPEGInterchangeFormat/JPEGInterchangeFormatLength
+ // with libjpeg-turbo and insert them as the starting pages.
+ //
+ // This is not possible with libtiff directly, because TIFFSetSubDirectory()
+ // requires an ImageLength tag that's missing, and TIFFReadCustomDirectory()
+ // takes a privately defined struct that cannot be omitted.
+ uint32_t subtype = 0;
+ uint16_t subifd_count = 0;
+ const uint64_t *subifd_offsets = NULL;
+ if (TIFFGetField(tiff, TIFFTAG_SUBFILETYPE, &subtype) &&
+ (subtype & FILETYPE_REDUCEDIMAGE) &&
+ TIFFGetField(tiff, TIFFTAG_SUBIFD, &subifd_count, &subifd_offsets) &&
+ subifd_count > 0 && subifd_offsets) {
+ }
+
do {
// We inform about unsupported directories, but do not fail on them.
GError *err = NULL;