mirror of
https://github.com/immich-app/immich.git
synced 2025-12-06 09:13:13 +03:00
fix: exif gps parsing of malformed data (#23551)
* fix: exif gps parsing of malformed data * chore: e2e test
This commit is contained in:
@@ -1140,6 +1140,16 @@ describe('/asset', () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
input: 'metadata/gps-position/empty_gps.jpg',
|
||||
expected: {
|
||||
type: AssetTypeEnum.Image,
|
||||
exifInfo: {
|
||||
latitude: null,
|
||||
longitude: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
it.each(tests)(`should upload and generate a thumbnail for different file types`, async ({ input, expected }) => {
|
||||
|
||||
Submodule e2e/test-assets updated: 37f60ea537...68e8b5853c
@@ -236,8 +236,8 @@ export class MetadataService extends BaseService {
|
||||
latitude: number | null = null,
|
||||
longitude: number | null = null;
|
||||
if (this.hasGeo(exifTags)) {
|
||||
latitude = exifTags.GPSLatitude;
|
||||
longitude = exifTags.GPSLongitude;
|
||||
latitude = Number(exifTags.GPSLatitude);
|
||||
longitude = Number(exifTags.GPSLongitude);
|
||||
if (reverseGeocoding.enabled) {
|
||||
geo = await this.mapRepository.reverseGeocode({ latitude, longitude });
|
||||
}
|
||||
@@ -894,12 +894,10 @@ export class MetadataService extends BaseService {
|
||||
};
|
||||
}
|
||||
|
||||
private hasGeo(tags: ImmichTags): tags is ImmichTags & { GPSLatitude: number; GPSLongitude: number } {
|
||||
return (
|
||||
tags.GPSLatitude !== undefined &&
|
||||
tags.GPSLongitude !== undefined &&
|
||||
(tags.GPSLatitude !== 0 || tags.GPSLatitude !== 0)
|
||||
);
|
||||
private hasGeo(tags: ImmichTags) {
|
||||
const lat = Number(tags.GPSLatitude);
|
||||
const lng = Number(tags.GPSLongitude);
|
||||
return !Number.isNaN(lat) && !Number.isNaN(lng) && (lat !== 0 || lng !== 0);
|
||||
}
|
||||
|
||||
private getAutoStackId(tags: ImmichTags | null): string | null {
|
||||
|
||||
Reference in New Issue
Block a user