How to use the ImageMagick API without installing ImageMagick

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Rolf_Wetjen
Posts: 1
Joined: 2017-06-29T07:40:14-07:00
Authentication code: 1151

How to use the ImageMagick API without installing ImageMagick

Post by Rolf_Wetjen » 2017-06-30T00:02:24-07:00

I've created a Free Pascal (Lazarus) image viewer application (Windows) using the MagickWand and MagickCore API (version 7.0.6-0-Q16-x64).
The ImageMagick files are in an ImageMagick subfolder of the application executable folder.
The relevant Pascal unit is here: https://drive.google.com/file/d/0B1u-03 ... sp=sharing

In summary:
Create an ImageMagick subfolder in the application executable folder with the same structure as an installed ImageMagick would create in Program Files:
.\ImageMagick holds all DLL library and xml configuration files from the ImageMagick primary folder
(ImageMagick installation: Program Files\ImageMagick)
.\ImageMagick\coders holds all IM_MOD_*.DLL files
(ImageMagick installation: Program Files\ImageMagick\coders)
.\ImageMagick\filters holds all FILTER_*.DLL files
(ImageMagick installation: Program Files\ImageMagick\filters)

Don't define the ImageMagick function as external. Define procedure and function variables and use LoadLibrary / GetProcAdress.
In Pascal this looks like

Code: Select all

var
  IsMagickWandInstantiated: function: MagickBooleanType; cdecl;
...
hWandExport:=LoadLibrary(Application_Folder\ImageMagick\CORE_RL_MagickWand_.dll)
pointer(IsMagickWandInstantiated):=GetProcAddress(hWandExport,'IsMagickWandInstantiated');
Set some environment variables within the application before loading the ImageMagick libraries.
Path=Application_Folder;%Path%
LD_LIBRARY_PATH=Application_Folder\ImageMagick
MAGICK_CODER_FILTER_PATH=Application_Folder\ImageMagick\filters
MAGICK_CODER_MODULE_PATH=Application_Folder\ImageMagick\coders
MAGICK_CONFIGURE_PATH=Application_Folder\ImageMagick

Enjoy!

Post Reply