Skip to content
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
6 changes: 4 additions & 2 deletions core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ export type FileExtension =
| '3mf'
| 'zst'
| 'jxl'
| 'vcf';
| 'vcf'
| 'jls';

export type MimeType =
| 'image/jpeg'
Expand Down Expand Up @@ -276,7 +277,8 @@ export type MimeType =
| 'application/vnd.ms-htmlhelp'
| 'model/3mf'
| 'image/jxl'
| 'application/zstd';
| 'application/zstd'
| 'image/jls';

export interface FileTypeResult {
/**
Expand Down
22 changes: 15 additions & 7 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,6 @@ class FileTypeParser {
};
}

if (this.check([0xFF, 0xD8, 0xFF])) {
return {
ext: 'jpg',
mime: 'image/jpeg',
};
}

if (this.check([0x49, 0x49, 0xBC])) {
return {
ext: 'jxr',
Expand Down Expand Up @@ -222,6 +215,21 @@ class FileTypeParser {

// -- 4-byte signatures --

// Requires a sample size of 4 bytes
if (this.check([0xFF, 0xD8, 0xFF])) {
if (this.check([0xF7], {offset: 3})) { // JPG7/SOF55, indicating a ISO/IEC 14495 / JPEG-LS file
return {
ext: 'jls',
mime: 'image/jls',
};
}

return {
ext: 'jpg',
mime: 'image/jpeg',
};
}

if (this.checkString('FLIF')) {
return {
ext: 'flif',
Expand Down
Binary file added fixture/fixture-hp1.jls
Binary file not shown.
Binary file added fixture/fixture-hp2.jls
Binary file not shown.
Binary file added fixture/fixture-hp3.jls
Binary file not shown.
Binary file added fixture/fixture-normal.jls
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@
"3mf",
"zst",
"jxl",
"vcf"
"vcf",
"jls"
],
"dependencies": {
"readable-web-to-node-stream": "^3.0.2",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ Returns a `Set<string>` of supported MIME types.
- [`ics`](https://en.wikipedia.org/wiki/ICalendar#Data_format) - iCalendar
- [`indd`](https://en.wikipedia.org/wiki/Adobe_InDesign#File_format) - Adobe InDesign document
- [`it`](https://wiki.openmpt.org/Manual:_Module_formats#The_Impulse_Tracker_format_.28.it.29) - Audio module format: Impulse Tracker
- [`jls`](https://en.wikipedia.org/wiki/Lossless_JPEG#JPEG-LS) - Lossless/near-lossless compression standard for continuous-tone images
- [`jp2`](https://en.wikipedia.org/wiki/JPEG_2000) - JPEG 2000
- [`jpg`](https://en.wikipedia.org/wiki/JPEG) - Joint Photographic Experts Group image
- [`jpm`](https://en.wikipedia.org/wiki/JPEG_2000) - JPEG 2000
Expand Down
2 changes: 2 additions & 0 deletions supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export const extensions = [
'zst',
'jxl',
'vcf',
'jls',
];

export const mimeTypes = [
Expand Down Expand Up @@ -275,4 +276,5 @@ export const mimeTypes = [
'model/3mf',
'image/jxl',
'application/zstd',
'image/jls',
];
6 changes: 6 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ const names = {
'fixture-utf16-be-bom', // UTF-16 little endian encoded XML, with BOM
'fixture-utf16-le-bom', // UTF-16 big endian encoded XML, with BOM
],
jls: [
'fixture-normal',
'fixture-hp1',
'fixture-hp2',
'fixture-hp3',
],
};

// Define an entry here only if the file type has potential
Expand Down