Which Python API?

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
miket
Posts: 60
Joined: 2016-08-12T13:19:13-07:00
Authentication code: 1151

Which Python API?

Post by miket »

Hi Folks,

I've been using PerlMagic for a while now. However, I've recently been using Python for some (non-imaging) work, and would like to start using Python with ImageMagick.

There appears to be a number of different wrapper implementations, some of which do not appear to have been updated recently. I'm looking for something that will give full functionality of all the IM process and something that keeps up to date with all IM fixes.

Does anybody have any recommendations of which wrapper would be best for my requirements?

Ta

Mike
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Which Python API?

Post by fmw42 »

I am not an expert on ImageMagick bindings to Python. But from what I have seen from their documentation, Wand (http://docs.wand-py.org/en/0.4.4/) does a pretty good job. One thing that seems missing is dealing with profiles.

Also consider Imagemagick's Pythonmagick (http://www.imagemagick.org/download/python/). At least with the latter, you may be able to ask for features to be added if they are not there.

Another option is to use Python subprocess to make calls to ImageMagick directly.
miket
Posts: 60
Joined: 2016-08-12T13:19:13-07:00
Authentication code: 1151

Re: Which Python API?

Post by miket »

Thanks Fred,

I suspected this. Think I may stay with perl for the moment. Better the Devil you know :)

Mike
eried
Posts: 5
Joined: 2018-01-25T12:23:17-07:00
Authentication code: 1152
Location: Norway

Re: Which Python API?

Post by eried »

I am so surprised about how limited are they python apis, I need to find one for using ImageMagick in one Raspberry pi but I cant find any function :(

Has anyone any idea how to execute a barrel distortion in ImageMagick via a python script?

Code: Select all

img.Distort(DistortMethod.Barrel, new[] { -0.92578, 1.3845, -2.09958 });
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Which Python API?

Post by fmw42 »

One way, is to use a subprocess call from python to an imagemagick command line. See viewtopic.php?f=4&t=32920

I do not know if PythonMagick contains calls to all the distort methods. It may be behind. But you might ask the developers if that is included or if they can include it.
eried
Posts: 5
Joined: 2018-01-25T12:23:17-07:00
Authentication code: 1152
Location: Norway

Re: Which Python API?

Post by eried »

fmw42 wrote: 2018-01-25T12:34:13-07:00 One way, is to use a subprocess call from python to an imagemagick command line. See viewtopic.php?f=4&t=32920

I do not know if PythonMagick contains calls to all the distort methods. It may be behind. But you might ask the developers if that is included or if they can include it.
True, but since I am doing several steps it will be a waste to create all those temp files :/
https://stackoverflow.com/questions/484 ... correction

Nobody uses imagemagick with python? I am quite impressive how lackluster is the experience
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Which Python API?

Post by Bonzo »

Nobody uses imagemagick with python? I am quite impressive how lackluster is the experience
Perhaps you would be willing to help improve the experience rather than just complaining about other peoples work?
eried
Posts: 5
Joined: 2018-01-25T12:23:17-07:00
Authentication code: 1152
Location: Norway

Re: Which Python API?

Post by eried »

I agree with you, but in this particular case I just needed it to work for a short task.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Which Python API?

Post by fmw42 »

Nobody uses imagemagick with python? I am quite impressive how lackluster is the experience
Have you tried using Wand with Python. See https://media.readthedocs.org/pdf/wand/latest/wand.pdf
eried
Posts: 5
Joined: 2018-01-25T12:23:17-07:00
Authentication code: 1152
Location: Norway

Re: Which Python API?

Post by eried »

I was going to test it but they only support IM6.x, and the repo seemed quite abandoned so I went first with PythonMagick. But I will test again, thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Which Python API?

Post by fmw42 »

You could perhaps do it with Python and Opencv. See https://docs.opencv.org/3.0-beta/doc/py ... ation.html
eried
Posts: 5
Joined: 2018-01-25T12:23:17-07:00
Authentication code: 1152
Location: Norway

Re: Which Python API?

Post by eried »

fmw42 wrote: 2018-01-25T17:25:11-07:00 You could perhaps do it with Python and Opencv. See https://docs.opencv.org/3.0-beta/doc/py ... ation.html
Yeah, thanks but that wrapper is quite undocumented too. I think I will do what you suggested at first, using a subprocess. I just need to write a long argument :lol:
Post Reply