1
0
mirror of https://github.com/immich-app/immich.git synced 2025-06-15 03:30:33 +02:00

feat: JPEG XL (#2893)

Support the JPEG XL format (.jxl).

JPEG XL is reported as supported by `sharp.format`:

```
jxl: {
  id: 'jxl',
  input: { file: true, buffer: true, stream: true, fileSuffix: [Array] },
  output: { file: true, buffer: true, stream: true }
}
```

Fixes: #2743
This commit is contained in:
Thomas
2023-06-21 13:29:02 +01:00
committed by GitHub
parent 868f629f32
commit 80d02e8a8d
7 changed files with 174 additions and 56 deletions

View File

@ -126,39 +126,40 @@ export function getAssetFilename(asset: AssetResponseDto): string {
*/
export function getFileMimeType(file: File): string {
const mimeTypes: Record<string, string> = {
'3fr': 'image/x-hasselblad-3fr',
'3gp': 'video/3gpp',
ari: 'image/x-arriflex-ari',
arw: 'image/x-sony-arw',
dng: 'image/dng',
heic: 'image/heic',
heif: 'image/heif',
avif: 'image/avif',
insp: 'image/jpeg',
insv: 'video/mp4',
nef: 'image/x-nikon-nef',
raf: 'image/x-fuji-raf',
srw: 'image/x-samsung-srw',
crw: 'image/x-canon-crw',
cap: 'image/x-phaseone-cap',
cin: 'image/x-phantom-cin',
cr2: 'image/x-canon-cr2',
cr3: 'image/x-canon-cr3',
erf: 'image/x-epson-erf',
crw: 'image/x-canon-crw',
dcr: 'image/x-kodak-dcr',
dng: 'image/dng',
erf: 'image/x-epson-erf',
fff: 'image/x-hasselblad-fff',
heic: 'image/heic',
heif: 'image/heif',
iiq: 'image/x-phaseone-iiq',
insp: 'image/jpeg',
insv: 'video/mp4',
jxl: 'image/jxl',
k25: 'image/x-kodak-k25',
kdc: 'image/x-kodak-kdc',
mrw: 'image/x-minolta-mrw',
nef: 'image/x-nikon-nef',
orf: 'image/x-olympus-orf',
raw: 'image/x-panasonic-raw',
pef: 'image/x-pentax-pef',
x3f: 'image/x-sigma-x3f',
srf: 'image/x-sony-srf',
sr2: 'image/x-sony-sr2',
'3fr': 'image/x-hasselblad-3fr',
fff: 'image/x-hasselblad-fff',
rwl: 'image/x-leica-rwl',
ori: 'image/x-olympus-ori',
iiq: 'image/x-phaseone-iiq',
ari: 'image/x-arriflex-ari',
cap: 'image/x-phaseone-cap',
cin: 'image/x-phantom-cin'
pef: 'image/x-pentax-pef',
raf: 'image/x-fuji-raf',
raw: 'image/x-panasonic-raw',
rwl: 'image/x-leica-rwl',
sr2: 'image/x-sony-sr2',
srf: 'image/x-sony-srf',
srw: 'image/x-samsung-srw',
x3f: 'image/x-sigma-x3f'
};
// Return the MIME type determined by the browser or the MIME type based on the file extension.
return file.type || (mimeTypes[getFilenameExtension(file.name)] ?? '');