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 Dec 2, 2024
1 parent 2bc2eb7 commit 471b4d0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1706,11 +1706,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

0 comments on commit 471b4d0

Please sign in to comment.