refactor: move ExifFields to class

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/888/head
Varun Patil 2023-10-22 12:40:25 -07:00
parent cd2743764d
commit 8b2df7c2a5
3 changed files with 87 additions and 84 deletions

View File

@ -0,0 +1,86 @@
<?php
declare(strict_types=1);
namespace OCA\Memories\Db;
class ExifFields
{
/**
* This is the list of fields that will be STORED in the databse as JSON.
* This is mostly only used for the metadata view.
*/
public const EXIF_FIELDS_LIST = [
// Date/Time
'DateTimeOriginal' => true,
'CreateDate' => true,
'OffsetTimeOriginal' => true,
'OffsetTime' => true,
// Generated date fields
'DateTimeEpoch' => true,
'LocationTZID' => true,
// Camera Info
'Make' => true,
'Model' => true,
'LensModel' => true,
'CameraType' => true,
'AutoRotate' => true,
'SerialNumber' => true,
// Photo Info
'FNumber' => true,
'ApertureValue' => true,
'FocalLength' => true,
'ISO' => true,
'ShutterSpeedValue' => true,
'ShutterSpeed' => true,
'ExposureTime' => true,
'WhiteBalance' => true,
'Sharpness' => true,
'ColorTemperature' => true,
'HDR' => true,
'HDREffect' => true,
'ColorSpace' => true,
'Aperture' => true,
'ImageUniqueID' => true,
// GPS info
'GPSLatitude' => true,
'GPSLongitude' => true,
'GPSAltitude' => true,
'GPSTimeStamp' => true,
'GPSStatus' => true,
// Size / rotation info
'Megapixels' => true,
'Rotation' => true,
'Orientation' => true,
// Editable Metadata
'Title' => true,
'Description' => true,
'Label' => true,
'Artist' => true,
'Copyright' => true,
// Other image info
'Rating' => true,
'NumberOfImages' => true,
'FlashType' => true,
'RedEyeReduction' => true,
'CircleOfConfusion' => true,
'DOF' => true,
'FOV' => true,
// Currently unused fields
'ExifVersion' => true,
// Video info
'Duration' => true,
'FrameRate' => true,
'TrackDuration' => true,
'VideoCodec' => true,
];
}

View File

@ -11,8 +11,6 @@ use OCP\Files\File;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\Lock\ILockingProvider; use OCP\Lock\ILockingProvider;
require_once __DIR__.'/../ExifFields.php';
const DELETE_TABLES = ['memories', 'memories_livephoto', 'memories_places']; const DELETE_TABLES = ['memories', 'memories_livephoto', 'memories_places'];
const TRUNCATE_TABLES = ['memories_mapclusters']; const TRUNCATE_TABLES = ['memories_mapclusters'];
@ -290,7 +288,7 @@ class TimelineWrite
} }
// Only keep fields in the whitelist // Only keep fields in the whitelist
if (\array_key_exists($key, EXIF_FIELDS_LIST)) { if (\array_key_exists($key, ExifFields::EXIF_FIELDS_LIST)) {
$filteredExif[$key] = $value; $filteredExif[$key] = $value;
} }
} }

View File

@ -1,81 +0,0 @@
<?php
declare(strict_types=1);
/**
* This is the list of fields that will be STORED in the databse as JSON.
* This is mostly only used for the metadata view.
*/
const EXIF_FIELDS_LIST = [
// Date/Time
'DateTimeOriginal' => true,
'CreateDate' => true,
'OffsetTimeOriginal' => true,
'OffsetTime' => true,
// Generated date fields
'DateTimeEpoch' => true,
'LocationTZID' => true,
// Camera Info
'Make' => true,
'Model' => true,
'LensModel' => true,
'CameraType' => true,
'AutoRotate' => true,
'SerialNumber' => true,
// Photo Info
'FNumber' => true,
'ApertureValue' => true,
'FocalLength' => true,
'ISO' => true,
'ShutterSpeedValue' => true,
'ShutterSpeed' => true,
'ExposureTime' => true,
'WhiteBalance' => true,
'Sharpness' => true,
'ColorTemperature' => true,
'HDR' => true,
'HDREffect' => true,
'ColorSpace' => true,
'Aperture' => true,
'ImageUniqueID' => true,
// GPS info
'GPSLatitude' => true,
'GPSLongitude' => true,
'GPSAltitude' => true,
'GPSTimeStamp' => true,
'GPSStatus' => true,
// Size / rotation info
'Megapixels' => true,
'Rotation' => true,
'Orientation' => true,
// Editable Metadata
'Title' => true,
'Description' => true,
'Label' => true,
'Artist' => true,
'Copyright' => true,
// Other image info
'Rating' => true,
'NumberOfImages' => true,
'FlashType' => true,
'RedEyeReduction' => true,
'CircleOfConfusion' => true,
'DOF' => true,
'FOV' => true,
// Currently unused fields
'ExifVersion' => true,
// Video info
'Duration' => true,
'FrameRate' => true,
'TrackDuration' => true,
'VideoCodec' => true,
];