Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more ARW, DNG, NEF and TIF fixtures, and new detection patterns #220

Merged
merged 2 commits into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added fixture/fixture.tif
Binary file not shown.
Binary file added fixture/fixture2.arw
Binary file not shown.
Binary file added fixture/fixture2.dng
Binary file not shown.
Binary file added fixture/fixture2.nef
Binary file not shown.
Binary file added fixture/fixture3.arw
Binary file not shown.
Binary file added fixture/fixture3.nef
Binary file not shown.
Binary file added fixture/fixture4.arw
Binary file not shown.
18 changes: 15 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,33 @@ const fileType = input => {
};
}

if (check([0x49, 0x49, 0x2A, 0x00, 0x10, 0xFB, 0x86, 0x01])) {
if (
check([0x49, 0x49, 0x2A, 0x00]) &&
(check([0x10, 0xFB, 0x86, 0x01], {offset: 4}) ||
check([0x08, 0x00, 0x00, 0x00, 0x13, 0x00], {offset: 4}) ||
check([0x08, 0x00, 0x00, 0x00, 0x12, 0x00], {offset: 4}))
) {
return {
ext: 'arw',
mime: 'image/x-sony-arw'
};
}

if (check([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2D])) {
if (
check([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00]) &&
(check([0x2D, 0x00, 0xFE, 0x00], {offset: 8}) ||
check([0x27, 0x00, 0xFE, 0x00], {offset: 8}))
) {
return {
ext: 'dng',
mime: 'image/x-adobe-dng'
};
}

if (check([0x49, 0x49, 0x2A, 0x00, 0x30, 0x3D, 0x72, 0x01, 0x1C])) {
if (
check([0x49, 0x49, 0x2A, 0x00]) &&
check([0x1C, 0x00, 0xFE, 0x00], {offset: 8})
) {
return {
ext: 'nef',
mime: 'image/x-nikon-nef'
Expand Down
14 changes: 14 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ const types = [
// Define an entry here only if the fixture has a different
// name than `fixture` or if you want multiple fixtures
const names = {
arw: [
'fixture',
'fixture2',
'fixture3',
'fixture4'
],
dng: [
'fixture',
'fixture2'
],
nef: [
'fixture',
'fixture2'
],
'3gp': [
'fixture',
'fixture2'
Expand Down