我正在尝试将Imagemagick convert.exe与Flex4 NativeProcess一起使用。我知道我已将其配置正确,因为我可以通过简单的调用获得成功的结果而无需转换选项。
convertOptions = ':srcFilename,:destFilename'; // command (1)
// command processing
var srcFilename:String = 'C:\\USERS\\ ... \\DC\\P1040011.JPG';
var destFilename:String = 'W:\\ ... \\sq~P1040011.JPG';
convertOptions = convertOptions.replace(':srcFilename', srcFilename);
convertOptions = convertOptions.replace(':destFilename', destFilename);
var processArgs:Vector.<String> = new Vector.<String>();
var parts:Array = convertOptions.split(',');
for (var i:int =0; i<parts.length; i++) {
processArgs.push(parts[i]);
}
nativeProcessStartupInfo.arguments = processArgs;
process.start(nativeProcessStartupInfo);
// (1) e.exitCode=0, image successfully copied to :destFilename
但是,我无法通过NativeProcess传递一个简单的命令选项(即-resize WxH)到convert.exe。以下是我尝试使用上述相同代码的所有变体:
(1) convertOptions = ':srcFilename,:destFilename'
(args passed as Vector.<String>) exit=0 success, convert successful
(2) convertOptions = ':srcFilename :destFilename'
(args passed in 1 line) exit=0, convert failed
onOutputData: shows convert -h output, as if command options malformed
(3) convertOptions = '":srcFilename" ":destFilename"'
(args passed in 1 line, quoted) exit=0, convert failed
onOutputData: shows convert -h output, as if command options malformed
(4) convertOptions = ':srcFilename,-resize 75x112,:destFilename'
(args passed as Vector.<String>) exit=1, convert failed
onErrorData - convert.exe: unrecognized option '-resize 75x112' @ error/convert.c/ConvertImageCommand/2344.
(5) convertOptions = ':srcFilename,"-resize 75x112",:destFilename'
(passed as array with -resize option quoted) exit=1, convert failed
onErrorData - convert.exe: unable to open image '"-resize 75x112"': Invalid argument @ error/blob.c/OpenBlob/2489.
(6) convertOptions = ':srcFilename -resize 75x112 :destFilename'
(args passed in 1 line) exit=0, convert failed
onOutputData: shows convert -h output, as if command options malformed
有人可以提供建议吗?
答案 0 :(得分:1)
convertOptions = ':srcFilename,-resize,75x112,:destFilename'
将-resize
和75x112
视为两个独立的参数。