2

On Mac, when I run my app from WebStorm, exiftool-vendored works great. However, when I build my app (I use electron-builder) and install it on the same Mac, it never returns, even just trying to get the version:

exiftool.version().then(version => writeBreadcrumb('exif', version))

In other words, no error is raised, and the then is never executed when running an installed version of my app, though it works fine running my app from WebStorm (with cd build && electron .)

What am I doing wrong? Is there an example anywhere of how to use exiftool-vendored in an electron app?

David Burson
  • 2,947
  • 7
  • 32
  • 55

3 Answers3

3

You should take a look at what the docs say about making it work with Electron:

How do you make this work with electron?

Electron is notoriously brittle and buggy, and is not officially supported by this package. Although PhotoStructure uses this package within electron, there's a nontrivial amount of auxiliary support code specific to that project to make it work smoothly.

If you're still anxious to try, here are some things to keep in mind:

  1. Note that this package will spawn exiftool external processes, which means the exiftool-vendored.pl and exiftool-vendored.exe packages should be included in your asarUnpack. SmartUnpack might work, but if it doesn't use a pattern like node_modules/{exiftool-vendored.*}/**/*.

  2. If you're requiring exiftool-vendored from within a webview, you're gonna have a bad time. Many things won't work due to a lack of node compatibility within electron.

  3. __dirname at runtime from within an asar package after webpacking will be invalid, so don't rely on that.

https://github.com/photostructure/exiftool-vendored.js/wiki/FAQ#how-do-you-make-this-work-with-electron

Community
  • 1
  • 1
Daniel
  • 10,641
  • 12
  • 47
  • 85
3

Since I never found a way to get exiftool-vendored to work with electron on Mac, I accepted the above answer, as essentially a warning to steer clear of exiftool-vendored for electron on Mac.

This answer is included for completeness, for those of us who need exiftool in an electron app for both Mac and Windows:

I used node-exiftool with these settings added in package.json for electron-builder:

"build": {
  ...
  "win": {
    ...
    "extraResources": "exiftoolwin/**/*"
  },
  "mac": {
    ...
    "extraResources": "exiftool/**/*"
  }
}

In the root of my project, I added folders exiftoolwin and exiftool. In exiftoolwin, I put exiftool.exe which I obtained by following the Windows Stand-Alone Executable instructions here, and in my exiftool folder I put exiftool and lib which I obtained by extracting the full perl distribution on Mac, as described on the same page.

Then, in my .jsx (I'm using React):

import exiftool from 'node-exiftool';
const exiftoolFolderAndFile = process.platform === 'win32' ? 'exiftoolwin/exiftool.exe' : 'exiftool/exiftool';
const exiftoolPath = path.resolve(__dirname, '../..', exiftoolFolderAndFile);
const ep = new exiftool.ExiftoolProcess(exiftoolPath);

Then I just use ep as described here.

StarGeek
  • 4,948
  • 2
  • 19
  • 30
David Burson
  • 2,947
  • 7
  • 32
  • 55
1

This is working for us:

add this dependency:

"exiftool-vendored": "^15.2.0",

Update package.json "build" section for mac ( not needed for windows as far as we can see )

"build": {
  "mac": {
    ...
    "asarUnpack": [
       "node_modules/exiftool-vendored/**" ,
       "node_modules/exiftool-vendored.pl/**"
    ]
  }
}
Maayan Hope
  • 1,482
  • 17
  • 32