mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +00:00
fix(server): handle numeric 'Image Description' and 'Description' values (#11636)
* Made 'Image Description' and 'Description' type safe during exif parsing * add test + update types --------- Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>
This commit is contained in:
parent
5b64456f48
commit
28ba22e8c1
3 changed files with 18 additions and 2 deletions
|
@ -7,7 +7,7 @@ export interface ExifDuration {
|
||||||
Scale?: number;
|
Scale?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ImmichTags extends Omit<Tags, 'FocalLength' | 'Duration'> {
|
export interface ImmichTags extends Omit<Tags, 'FocalLength' | 'Duration' | 'Description' | 'ImageDescription'> {
|
||||||
ContentIdentifier?: string;
|
ContentIdentifier?: string;
|
||||||
MotionPhoto?: number;
|
MotionPhoto?: number;
|
||||||
MotionPhotoVersion?: number;
|
MotionPhotoVersion?: number;
|
||||||
|
@ -19,6 +19,10 @@ export interface ImmichTags extends Omit<Tags, 'FocalLength' | 'Duration'> {
|
||||||
EmbeddedVideoType?: string;
|
EmbeddedVideoType?: string;
|
||||||
EmbeddedVideoFile?: BinaryField;
|
EmbeddedVideoFile?: BinaryField;
|
||||||
MotionPhotoVideo?: BinaryField;
|
MotionPhotoVideo?: BinaryField;
|
||||||
|
|
||||||
|
// Type is wrong, can also be number.
|
||||||
|
Description?: string | number;
|
||||||
|
ImageDescription?: string | number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IMetadataRepository {
|
export interface IMetadataRepository {
|
||||||
|
|
|
@ -753,6 +753,18 @@ describe(MetadataService.name, () => {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('handles a numeric description', async () => {
|
||||||
|
assetMock.getByIds.mockResolvedValue([assetStub.image]);
|
||||||
|
metadataMock.readTags.mockResolvedValue({ Description: 1000 });
|
||||||
|
|
||||||
|
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||||
|
expect(assetMock.upsertExif).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
description: '1000',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('handleQueueSidecar', () => {
|
describe('handleQueueSidecar', () => {
|
||||||
|
|
|
@ -482,7 +482,7 @@ export class MetadataService implements OnEvents {
|
||||||
bitsPerSample: this.getBitsPerSample(tags),
|
bitsPerSample: this.getBitsPerSample(tags),
|
||||||
colorspace: tags.ColorSpace ?? null,
|
colorspace: tags.ColorSpace ?? null,
|
||||||
dateTimeOriginal: this.getDateTimeOriginal(tags) ?? asset.fileCreatedAt,
|
dateTimeOriginal: this.getDateTimeOriginal(tags) ?? asset.fileCreatedAt,
|
||||||
description: (tags.ImageDescription || tags.Description || '').trim(),
|
description: String(tags.ImageDescription || tags.Description || '').trim(),
|
||||||
exifImageHeight: validate(tags.ImageHeight),
|
exifImageHeight: validate(tags.ImageHeight),
|
||||||
exifImageWidth: validate(tags.ImageWidth),
|
exifImageWidth: validate(tags.ImageWidth),
|
||||||
exposureTime: tags.ExposureTime ?? null,
|
exposureTime: tags.ExposureTime ?? null,
|
||||||
|
|
Loading…
Reference in a new issue