From 2147dba8c433c48058b815f5cffd525dd11ddccc Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Sun, 12 Dec 2021 00:21:04 +0100 Subject: Add a comment about TIFF/EP vs libtiff --- fastiv-io.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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; -- cgit v1.2.3-70-g09d2