Skip to content

Commit

Permalink
✨ Return undefined for EXIF fields without values
Browse files Browse the repository at this point in the history
  • Loading branch information
leolabs committed Mar 11, 2021
1 parent d40cd7a commit eca361e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const processFile = async (file: fs.WalkEntry) => {
const newExifValues: string[] = [];

// Fix missing timestamps with information from Google Photos
if (exifData.dateTimeOriginal === "-" && exifData.createDate === "-") {
if (!exifData.dateTimeOriginal && !exifData.createDate) {
const newDate = formatDate(
Date.parse(metadata.photoTakenTime.formatted),
"yyyy-MM-dd HH:mm:ss",
Expand All @@ -166,8 +166,8 @@ const processFile = async (file: fs.WalkEntry) => {

// Add missing GPS information
if (
exifData.gpsLatutide === "-" &&
exifData.gpsLongitude === "-" &&
!exifData.gpsLatutide &&
!exifData.gpsLongitude &&
metadata.geoData.latitude
) {
args.verbose && log("Adding GPS data");
Expand Down
2 changes: 1 addition & 1 deletion util/exif.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const getExifData = async (path: string) => {
gpsLatutide,
gpsLongitude,
gpsAltitude,
] = exifData.split("\t");
] = exifData.split("\t").map((d) => (d === "-" ? undefined : d));

return {
dateTimeOriginal,
Expand Down

0 comments on commit eca361e

Please sign in to comment.