mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
fix: metadata extraction as LensModel can be a float (#30512)
This commit is contained in:
parent
46c42e0935
commit
0d7147dcec
3 changed files with 27 additions and 2 deletions
|
|
@ -20,7 +20,8 @@ type TagsWithWrongTypes =
|
|||
| 'TagsList'
|
||||
| 'Keywords'
|
||||
| 'HierarchicalSubject'
|
||||
| 'ISO';
|
||||
| 'ISO'
|
||||
| 'LensModel';
|
||||
|
||||
export interface ImmichTags extends Omit<Tags, TagsWithWrongTypes> {
|
||||
ContentIdentifier?: string;
|
||||
|
|
@ -43,6 +44,9 @@ export interface ImmichTags extends Omit<Tags, TagsWithWrongTypes> {
|
|||
Description?: StringOrNumber;
|
||||
ImageDescription?: StringOrNumber;
|
||||
|
||||
// Apparently LensModel can also be a float: https://github.com/immich-app/immich/issues/30492
|
||||
LensModel?: StringOrNumber;
|
||||
|
||||
// Extended properties for image regions, such as faces
|
||||
RegionInfo?: {
|
||||
AppliedToDimensions: {
|
||||
|
|
|
|||
|
|
@ -117,7 +117,9 @@ const validateRange = (value: number | undefined, min: number, max: number): Non
|
|||
};
|
||||
|
||||
const getLensModel = (exifTags: ImmichTags): string | null => {
|
||||
const lensModel = (exifTags.LensID ?? exifTags.LensType ?? exifTags.LensSpec ?? exifTags.LensModel ?? '').trim();
|
||||
const lensModel = String(
|
||||
exifTags.LensID ?? exifTags.LensType ?? exifTags.LensSpec ?? exifTags.LensModel ?? '',
|
||||
).trim();
|
||||
if (lensModel === '----') {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,4 +152,23 @@ describe(MetadataService.name, () => {
|
|||
).resolves.toEqual({ dateTimeOriginal: new Date('4260-03-05T04:04:12.000Z') });
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle float lens models (#30492)', async () => {
|
||||
const { sut, ctx } = setup();
|
||||
ctx.getMock(EventRepository).emit.mockResolvedValue();
|
||||
const { filePath } = await createTestFile({ LensModel: 1.8 });
|
||||
const { user } = await ctx.newUser();
|
||||
const { asset } = await ctx.newAsset({ originalPath: filePath, ownerId: user.id });
|
||||
await ctx.newExif({ assetId: asset.id, description: '' });
|
||||
|
||||
await sut.handleMetadataExtraction({ id: asset.id });
|
||||
|
||||
await expect(
|
||||
ctx.database
|
||||
.selectFrom('asset_exif')
|
||||
.where('assetId', '=', asset.id)
|
||||
.select('lensModel')
|
||||
.executeTakeFirstOrThrow(),
|
||||
).resolves.toEqual({ lensModel: '1.8' });
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue