I need to use ImageMagick as PIL does not have the amount of image functionality available that I am looking for. However, I am wanting to use Python.
The python bindings (PythonMagick) have not been updated since 2009. The only thing I have been able to find is os.system
calls to use the command line interface but this seems clunky.
Is there any way to access the API directly using ctypes
and conversions of some sort?
As a last resort is there any other library out there that has the extensive amount of image editing tools like ImageMagick that I have looked over?
This has worked for me for the following command to create an image from text for the letter "P":
I would recommend using Wand (explanations follows).
I was looking for proper binding to ImageMagick library, that would:
But indeed python API (binding) has too many different (mostly discontinued) versions. After reading a nice historical overview by Benjamin Schweizer it has all become clear
(also see his github wiki):Now Wand is just a (reduced) C API to the ImageMagick ".. API is the recommended interface between the C programming language and the ImageMagick image processing libraries. Unlike the MagickCore C API, MagickWand uses only a few opaque types. Accessors are available to set or get important wand properties." (See project homepage)
So it is already a simplified interface that is easer to maintain.
I found no good Python binding for ImageMagick, so in order to use ImageMagick in Python program I had to use
subprocess
module to redirect input/output.For example, let's assume we need to convert PDF file into TIF:
Here I used
tif:-
to tell ImageMagick's command-line utility that I want to get TIF image as stdout stream. In the similar way you may tell it to use stdin stream as input by specifying-
as input filename.