Skip to content

Commit 57ecf2d

Browse files
authored
Add support for JPEG XL image format (#455)
1 parent 07101ac commit 57ecf2d

File tree

8 files changed

+20
-0
lines changed

8 files changed

+20
-0
lines changed

core.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ declare namespace core {
140140
| 'chm'
141141
| '3mf'
142142
| 'zst'
143+
| 'jxl'
143144
| 'vcf';
144145

145146
type MimeType =
@@ -274,6 +275,7 @@ declare namespace core {
274275
| 'model/stl'
275276
| 'application/vnd.ms-htmlhelp'
276277
| 'model/3mf'
278+
| 'image/jxl'
277279
| 'application/zstd';
278280

279281
interface FileTypeResult {

core.js

+10
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,16 @@ async function _fromTokenizer(tokenizer) {
11621162
}
11631163
}
11641164

1165+
if (
1166+
check([0xFF, 0x0A]) ||
1167+
check([0x00, 0x00, 0x00, 0x0C, 0x4A, 0x58, 0x4C, 0x20, 0x0D, 0x0A, 0x87, 0x0A])
1168+
) {
1169+
return {
1170+
ext: 'jxl',
1171+
mime: 'image/jxl'
1172+
};
1173+
}
1174+
11651175
// -- Unsafe signatures --
11661176

11671177
if (

fixture/fixture.jxl

285 Bytes
Binary file not shown.

fixture/fixture2.jxl

26 Bytes
Binary file not shown.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@
184184
"chm",
185185
"3mf",
186186
"zst",
187+
"jxl",
187188
"vcf"
188189
],
189190
"devDependencies": {

readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ Returns a set of supported MIME types.
409409
- [`stl`](https://en.wikipedia.org/wiki/STL_(file_format)) - Standard Tesselated Geometry File Format (ASCII only)
410410
- [`chm`](https://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help) - Microsoft Compiled HTML Help
411411
- [`3mf`](https://en.wikipedia.org/wiki/3D_Manufacturing_Format) - 3D Manufacturing Format
412+
- [`jxl`](https://en.wikipedia.org/wiki/JPEG_XL) - JPEG XL image format
412413

413414
*Pull requests are welcome for additional commonly used file types.*
414415

supported.js

+2
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ module.exports = {
138138
'chm',
139139
'3mf',
140140
'zst',
141+
'jxl',
141142
'vcf'
142143
],
143144
mimeTypes: [
@@ -272,6 +273,7 @@ module.exports = {
272273
'model/stl',
273274
'application/vnd.ms-htmlhelp',
274275
'model/3mf',
276+
'image/jxl',
275277
'application/zstd'
276278
]
277279
};

test.js

+4
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ const names = {
189189
'fixture-normal', // Normal AI
190190
'fixture-without-pdf-compatibility' // AI without the PDF compatibility (cannot be opened by PDF viewers I guess)
191191
],
192+
jxl: [
193+
'fixture', // Image data stored within JXL container
194+
'fixture2' // Bare image data with no container
195+
],
192196
pdf: [
193197
'fixture',
194198
'fixture-adobe-illustrator', // PDF saved from Adobe Illustrator, using the default "[Illustrator Default]" preset

0 commit comments

Comments
 (0)