From 84b59f187aa8418e0b5f0986caa6a5a7e5f08136 Mon Sep 17 00:00:00 2001 From: Anders Bennehag Date: Sun, 21 Jun 2020 14:08:45 -0400 Subject: [PATCH] createJPEGMarker(): Removes MakerNotes.ShotInfo from jpeg export as it is 52Kb large on Nikon Z-series cameras, which results in jpeg exif tags being larger than allowed 65Kb limit. Fixes https://github.com/Beep6581/RawTherapee/issues/5698 --- rtexif/rtexif.cc | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/rtexif/rtexif.cc b/rtexif/rtexif.cc index c0038c067..f32a9feb1 100644 --- a/rtexif/rtexif.cc +++ b/rtexif/rtexif.cc @@ -3248,7 +3248,43 @@ int ExifManager::createJPEGMarker (const TagDirectory* root, const rtengine::pro TagDirectory* cl; if (root) { - cl = (const_cast (root))->clone (nullptr); + cl = root->clone(nullptr); + + // Drop unwanted tags before exporting + // For example, Nikon Z-series has a 52Kb MakerNotes->ShotInfo tag + // which does not fit into the 65Kb limit on JPEG exif tags + const Tag* const make_tag = cl->getTag(271); + if (make_tag && !std::strncmp((const char*)make_tag->getValue(), "NIKON CORPORATION", 17)) { + [cl]() + { + Tag* const exif_tag = cl->getTag(34665); + if (!exif_tag) { + return; + } + + TagDirectory* const exif_dir = exif_tag->getDirectory(); + if (!exif_dir) { + return; + } + + Tag* const make_notes_tag = exif_dir->getTag(37500); + if (!make_notes_tag) { + return; + } + + TagDirectory* const maker_notes_dir = make_notes_tag->getDirectory(); + if (!maker_notes_dir) { + return; + } + + Tag* const shot_info_tag = maker_notes_dir->getTag(145); + if (!shot_info_tag) { + return; + } + + shot_info_tag->setKeep(false); + }(); + } } else { cl = new TagDirectory (nullptr, ifdAttribs, INTEL); }