Skip to content

Commit

Permalink
Add support for ICC (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorWiecz committed Jun 4, 2023
1 parent 1759382 commit 0ccebb1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export type FileExtension =
| 'cpio'
| 'ace'
| 'avro'
| 'icc'
; // eslint-disable-line semi-style

export type MimeType =
Expand Down Expand Up @@ -298,6 +299,7 @@ export type MimeType =
| 'application/x-cpio'
| 'application/x-ace-compressed'
| 'application/avro'
| 'application/vnd.iccprofile'
; // eslint-disable-line semi-style

export type FileTypeResult = {
Expand Down
7 changes: 7 additions & 0 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,13 @@ class FileTypeParser {
// Increase sample size from 12 to 256.
await tokenizer.peekBuffer(this.buffer, {length: Math.min(256, tokenizer.fileInfo.size), mayBeLess: true});

if (this.check([0x61, 0x63, 0x73, 0x70], {offset: 36})) {
return {
ext: 'icc',
mime: 'application/vnd.iccprofile',
};
}

// -- 15-byte signatures --

if (this.checkString('BEGIN:')) {
Expand Down
Binary file added fixture/fixture.icc
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@
"arj",
"cpio",
"ace",
"avro"
"avro",
"icc"
],
"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 @@ -366,6 +366,7 @@ Returns a `Set<string>` of supported MIME types.
- [`glb`](https://github.com/KhronosGroup/glTF) - GL Transmission Format
- [`gz`](https://en.wikipedia.org/wiki/Gzip) - Archive file
- [`heic`](https://nokiatech.github.io/heif/technical.html) - High Efficiency Image File Format
- [`icc`](https://en.wikipedia.org/wiki/ICC_profile) - ICC Profile
- [`icns`](https://en.wikipedia.org/wiki/Apple_Icon_Image_format) - Apple Icon image
- [`ico`](https://en.wikipedia.org/wiki/ICO_(file_format)) - Windows icon file
- [`ics`](https://en.wikipedia.org/wiki/ICalendar#Data_format) - iCalendar
Expand Down
2 changes: 2 additions & 0 deletions supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export const extensions = [
'cpio',
'ace',
'avro',
'icc',
];

export const mimeTypes = [
Expand Down Expand Up @@ -295,4 +296,5 @@ export const mimeTypes = [
'application/x-cpio',
'application/x-ace-compressed',
'application/avro',
'application/vnd.iccprofile',
];

0 comments on commit 0ccebb1

Please sign in to comment.