Skip to content

Commit

Permalink
Improve Nikon RAW NEF (Tiff) format detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Borewit committed Sep 8, 2024
1 parent 19fc36d commit c089494
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
17 changes: 12 additions & 5 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1699,11 +1699,18 @@ export class FileTypeParser {
};
}

if (ifdOffset >= 8 && (this.check([0x1C, 0x00, 0xFE, 0x00], {offset: 8}) || this.check([0x1F, 0x00, 0x0B, 0x00], {offset: 8}))) {
return {
ext: 'nef',
mime: 'image/x-nikon-nef',
};
if (ifdOffset >= 8) {
const someId1 = (bigEndian ? Token.UINT16_BE : Token.UINT16_LE).get(this.buffer, 8);
const someId2 = (bigEndian ? Token.UINT16_BE : Token.UINT16_LE).get(this.buffer, 10);

if (
(someId1 === 0x1C && someId2 === 0xFE)
|| (someId1 === 0x1F && someId2 === 0x0B)) {
return {
ext: 'nef',
mime: 'image/x-nikon-nef',
};
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,5 +253,6 @@
},
"ava": {
"serial": true
}
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}

0 comments on commit c089494

Please sign in to comment.