Show EXIF metadata of pictures in DT?

But there is:

(() => {
  const app = Application("DEVONthink 3")
  const IE = Application('Image Events');
  app.includeStandardAdditions = true;
  const recs = app.selectedRecords();
  // Loop over all selected records
  recs.forEach(r => {
   // Get path of current record
    const p = r.path();
   // Skip over every record that's not a jpeg image
    if (!(r.type() === 'picture' && /\.jpe?g$/i.test(r.path()))) 
      return;
    // Open the file as an image
    const image = IE.open(p);
    // Get the image's metadata
    const metaData = image.metadataTags();
    // Loop over the metadata
    metaData.forEach(m => {
      // If the current metadata is 'creation', get its value and
      // convert to a JS date
      if (m.name() === 'creation') {
        const rawDate = m.value().replace(/(\d{4}):(\d\d):(\d\d) /,"$1-$2-$3T");
// OPTIONAL (remove comments!): set record's creation date to date of image.
        // r.creationDate = new Date(rawDate);
      }
    })
    IE.close(image, {saving: 'no'});
  })
})()

This works for some image data (notably the creation date), but not for all EXIF data.

These solutions rely on external libraries that are not easy to import into JXA scripts. It should be possible to use a pure JXA solution based on the NSImage framework, but I don’t have the time to investigate that right now.

As you said, an alternative might be to script GraphicsConverter (if that’s already installed) or simply shell-script exiftool.

3 Likes