mirror of
https://github.com/immich-app/immich.git
synced 2024-11-27 09:21:05 +02: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
@ -7,7 +7,7 @@ export interface ExifDuration {
|
||||
Scale?: number;
|
||||
}
|
||||
|
||||
export interface ImmichTags extends Omit<Tags, 'FocalLength' | 'Duration'> {
|
||||
export interface ImmichTags extends Omit<Tags, 'FocalLength' | 'Duration' | 'Description' | 'ImageDescription'> {
|
||||
ContentIdentifier?: string;
|
||||
MotionPhoto?: number;
|
||||
MotionPhotoVersion?: number;
|
||||
@ -19,6 +19,10 @@ export interface ImmichTags extends Omit<Tags, 'FocalLength' | 'Duration'> {
|
||||
EmbeddedVideoType?: string;
|
||||
EmbeddedVideoFile?: BinaryField;
|
||||
MotionPhotoVideo?: BinaryField;
|
||||
|
||||
// Type is wrong, can also be number.
|
||||
Description?: string | number;
|
||||
ImageDescription?: string | number;
|
||||
}
|
||||
|
||||
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', () => {
|
||||
|
@ -482,7 +482,7 @@ export class MetadataService implements OnEvents {
|
||||
bitsPerSample: this.getBitsPerSample(tags),
|
||||
colorspace: tags.ColorSpace ?? null,
|
||||
dateTimeOriginal: this.getDateTimeOriginal(tags) ?? asset.fileCreatedAt,
|
||||
description: (tags.ImageDescription || tags.Description || '').trim(),
|
||||
description: String(tags.ImageDescription || tags.Description || '').trim(),
|
||||
exifImageHeight: validate(tags.ImageHeight),
|
||||
exifImageWidth: validate(tags.ImageWidth),
|
||||
exposureTime: tags.ExposureTime ?? null,
|
||||
|
Loading…
Reference in New Issue
Block a user