You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-06-18 03:57:43 +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:
@ -61,16 +61,40 @@ describe('get asset filename', () => {
|
||||
|
||||
describe('get file mime type', () => {
|
||||
for (const { extension, mimeType } of [
|
||||
{ extension: '3fr', mimeType: 'image/x-hasselblad-3fr' },
|
||||
{ extension: '3gp', mimeType: 'video/3gpp' },
|
||||
{ extension: 'ari', mimeType: 'image/x-arriflex-ari' },
|
||||
{ extension: 'arw', mimeType: 'image/x-sony-arw' },
|
||||
{ extension: 'avif', mimeType: 'image/avif' },
|
||||
{ extension: 'cap', mimeType: 'image/x-phaseone-cap' },
|
||||
{ extension: 'cin', mimeType: 'image/x-phantom-cin' },
|
||||
{ extension: 'cr2', mimeType: 'image/x-canon-cr2' },
|
||||
{ extension: 'cr3', mimeType: 'image/x-canon-cr3' },
|
||||
{ extension: 'crw', mimeType: 'image/x-canon-crw' },
|
||||
{ extension: 'dcr', mimeType: 'image/x-kodak-dcr' },
|
||||
{ extension: 'dng', mimeType: 'image/dng' },
|
||||
{ extension: 'erf', mimeType: 'image/x-epson-erf' },
|
||||
{ extension: 'fff', mimeType: 'image/x-hasselblad-fff' },
|
||||
{ extension: 'heic', mimeType: 'image/heic' },
|
||||
{ extension: 'heif', mimeType: 'image/heif' },
|
||||
{ extension: 'iiq', mimeType: 'image/x-phaseone-iiq' },
|
||||
{ extension: 'insp', mimeType: 'image/jpeg' },
|
||||
{ extension: 'insv', mimeType: 'video/mp4' },
|
||||
{ extension: 'jxl', mimeType: 'image/jxl' },
|
||||
{ extension: 'k25', mimeType: 'image/x-kodak-k25' },
|
||||
{ extension: 'kdc', mimeType: 'image/x-kodak-kdc' },
|
||||
{ extension: 'mrw', mimeType: 'image/x-minolta-mrw' },
|
||||
{ extension: 'nef', mimeType: 'image/x-nikon-nef' },
|
||||
{ extension: 'orf', mimeType: 'image/x-olympus-orf' },
|
||||
{ extension: 'ori', mimeType: 'image/x-olympus-ori' },
|
||||
{ extension: 'pef', mimeType: 'image/x-pentax-pef' },
|
||||
{ extension: 'raf', mimeType: 'image/x-fuji-raf' },
|
||||
{ extension: 'srw', mimeType: 'image/x-samsung-srw' }
|
||||
{ extension: 'raw', mimeType: 'image/x-panasonic-raw' },
|
||||
{ extension: 'rwl', mimeType: 'image/x-leica-rwl' },
|
||||
{ extension: 'sr2', mimeType: 'image/x-sony-sr2' },
|
||||
{ extension: 'srf', mimeType: 'image/x-sony-srf' },
|
||||
{ extension: 'srw', mimeType: 'image/x-samsung-srw' },
|
||||
{ extension: 'x3f', mimeType: 'image/x-sigma-x3f' }
|
||||
]) {
|
||||
it(`returns the mime type for ${extension}`, () => {
|
||||
expect(getFileMimeType({ name: `filename.${extension}` } as File)).toEqual(mimeType);
|
||||
|
@ -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)] ?? '');
|
||||
|
@ -22,8 +22,46 @@ export const openFileUploadDialog = async (
|
||||
|
||||
// When adding a content type that is unsupported by browsers, make sure
|
||||
// to also add it to getFileMimeType() otherwise the upload will fail.
|
||||
fileSelector.accept =
|
||||
'image/*,video/*,.heic,.heif,.avif,.dng,.3gp,.nef,.srw,.crw,.cr2,.cr3,.raf,.insp,.insv,.arw,.erf,.raf,.dcr,.k25,.kdc,.mrw,.orf,.raw,.pef,.x3f,.srf,.sr2,.3fr,.fff,.rwl,.ori,.iiq,.ari,.cap,.cin,.mov';
|
||||
fileSelector.accept = [
|
||||
'image/*',
|
||||
'video/*',
|
||||
'.3fr',
|
||||
'.3gp',
|
||||
'.ari',
|
||||
'.arw',
|
||||
'.avif',
|
||||
'.cap',
|
||||
'.cin',
|
||||
'.cr2',
|
||||
'.cr3',
|
||||
'.crw',
|
||||
'.dcr',
|
||||
'.dng',
|
||||
'.erf',
|
||||
'.fff',
|
||||
'.heic',
|
||||
'.heif',
|
||||
'.iiq',
|
||||
'.insp',
|
||||
'.insv',
|
||||
'.jxl',
|
||||
'.k25',
|
||||
'.kdc',
|
||||
'.mov',
|
||||
'.mrw',
|
||||
'.nef',
|
||||
'.orf',
|
||||
'.ori',
|
||||
'.pef',
|
||||
'.raf',
|
||||
'.raf',
|
||||
'.raw',
|
||||
'.rwl',
|
||||
'.sr2',
|
||||
'.srf',
|
||||
'.srw',
|
||||
'.x3f'
|
||||
].join(',');
|
||||
|
||||
fileSelector.onchange = async (e: Event) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
|
Reference in New Issue
Block a user