【问题标题】:exiftool-vendored doesn't return when used in an electron app on Mac?在 Mac 上的电子应用程序中使用时 exiftool-vendred 不返回?
【发布时间】:2019-10-08 02:36:43
【问题描述】:

在 Mac 上,当我从 WebStorm 运行我的应用程序时,exiftool-vendred 运行良好。但是,当我构建我的应用程序(我使用 electron-builder)并将其安装在同一台 Mac 上时,它永远不会返回,即使只是试图获取版本:

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

换句话说,不会引发错误,并且then 在运行我的应用程序的已安装版本时永远不会执行,尽管它可以从 WebStorm 运行我的应用程序(使用 cd build && electron .

我做错了什么?有没有在电子应用程序中使用 exiftool-vendred 的示例?

【问题讨论】:

    标签: electron electron-builder exiftool


    【解决方案1】:

    你应该看看文档是如何让它与 Electron 一起工作的:

    你如何使用电子来完成这项工作?

    Electron 是出了名的脆弱和漏洞百出,并且不受此软件包的官方支持。尽管 PhotoStructure 在 electron 中使用了这个包,但该项目有大量的辅助支持代码可以使其顺利运行。

    如果您仍然急于尝试,请记住以下几点:

    1. 请注意,此软件包将生成 exiftool 外部进程,这意味着 exiftool-vendored.pl 和 exiftool-vendored.exe 软件包应包含在您的 asarUnpack 中。 SmartUnpack 可能会起作用,但如果它不使用像 node_modules/{exiftool-vendored.*}/**/* 这样的模式。

    2. 如果您需要从 web 视图中提供 exiftool-vendred,那么您会遇到麻烦。由于 electron 中缺乏节点兼容性,许多事情都无法正常工作。

    3. __dirname 在运行时从 webpacking 之后的 asar 包中将无效,所以不要依赖它。

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

    【讨论】:

    • 非常感谢!知道这真的很有帮助。希望我很久以前就看到了。
    【解决方案2】:

    由于我从未找到让exiftool-vendored 在 Mac 上与电子一起工作的方法,我接受了上述答案,本质上是一个警告,在 Mac 上避开 exiftool-vendored 电子。

    这个答案是为了完整起见,对于我们这些在 Mac 和 Windows 的电子应用程序中需要 exiftool 的人:

    我使用 node-exiftool 并在 package.json 中为电子生成器添加了这些设置:

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

    在我的项目的根目录中,我添加了文件夹exiftoolwinexiftool。在exiftoolwin 中,我放入了exiftool.exe,这是我通过遵循Windows 独立可执行指令here 获得的,在我的exiftool 文件夹中我放入了exiftoollib,这是我通过提取完整的perl 获得的如同一页所述,在 Mac 上分发。

    然后,在我的 .jsx 中(我正在使用 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);
    

    然后我就按照here 的描述使用ep

    【讨论】:

    • 非常感谢,大卫!你是救生员!
    【解决方案3】:

    这对我们有用:

    添加这个依赖:

    "exiftool-vendored": "^15.2.0",
    

    为 mac 更新 package.json "build" 部分(据我们所见,windows 不需要)

    "build": {
      "mac": {
        ...
        "asarUnpack": [
           "node_modules/exiftool-vendored/**" ,
           "node_modules/exiftool-vendored.pl/**"
        ]
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-14
      • 2020-11-15
      • 1970-01-01
      • 2017-10-22
      • 2017-07-01
      • 2020-10-29
      • 2015-11-24
      • 1970-01-01
      相关资源
      最近更新 更多