π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Dates
Manav Rathi47ded8b302d9
diff --git a/web/packages/new/photos/services/exif.ts b/web/packages/new/photos/services/exif.tsindex 19b6c787c3..5b5f15f423 100644--- a/web/packages/new/photos/services/exif.ts+++ b/web/packages/new/photos/services/exif.ts@@ -67,10 +67,7 @@ interface ExtractedExif {* The library we use is https://github.com/mattiasw/ExifReader.*/export const extractExif = async (file: File) => {- const tags = await ExifReader.load(await file.arrayBuffer(), {- async: true,- expanded: true,- });+ const tags = await extractTags(file);const location = parseLocation(tags);const creationDate = parseCreationDate(tags);@@ -82,6 +79,14 @@ export const extractExif = async (file: File) => {return metadata;};+const extractTags = async (blob: Blob) => {+ // See: [Note: Definining "raw" Exif] for the choice of options.+ return await ExifReader.load(await blob.arrayBuffer(), {+ async: true,+ expanded: true,+ });+};+/*** Parse a single "best" creation date for an image from the metadata embedded* in the file.@@ -96,6 +101,27 @@ const parseCreationDate = (tags: ExifReader.ExpandedTags) => {return DateTimeOriginal ?? DateTimeDigitized ?? MetadataDate ?? DateTime;};+/**+ * Dates extracted from the Exif and other metadata embedded in a file.+ *+ * These are the dates corresponding to the various options we show to the user+ * for the "Fix date" functionality. These don't come solely from the Exif but+ * from all forms of metadata we support (Exif, XMP, IPTC). They roughly+ * correspond to the three Exif DateTime* tags, and the XMP MetadataDate tag.+ */+interface ExtractedExifDates {+ DateTimeOriginal: Date | undefined;+ DateTimeDigitized: Date | undefined;+ DateTime: Date | undefined;+ MetadataDate: Date | undefined;+}++/**+ * Extract dates from Exif and other metadata for the given file.+ */+export const extractExifDates = (file: File): Promise<ExtractedExifDates> =>+ extractTags(file).then(parseDates);+/*** Parse all date related fields from the metadata embedded in the file,* grouping them into chunks that somewhat reflect the Exif ontology.@@ -123,8 +149,8 @@ const parseDates = (tags: ExifReader.ExpandedTags) => {valid(iptc.DateTimeDigitized) ??valid(exif.DateTimeDigitized) ??valid(xmp.CreateDate),- MetadataDate: valid(xmp.MetadataDate),DateTime: valid(xmp.DateTime ?? exif.DateTime ?? xmp.ModifyDate),+ MetadataDate: valid(xmp.MetadataDate),};};@@ -469,10 +495,7 @@ const parseXMPNum = (xmpTag: ExifReader.XmpTag | undefined) => {* to know about ExifReader specifically.*/export const extractRawExif = async (blob: Blob) => {- const tags = await ExifReader.load(await blob.arrayBuffer(), {- async: true,- expanded: true,- });+ const tags = await extractTags(blob);// Remove the embedded thumbnail (if any).delete tags.Thumbnail;