Detect and correct incorrect makernote offsets#730
Draft
Copilot wants to merge 2 commits into
Draft
Conversation
Implements detection of makernotes where tag value offsets are written relative to the makernote's own start instead of the TIFF header, similar to ExifTool's 'Possibly incorrect maker notes offsets' warning. The algorithm (inspired by ExifTool's FixBase) finds the minimum raw offset among external-data IFD tags and compares it to the expected minimum for both the standard TIFF-header base and the makernote-relative base. If the makernote base matches better, it is used and a warning is added to the directory. All 17 processMakernote branches that used tiffHeaderOffset directly now call determineBestBase() to pick the correct offset base. A new unit test verifies both the warning message and the tag value extraction for the Canon makernote with incorrect offsets. Closes #654 Agent-Logs-Url: https://github.com/drewnoakes/metadata-extractor/sessions/5a5ddde7-5eb5-49a6-8c8b-5bb07682439b Co-authored-by: drewnoakes <350947+drewnoakes@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add detection and fixing of incorrect makernote offsets
Detect and correct incorrect makernote offsets
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some cameras write makernote tag value offsets relative to the makernote's own start position rather than the TIFF header, causing tag data to be read from wrong positions. This mirrors the ExifTool warning:
"Possibly incorrect maker notes offsets (fix by N?)".Algorithm (
ExifTiffHandler.determineBestBase)Inspired by ExifTool's
FixBaseheuristic:Coverage
All 17
TiffReader.processIfdcalls inprocessMakernotethat previously passedtiffHeaderOffsetdirectly now route throughdetermineBestBase(ifdOffset, tiffHeaderOffset, makernoteOffset, reader), covering:Makernotes that already explicitly use the makernote-relative base (Olympus OLYMPUS\0II, OM SYSTEM, Nikon type 2 embedded TIFF, Fujifilm, Pentax, Sanyo, Ricoh, Apple iOS, Leica type 5) are unaffected.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
repository.sonatype.org/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.14/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.14/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.14 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.14/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/metadata-extractor/metadata-extractor org.codehaus.plexus.classworlds.launcher.Launcher test -q(dns block)If you need me to access, download, or install something from one of these locations, you can either: