If you are interested in ImageMagickObject Delphi example

ImageMagickObject is a Windows COM+ interface to ImageMagick. COM+, Visual Basic, and Delphi users should post to this discussion group.
Post Reply
oku

If you are interested in ImageMagickObject Delphi example

Post by oku »

The ImageMagickObject usage example - calling ImageMagick.convert method in Delphi

1. Install ImageMagick - check "Install ImageMagickObject"
2. Run Delphi, import ImageMagickObject type library (Delphi 7 - menu: "Project"/"Import Type Library")
- this should create unit ImageMagickObject_TLB.pas
3. Optionally uncomment the example you want in "Test" procedure (resize example is default)
4. Compile project, run
5. Check the output in logo2.png (example code does not display any pictures just makes a conversion)

IMPORTANT:
To compile procedure Test() include ImageMagickObject_TLB, variants and activex units in uses section


IMPORTANT:
When you get "An application has made an attempt to load the C runtime library incorrectly" error you should upgrade:
"Microsoft Visual C++ 2008 SP1 Redistributable Package (x86)"
http://www.microsoft.com/downloads/deta ... laylang=en

Tested on:
ImageMagick-6.5.1-0-Q16-windows-dll Windows package, Delphi 7

Author: Pawel Kujawa, 2009
oku@chello.pl

Code: Select all



// uses section for GUI application:
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ImageMagickObject_TLB, activeX, StdCtrls;



// Example procedure using COM object 
procedure Test;
var
  v : Variant;
 im : TMagickImage;
begin

  im := TMagickImage.Create(nil);
  try

   v := VarArrayCreate([0, 3], varVariant);
   v[0] := 'logo:';

 // rotation example
 //  v[1] := '-rotate';
 //  v[2] := '10';


 // crop example - crop to 94x103 starting at 30, 25
 //  v[1] := '-crop';
 //  v[2] := '94x103+30+25';


 // resize example - set width = 150 (will keep aspect ratio)
    v[1] := '-resize';
    v[2] := '150';

 // output filename
   v[3] := 'logo2.jpg';

 // execution 
   im.Convert(PSafeArray(TVarData(v).VArray));

  finally
   im.Free;
  end; 

end;

99Percent

Re: If you are interested in ImageMagickObject Delphi exampl

Post by 99Percent »

This works fine, but how can I get error messages?

if I do this

Code: Select all

Memo1.Lines.Add(String(im.Messages));
I get exception class EOleException 'Not implemented'
oku

Re: If you are interested in ImageMagickObject Delphi exampl

Post by oku »

Try

Code: Select all

Memo1.Lines.Add(String(im.Get_Messages));
Post Reply