ImageEn, unit iemiscplugins

TIEMiscPluginsImageMagick


Declaration

TIEMiscPluginsImageMagick = class;


Description

TIEMiscPluginsImageMagick is a wrapper around ImageMagick library allowing ImageEn to load and save many extra formats.

The plug-in adds support for: SVG, SVGZ, CALS*, FITS, PCD, BIE, CIN, EXR, DPX, JBIG, JNG, MAT, MIFF, MNG, PES*, PTIF, XCF*
And if GhostScript is available: PDF, EPDF, PS, PCL, XPS*
* Loading only, no save support



To enable the ImageMagick wrapper just call the RegisterPlugin class method once at application startup, or alternatively, RegisterPlugIns.

Note: All formats are rasterized.

You can either download the ImageMagick plug-in from:
http://www.imageen.com/download/

And unzip the files to your EXE folder (and ship them with your application).

Or ImageEn can automatically support the installed version of ImageMagick:
http://www.imagemagick.org/script/download.php#windows

In order to load PDF, PS, PCL and XPS you must install the Ghostscript library:
http://www.ghostscript.com/download/

Or download the portable version of GhostScript and add the files to your EXE folder (you may need a license to use GhostScript).


Loading Options

You can use assign options to the Dict property to scale or size the loaded image:
Option Description
ImageMagick:Scale Scale the image relative to its original size, e.g. 2 to double the image size
ImageMagick:Density Specify a DPI for the loaded image (Generally ImageMagick loads at 72 or 96 DPI)
ImageMagick:Width Specify a width in pixels to load the image. If Width is specified, but Height is 0, Height will be automatically calculated to maintain the aspect ratio *
ImageMagick:Height Specify a height in pixels to load the image. If Height is specified, but Width is 0, Width will be automatically calculated to maintain the aspect ratio *
ImageMagick:AspectRatio If Width and Height are specified, enabling AspectRatio (1) will ensure the image is loaded with the correct aspect ratio. The default is 0 meaning the aspect ratio is ignored
* You can also specify import size of images using AutoScaleImport


Methods and Properties

Public Method  IsAvailable
Public Method  RegisterPlugin


Demos

Demo  Demos\InputOutput\ImageMagick\ImageMagick.dpr
Demo  Demos\LayerEditing\SVGVectorLayers\SVGLayers.dpr


Examples

// Register the ImageMagick plug-in
IEGlobalSettings().RegisterPlugIns([iepiImageMagick]);
if not ( iepiImageMagick in IEGlobalSettings().ActivePlugIns ) then
  ShowMessage( 'ImageMagick not found!' );

// Load an SVG at double size
ImageEnView1.IO.Params.Dict.Clear();
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Scale', 2 );
ImageEnView1.IO.LoadFromFile( 'D:\SVG\Lion.svg' );

// Load an SVG at size 2000x1000px
ImageEnView1.IO.Params.Dict.Clear();
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Width', 2000 );
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Height', 1000 );
ImageEnView1.IO.LoadFromFile( 'D:\SVG\Lion.svg' );

// Which is the same as...
ImageEnView1.IO.Params.AutoScale := True;
ImageEnView1.IO.Params.LoadToWidth := 2000;
ImageEnView1.IO.Params.LoadToHeight := 1000;
ImageEnView1.IO.LoadFromFile( 'D:\SVG\Lion.svg' );

// Load an SVG at size 2000px wide. Auto-calculate height
ImageEnView1.IO.Params.Dict.Clear();
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Width', 2000 );
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Height', 0 );
ImageEnView1.IO.LoadFromFile( 'D:\SVG\Lion.svg' );

// Load an SVG at size 1000px high. Auto-calculate width
ImageEnView1.IO.Params.Dict.Clear();
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Width', 0 );
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Height', 1000 );
ImageEnView1.IO.LoadFromFile( 'D:\SVG\Lion.svg' );

// Load an SVG at size up to 2000x1000px, but maintain the Aspect ratio
ImageEnView1.IO.Params.Dict.Clear();
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Width', 2000 );
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Height', 1000 );
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:AspectRatio', 1 );
ImageEnView1.IO.LoadFromFile( 'D:\SVG\Lion.svg' );

// Load an SVG at 200 dpi
ImageEnView1.IO.Params.Dict.Clear();
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Density', 200 );
ImageEnView1.IO.LoadFromFile( 'D:\SVG\Lion.svg' );

// Rasterize page number 5 of mybook.pdf at 200dpi
ImageEnView1.IO.Params.ImageIndex := 5;
ImageEnView1.IO.Params.Dict.Insert('ImageMagick:Density', 200);
ImageEnView1.IO.LoadFromFile('mybook.pdf');