【问题标题】:Deconstructing piped (exiftool & imagemagick) bash command into individual commands将管道(exiftool 和 imagemagick)bash 命令解构为单个命令
【发布时间】:2020-12-07 23:00:35
【问题描述】:

我有一个可以从图像中提取原始数据的工作 bash 脚本。我正在将此脚本转换为 JS (node.js),并且无法将管道命令转换为其组件以转换为 javascript。 exiftool 命令有效(据我所知,错误发生在第一个转换函数。

工作 bash 管道:

exiftool $F -b -RawThermalImage | convert - gray:- | convert -depth 16 -endian lsb -size $Resolution gray:- $F-RAW.tiff

当前(不工作)javascript:

const execFile = require('child_process').execFile;
const exiftool = require('dist-exiftool');
const im = require('imagemagick');

execFile(exiftool, ['file.jpg', '-b', '-RawThermalImage', '-w', '-raw.jpg'], (error) => {
    if (err) throw "Error extracting RawThermalImage. Unsupported filetype.";

    im.convert(['file-raw.jpg', 'gray', 'file-raw.jpg'], function(err, stdout){
        if (err) throw err;
        console.log('stdout:', stdout);

        im.convert(['file-raw.jpg', '-depth', '16', 'endian', 'lsb', '-size', resolution, 'gray', 'file-raw.jpg'], function(err, stdout){
            if (err) throw err;
            console.log('stdout:', stdout);
        });
    });
});

【问题讨论】:

  • 在第二个命令中,尝试 `im.convert(['raw-file.jpg', 'gray:raw-file.gray']... 然后将 raw-file.gray 传递给您的第三个命令。见灰色imagemagick.org/script/formats.php#supported
  • @fmw42 不幸的是,虽然命令 convert raw.tiff gray:raw.gray 在命令行上工作,但 im.convert(['raw.tiff', 'raw.gray']... im.convert(['raw.tiff', 'gray:-']... 在节点中对我来说都失败了
  • im.convert(['raw.tiff', 'gray:raw.gray']... 也失败了
  • 对不起,我不知道 Node.js。所以我无能为力了

标签: node.js bash imagemagick exiftool


【解决方案1】:

我的问题是 Azure 而不是 Nodejs。 im.convert(['raw.tiff', 'gray:raw.gray']... 完美运行。对于遇到 Azure imagemagick 无法正常工作的问题的任何人,在 Azure 函数中工作的唯一发行版是 here。感谢@fmw42

【讨论】:

    猜你喜欢
    • 2016-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-03
    • 1970-01-01
    • 2014-06-07
    • 2017-06-03
    • 2012-06-18
    相关资源
    最近更新 更多