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: Scalable Vector Graphics (*.svg, *.svgz), High Efficiency Image File (*.heic, *.heif, *.avif), WebP image (*.webp), JPEG XL Image (*.jxl), GIMP (*.xcf), TrueType Fonts (*.ttf, *.otf), Kodak Photo-CD (*.pcd, *.pcds), Apple Pict (*.pict), CALS Image (*.cals, *.cal), Flexible Image Transport System (*.fits), HP PCL Printer Image (*.pcl), Kodak Cineon (*.cin), Embrid Embroidery Format (*.pes), SMPTE (*.dpx), Magick (*.miff, *.mvg), Matlab (*.mat), JPEG Network Graphics (*.jng), Multiple-Image Network Graphics (*.mng), High Dynamic Range File (*.exr), MPEG (*.mp4, *.mpeg, *.mpg, *.mov, *.m2v, *.m4v)
And if GhostScript is available: Adobe PDF (*.pdf, *.epdf), PostScript (*.ps, *.eps), Microsoft XML Page (*.xps)
Saving is NOT supported for these formats: *.heic, *.heif, *.avif, *.ttf, *.otf, *.pfa, *.pfb, *.ttc, *.dfont, *.pes, *.cals, *.cal, *.xcf
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:
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:
www.imagemagick.org/script/download.php#windowsIn order to load PDF, PS, PCL and XPS you must install the Ghostscript library:
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).
For PDF support, it is better to use
PDFiumImageMagick Formats
Format | Description | Extensions | Load | Save |
iomscFITS (8193) | Flexible Image Transport System | FITS, FTS | | |
iomscPCD (8194) | Photo CD Image | PCD, PCDS | | |
iomscPCL (8195) | Printer Control Language | PCL | | |
iomscPDF (8196) | Portable Document Format | PDF, PDFA, EPDF | | |
iomscHEIF (8197) | High Efficiency Image File | HEIC, HEIF, AVIF | | |
iomscCIN (8198) | Cineon Image File | CIN | | |
iomscEXR (8199) | High Dynamic Range File | EXR | | |
iomscTTF (8200) | TrueType Font | TTF, OTF, PFA, PFB, TTC, DFONT | | |
iomscDPX (8201) | Digital Picture Exchange Image | DPX | | |
iomscWEBP (8202) | WebP Image | WEBP | | |
iomscJNG (8203) | JPEG Network Graphics | JNG | | |
iomscM2V (8204) | MPEG Video Stream | M2V, MOV, MPEG, MPG | | |
iomscMAT (8205) | MATLAB Image Format | MAT | | |
iomscMIFF (8206) | Magick Image File Format | MIFF | | |
iomscMNG (8207) | Multiple-Image Network Graphics | MNG | | |
iomscMP4 (8208) | MPEG-4 Video | MP4, M4V | | |
iomscMSVG (8209) | ImageMagick SVG Renderer | MSVG, RSVG | | |
iomscPES (8210) | Embrid Embroidery Format | PES | | |
iomscPS (8211) | PostScript | PS, EPS, EPSF, EPSI, EPI, EPT | | |
iomscCALS (8212) | CALS Image | CALS, CAL | | |
iomscJPEGXL (8213) | JPEG XL Image | JXL | | |
iomscSVG (8214) | Scalable Vector Graphics | SVG, SVGZ | | |
iomscXCF (8215) | GIMP Image | XCF | | |
iomscXPS (8216) | Microsoft XML Paper Specification | XPS | | |
iomscPICT (8217) | QuickDraw PICT Image | PICT, PCT | | |
iomscJSON (8218) | Image Properties JSON File | JSON | | |
iomscSFW (8219) | Seattle FilmWorks Image | SFW | | |
iomscRGB (8220) | RGB Image | RGB, SGI | | |
iomscXBM (8221) | X11 Bitmap Graphic | XBM | | |
iomscXPM (8222) | X11 Pixmap Graphic | XPM | | |
iomscAAI (8223) | Dune AAI Image | AAI | | |
iomscORA (8224) | OpenRaster Image | ORA | | |
You can 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 (Integer values only) |
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 And also to control saving behavior:
Option | Description |
ImageMagick:Quality | Specify the compression quality (1=low quality, 100=highest quality). The default is 87 |
You can create a
dictionary named 'ImageMagick' to add custom ImageMagick options:
◼imagemagick.org/script/defines.php◼imagemagick.org/script/webp.php
// Save a PNG file as a lossless WebP with maximum compression
ImageEnView1.IO.SaveToFile('D:\Image.png');
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick', TIEDictionary.Create() );
ImageEnView1.IO.Params.Dict.GetDictionary('ImageMagick').Insert( 'webp:lossless', False );
ImageEnView1.IO.Params.Dict.GetDictionary('ImageMagick').Insert( 'webp:method', 6 );
ImageEnView1.IO.SaveToFile('D:\Image_out.webp'); | Demos\InputOutput\ImageMagick\ImageMagick.dpr |
| Demos\LayerEditing\SVGVectorLayers\SVGLayers.dpr |
// 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.AutoScaleImport := 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' );
// Save a JPEG as JNG at 95% quality
ImageEnView1.IO.LoadFromFile( 'D:\Image.jpg' );
ImageEnView1.IO.Params.Dict.Clear();
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Quality', 95 );
ImageEnView1.IO.LoadFromFile( 'D:\Image_out.jng' );
// Save a PNG file as a lossless WebP with maximum compression
ImageEnView1.IO.SaveToFile('D:\Image.png');
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick', TIEDictionary.Create() );
ImageEnView1.IO.Params.Dict.GetDictionary('ImageMagick').Insert( 'webp:lossless', False );
ImageEnView1.IO.Params.Dict.GetDictionary('ImageMagick').Insert( 'webp:method', 6 );
ImageEnView1.IO.SaveToFile('D:\Image_out.webp');
{
Results:
Original PNG: 2.19 MB
Lossless+Method=0: 1.38 MB
Lossless+Method=6: 1.17 MB
Lossy+Method=0: 86.4 KB
Lossy+Method=6: 63.6 KB
}