Tiff 转换为 png 节点 js
Tiff convert to png Node js
我必须将多个 tiff 转换为 png。例如,包含 3 页的 tiff 我应该转换为 3 png's.So 我正在使用 tiff-to-png 模块,我遇到了这个问题。
错误:命令失败:转换 /tiffs/one.tiff -scene 1 ./png/one/page%d.png
无效参数 - /tiffs.Bellow 是我的代码
'use strict'
const tiff_to_png=require('tiff-to-png');
const options={
logLevel:1
};
const converter=new tiff_to_png(options);
const tiffsLocation=['./tiffs/one.tiff'];
const location='./png';
converter.convertArray(tiffsLocation,location);
在错误上下文中,我们看到 -/tiffs inavliiad 参数。
tiffsLocation 是包含我的 tiff 文件的变量。
location 是变量,其中包含将转换为 png 文件的文件夹路径。
我不明白为什么我会收到这个错误,在这种情况下,tiffs 是包含我的 tiff 文件的目录为什么我有这个 error.Any 想法?
1st 你必须安装“Imagemagick”
对于windows,您会找到.exe 文件。请记住,在安装时,检查 "Install legacy utilities (e.g: convert)"
对于Ubuntu:
sudo apt install imagemagick
- 分 OS:
sudo yum install ImageMagick
var fs=require('fs');
var spawn = require('child_process').spawn;
//ifile: Tiff Absolute File Path
//ofile: PNG Absolute File Path (e.g: var ofile = APP_ROOT_PATH+'/data/files/png/sample.png';)
var tiff2png = spawn('convert', [ifile, ofile]);
tiff2png.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
tiff2png.stderr.on('data', function (data) {
return res.json(Utility.output('Unable to convert tiff to png','ERROR'));
console.log('stderr: ' + data);
});
tiff2png.on('close', function (code) {
/**Check Your Converted file exist or not. If exist then Converted**/
console.log('Close: ' + data);
});
tiff2png.on('error', function (code) {
return res.json(Utility.output('ERROR: Unable to convert tiff to png','ERROR'));
});
我找到了 2 个这样做的库:
最后我选择了 sharp,因为 jimp 无法处理 16 位图像
我必须将多个 tiff 转换为 png。例如,包含 3 页的 tiff 我应该转换为 3 png's.So 我正在使用 tiff-to-png 模块,我遇到了这个问题。 错误:命令失败:转换 /tiffs/one.tiff -scene 1 ./png/one/page%d.png 无效参数 - /tiffs.Bellow 是我的代码
'use strict'
const tiff_to_png=require('tiff-to-png');
const options={
logLevel:1
};
const converter=new tiff_to_png(options);
const tiffsLocation=['./tiffs/one.tiff'];
const location='./png';
converter.convertArray(tiffsLocation,location);
在错误上下文中,我们看到 -/tiffs inavliiad 参数。
tiffsLocation 是包含我的 tiff 文件的变量。
location 是变量,其中包含将转换为 png 文件的文件夹路径。
我不明白为什么我会收到这个错误,在这种情况下,tiffs 是包含我的 tiff 文件的目录为什么我有这个 error.Any 想法?
1st 你必须安装“Imagemagick”
对于windows,您会找到.exe 文件。请记住,在安装时,检查 "Install legacy utilities (e.g: convert)"
对于Ubuntu:
sudo apt install imagemagick
- 分 OS:
sudo yum install ImageMagick
var fs=require('fs');
var spawn = require('child_process').spawn;
//ifile: Tiff Absolute File Path
//ofile: PNG Absolute File Path (e.g: var ofile = APP_ROOT_PATH+'/data/files/png/sample.png';)
var tiff2png = spawn('convert', [ifile, ofile]);
tiff2png.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
tiff2png.stderr.on('data', function (data) {
return res.json(Utility.output('Unable to convert tiff to png','ERROR'));
console.log('stderr: ' + data);
});
tiff2png.on('close', function (code) {
/**Check Your Converted file exist or not. If exist then Converted**/
console.log('Close: ' + data);
});
tiff2png.on('error', function (code) {
return res.json(Utility.output('ERROR: Unable to convert tiff to png','ERROR'));
});
我找到了 2 个这样做的库:
最后我选择了 sharp,因为 jimp 无法处理 16 位图像