Page 1 of 1

Which Python API?

Posted: 2017-10-15T04:26:35-07:00
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

Re: Which Python API?

Posted: 2017-10-15T14:35:37-07:00
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.

Re: Which Python API?

Posted: 2017-11-10T05:23:51-07:00
by miket
Thanks Fred,

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

Mike

Re: Which Python API?

Posted: 2018-01-25T12:27:18-07:00
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 });

Re: Which Python API?

Posted: 2018-01-25T12:34:13-07:00
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.

Re: Which Python API?

Posted: 2018-01-25T12:44:51-07:00
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

Re: Which Python API?

Posted: 2018-01-25T14:32:37-07:00
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?

Re: Which Python API?

Posted: 2018-01-25T15:18:20-07:00
by eried
I agree with you, but in this particular case I just needed it to work for a short task.

Re: Which Python API?

Posted: 2018-01-25T16:16:52-07:00
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

Re: Which Python API?

Posted: 2018-01-25T17:17:21-07:00
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!

Re: Which Python API?

Posted: 2018-01-25T17:25:11-07:00
by fmw42
You could perhaps do it with Python and Opencv. See https://docs.opencv.org/3.0-beta/doc/py ... ation.html

Re: Which Python API?

Posted: 2018-01-26T08:09:48-07:00
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: