Under Windows 10 I am trying to run ImageMagick on a graphic file. I use TProcess for this purpose, and put handling of TProcess in its own procedure. I get the following Debugger Exception Notification:
Project project1 raised exception class 'EProcess' with message:
Failed to execute : 267
At address 4E68F2
The code, triggered by clicking a button, looks like
procedure TForm1.btnTestClick(Sender: TObject);
var
MCurrentDirectory: string;
MExecutable: string;
MParameters: array of string;
begin
MCurrentDirectory:= '"C:\Users\puzzled\downloads\graphics stuff\sample images"';
MExecutable:= '"C:\Program Files\ImageMagick\magick.exe"';
MParameters:= ['"C:\Users\puzzled\Documents\Lazarus\Resource files\arrow.png"',
'-alpha', 'set',
'-background', 'none',
'-rotate', '-44',
'"C:\Users\puzzled\downloads\graphics stuff\processed images\arrow44.png"'];
TProcessHandling(MCurrentDirectory,
MExecutable,
MParameters);
end;
procedure TForm1.TProcessHandling(MCurrentDirectory: string;
MExecutable: string;
MParameters: array of string);
var
RunProgram: TProcess;
s:string;
begin
RunProgram := TProcess.Create(nil);
RunProgram.CurrentDirectory:=MCurrentDirectory;
RunProgram.Executable:=MExecutable;
for s in MParameters do
RunProgram.Parameters.Add(s);
// Wait until done
RunProgram.Options := RunProgram.Options + [poWaitOnExit];
// Run ImageMagick
RunProgram.Execute; <--- Exception takes place here
Runprogram.Free;
end; }
This DOS command, including double quote marks, works without error when run manually:
"C:\Program Files\ImageMagick\magick.exe" "C:\Users\puzzled\Documents\Lazarus\Resource files\arrow.png" -alpha set -background none -rotate 44 "C:\Users\puzzled\downloads\graphics stuff\processed images\arrow44.png"
Thank you for your guidance