Flex4/AIR with NativeProcess: Cannot pass cmd line options to Imagemagick Convert.exe
I'm trying to use Imagemagick convert.exe with Flex4 NativeProcess. I know I have it configured properly because I can get a successful result with a simple call with no options to convert.
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
However, I cannot pass a simple command option (i.e. -resize WxH) to convert.exe through NativeProcess. Here are all the variations I have tried using the same code as above:
(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'
开发者_StackOverflow中文版 (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
Can anyone offer advice?
convertOptions = ':srcFilename,-resize,75x112,:destFilename'
Treat the -resize
and the 75x112
as two separate arguments.
精彩评论