Tie together
This commit is contained in:
@@ -57,7 +57,13 @@ export interface Metadata {
|
||||
* See: [Note: File name for local EnteFile objects]
|
||||
*/
|
||||
title: string;
|
||||
creationTime: number;
|
||||
/**
|
||||
* The time when this file was created.
|
||||
*
|
||||
* For photos (and images in general), this is the time when the photo was
|
||||
* taken, or when the screenshot was captured.
|
||||
*/
|
||||
creationTime: number | undefined;
|
||||
modificationTime: number;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
|
||||
@@ -41,8 +41,21 @@ interface ParsedMetadata {
|
||||
*
|
||||
* The library we use is https://github.com/mattiasw/ExifReader.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
export const extractExif = () => {};
|
||||
export const extractMetadata = async (file: File) => {
|
||||
const tags = await ExifReader.load(await file.arrayBuffer(), {
|
||||
async: true,
|
||||
expanded: true,
|
||||
});
|
||||
|
||||
const location = parseLocation(tags);
|
||||
const creationDate = parseCreationDate(tags);
|
||||
const dimensions = parseDimensions(tags);
|
||||
|
||||
const metadata: ParsedMetadata = dimensions ?? {};
|
||||
if (creationDate) metadata.creationTime = creationDate.getTime() * 1000;
|
||||
if (location) metadata.location = location;
|
||||
return metadata;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse a single "best" creation date for an image from the metadata embedded
|
||||
@@ -472,14 +485,13 @@ export const indexExif = async (enteFile: EnteFile, blob: Blob) => {
|
||||
};
|
||||
|
||||
const backfill = (enteFile: EnteFile, tags: ExifReader.ExpandedTags) => {
|
||||
// const date =
|
||||
// TODO:Exif: Testing
|
||||
const location = parseLocation(tags);
|
||||
const creationDate = parseCreationDate(tags);
|
||||
const dimensions = parseDimensions(tags);
|
||||
const metadata: ParsedMetadata = dimensions ?? {};
|
||||
if (creationDate) metadata.creationTime = creationDate.getTime() * 1000;
|
||||
if (location) metadata.location = location;
|
||||
console.log(enteFile, metadata);
|
||||
return metadata;
|
||||
if (!creationDate) return;
|
||||
|
||||
const creationTime = creationDate.getTime() * 1000;
|
||||
|
||||
if (enteFile.metadata.creationTime == creationTime) return;
|
||||
|
||||
// TODO: Exif: backfill
|
||||
console.log(enteFile, creationTime);
|
||||
};
|
||||
|
||||
@@ -68,7 +68,9 @@ const sortTrashFiles = (files: EnteFile[]) => {
|
||||
b.metadata.modificationTime - a.metadata.modificationTime
|
||||
);
|
||||
}
|
||||
return b.metadata.creationTime - a.metadata.creationTime;
|
||||
return (
|
||||
(b.metadata.creationTime ?? 0) - (a.metadata.creationTime ?? 0)
|
||||
);
|
||||
}
|
||||
return (a.deleteBy ?? 0) - (b.deleteBy ?? 0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user