1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-23 01:27:14 +02:00

Merge branch 'feature/camera-metadata' of https://github.com/grasdk/pigallery2

This commit is contained in:
gras 2024-04-04 23:34:48 +02:00
commit ac56bff769
4 changed files with 62 additions and 18 deletions

View File

@ -418,18 +418,13 @@ export class MetadataLoader {
private static mapCameraData(metadata: PhotoMetadata, exif: any) {
metadata.cameraData = metadata.cameraData || {};
if (exif.ifd0) {
if (exif.ifd0.Make && exif.ifd0.Make !== '') {
metadata.cameraData.make = '' + exif.ifd0.Make;
}
if (exif.ifd0.Model && exif.ifd0.Model !== '') {
metadata.cameraData.model = '' + exif.ifd0.Model;
}
}
metadata.cameraData.make = exif.ifd0?.Make || exif.tiff?.Make || metadata.cameraData.make;
metadata.cameraData.model = exif.ifd0?.Model || exif.tiff?.Model || metadata.cameraData.model;
metadata.cameraData.lens = exif.exif?.LensModel || exif.exifEX?.LensModel || metadata.cameraData.lens;
if (exif.exif) {
if (exif.exif.LensModel && exif.exif.LensModel !== '') {
metadata.cameraData.lens = '' + exif.exif.LensModel;
}
if (Utils.isUInt32(exif.exif.ISO)) {
metadata.cameraData.ISO = parseInt('' + exif.exif.ISO, 10);
}
@ -449,6 +444,7 @@ export class MetadataLoader {
);
}
}
Utils.removeNullOrEmptyObj(metadata.cameraData);
if (Object.keys(metadata.cameraData).length === 0) {
delete metadata.cameraData;
}
@ -473,13 +469,8 @@ export class MetadataLoader {
} catch (err) {
Logger.error(LOG_TAG, 'Error during reading of GPS data: ' + err);
} finally {
if (metadata.positionData?.GPSData &&
(Object.keys(metadata.positionData.GPSData).length === 0 ||
metadata.positionData.GPSData.longitude === undefined ||
metadata.positionData.GPSData.latitude === undefined)) {
delete metadata.positionData.GPSData;
}
if (metadata.positionData) {
Utils.removeNullOrEmptyObj(metadata.positionData);
if (Object.keys(metadata.positionData).length === 0) {
delete metadata.positionData;
}

View File

@ -35,7 +35,7 @@ export class Utils {
delete obj[key];
}
}
} else if (obj[key] === null) {
} else if (obj[key] === null || obj[key] === undefined) {
delete obj[key];
}
}

View File

@ -0,0 +1,37 @@
{
"size": {
"width": 10,
"height": 5
},
"caption": "Description of image",
"creationDate": 328817998000,
"faces": [
{
"box": {
"height": 1,
"left": 6,
"top": 2,
"width": 2
},
"name": "Person1"
},
{
"box": {
"height": 2,
"left": 2,
"top": 1,
"width": 2
},
"name": "Person2"
}
],
"fileSize": 1430,
"keywords": [
"Thing3"
],
"title": "The title",
"cameraData": {
"make": "Cam Make",
"model": "Cam Model"
}
}

View File

@ -0,0 +1,16 @@
{
"size": {
"width": 10,
"height": 5
},
"creationDate": 1185683698000,
"creationDateOffset": "+13:45",
"fileSize": 1430,
"keywords": ["Person 1", "Person 2"],
"caption": "XMP description",
"title": "Photoshop Headline",
"cameraData": {
"make": "CamMake",
"model": "CamModel"
}
}