Skip to content

Commit

Permalink
Refactored to use the async exif method
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Bea committed Mar 27, 2019
1 parent f6e5e43 commit 9f06251
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions lib/modules/apostrophe-attachments/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,29 @@ module.exports = function(self, options) {
}

if (info.extension === 'jpg') {
const data = exif.parseSync(file.path);
console.log(data);
info.description = data.ImageDescription ? data.ImageDescription.trim() : null;

if (data.Make && data.Model) {
info.camera = data.Make.trim() + ' ' + data.Model.trim();
} else if (data.Model) {
info.camera = data.Model.trim();
}

info.captureDate = data.DateTime ? data.DateTime : null;
info.credit = data.Copyright ? data.Copyright.trim() : null;
exif.parse(file.path, (err, exifData) => {
if (err) {
console.log(err);
} else {

const data = exifData;
info.description = data.ImageDescription ? data.ImageDescription.trim() : null;

if (data.Make && data.Model) {
info.camera = data.Make.trim() + ' ' + data.Model.trim();
} else if (data.Model) {
info.camera = data.Model.trim();
}

info.captureDate = data.DateTime ? data.DateTime : null;
info.credit = data.Copyright ? data.Copyright.trim() : null;
}

return callback(null);
});
} else {
return callback(null);
}

return callback(null);
});
} else {
// For non-image files we have to trust the file extension
Expand Down

0 comments on commit 9f06251

Please sign in to comment.