aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-06-08 18:58:21 +0200
committerPřemysl Eric Janouch <p@janouch.name>2023-06-08 18:59:19 +0200
commit34388b93ea92a979d0575ecc1aee48b854ffcc9c (patch)
tree531de8c827920dd1e4411e21eaafbe6fa37f5546
parent7dda3bd1ed923e9c2dba887670b9f65509235375 (diff)
downloadfiv-34388b93ea92a979d0575ecc1aee48b854ffcc9c.tar.gz
fiv-34388b93ea92a979d0575ecc1aee48b854ffcc9c.tar.xz
fiv-34388b93ea92a979d0575ecc1aee48b854ffcc9c.zip
info: decode JPEGs from all CR2 IFDs
-rw-r--r--tools/info.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/info.h b/tools/info.h
index d640f35..7476f9a 100644
--- a/tools/info.h
+++ b/tools/info.h
@@ -247,19 +247,23 @@ parse_exif_ifd(struct tiffer *T, const struct tiff_entry *info)
}
// This is how Exif specifies it, which doesn't follow TIFF 6.0.
- if (info == tiff_entries && compression == TIFF_Compression_JPEG &&
+ // Also support CR2 IFD1, which isn't tagged with compression at all.
+ if (info == tiff_entries && /* compression == TIFF_Compression_JPEG && */
jpeg > 0 && jpeg_length > 0 &&
- jpeg + jpeg_length < (T->end - T->begin)) {
+ jpeg + jpeg_length <= (T->end - T->begin)) {
ifd = jv_set(ifd, jv_string("JPEG image data"),
parse_jpeg(
jv_object(), T->begin + jpeg, jpeg_length));
}
+ // As specified by DRAFT TIFF Technical Note 2 + TIFFphotoshop.pdf.
// Theoretically, there may be more strips, but this is not expected.
+ // Also support CR2 IFD0, which is tagged with the "wrong" compression.
if (info == tiff_entries &&
- compression == TIFF_Compression_JPEGDatastream &&
+ (compression == TIFF_Compression_JPEGDatastream ||
+ compression == TIFF_Compression_JPEG) &&
strip_offsets > 0 && strip_byte_counts > 0 &&
- strip_offsets + strip_byte_counts < (T->end - T->begin)) {
+ strip_offsets + strip_byte_counts <= (T->end - T->begin)) {
ifd = jv_set(ifd, jv_string("JPEG image data"),
parse_jpeg(
jv_object(), T->begin + strip_offsets, strip_byte_counts));