代码转自:http://www.pjblog.net/index.php?post/2004/10/12/46-imagemagickobject-et-delphi
procedure TFormMain.Convert( ImgSource, ImgDest:TImage; SizeX, SizeY : Integer;PixelFormat: TPixelFormat); var SrcName, DestName : String; sa_cmdline : Variant; Params : PSafeArray; StrList : TStringList; i : Integer; begin StrList := TStringList.Create; SrcName := ExtractFilePath(Application.ExeName)+'tmp.bmp'; DestName := Format(ExtractFilePath(Application.ExeName)+'tmpdest%d_%d.bmp',[SizeX,ord(PixelFormat)]); ImgSource.Picture.SaveToFile(SrcName); StrList.Add('-geometry'); StrList.Add(Format('%dx%d',[Sizex,SizeY])); Case PixelFormat of pf1bit : begin StrList.Add('-monochrome'); StrList.Add('-dither'); end; pf4bit : begin StrList.Add('-colors'); StrList.Add('-16'); StrList.Add('-dither'); end; pf8bit : begin StrList.Add('-colors'); StrList.Add('-256'); StrList.Add('-dither'); end; pf16bit : begin StrList.Add('-colors'); StrList.Add('-65536'); end; end; StrList.Add(SrcName); StrList.Add(DestName); sa_cmdline := VarArrayCreate([0,StrList.Count-1], varVariant); for i := 0 to StrList.Count-1 do sa_cmdline[i]:=StrList[i]; Params := PSafeArray(TVarData(sa_cmdline).VArray); MagickImage1.Convert(Params); ImgDest.Picture.LoadFromFile(DestName); StrList.Free; end;