How to use the ImageMagick API without installing ImageMagick
Posted: 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
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!
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');
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!