{"id":379,"date":"2008-03-14T12:23:23","date_gmt":"2008-03-14T16:23:23","guid":{"rendered":"http:\/\/crazedmonkey.com\/blog\/python\/python-bindings-for-imagemagicks-magickwand-api.html"},"modified":"2008-04-01T15:33:45","modified_gmt":"2008-04-01T19:33:45","slug":"python-imagemagick-magickwand","status":"publish","type":"post","link":"http:\/\/crazedmonkey.com\/blog\/python\/python-imagemagick-magickwand.html","title":{"rendered":"Python bindings for ImageMagick&#8217;s MagickWand API"},"content":{"rendered":"<p>I&#8217;ve been spending some of my spare time recently putting together some <a href=\"http:\/\/www.assembla.com\/wiki\/show\/pythonmagickwand\">Python bindings for ImageMagick&#8217;s MagickWand API<\/a>.  While most bindings I&#8217;ve seen just look like generated ctypes code from C header files, these bindings are more object-oriented, completely hiding the <a href=\"http:\/\/www.imagemagick.org\/script\/magick-wand.php\" title=\"MagickWand, C API for ImageMagick\">MagickWand methods<\/a>.  While this is still in the early stages, it&#8217;s workable in a way which I hope is expected and unsurprising:<\/p>\n<pre><code>from pythonmagick.image import Image\r\nfrom pythonmagick.color import BLUE\r\ni = Image('foo.jpg')\r\ni.format = 'PNG'\r\ni.rotate(45, BLUE)\r\ni.save('flip.png')<\/code><\/pre>\n<p>The above reads in a JPEG image, reformats to PNG and rotates by 45 degrees with a background colour of blue.  The image is then saved to a new file.<\/p>\n<p>This may look a lot like <a href=\"http:\/\/www.pythonware.com\/products\/pil\/\" title=\"Python Imaging Library\">PIL<\/a> code, so why not use it instead of ImageMagick?  ImageMagick covers a much wider range of image formats than PIL, and supports better algorithms for image resizing.<\/p>\n<p>Check out the bindings by installing them with <a href=\"http:\/\/peak.telecommunity.com\/DevCenter\/EasyInstall\">easy_install<\/a>:<\/p>\n<pre><code>easy_install http:\/\/svn2.assembla.com\/svn\/pythonmagickwand\/trunk\/<\/code><\/pre>\n<p>On a side note, I&#8217;m quite impressed with <a href=\"http:\/\/assembla.com\">Assembla<\/a>, the site which I&#8217;m using for my SVN and Trac repo.  It&#8217;s about as good as something I would deploy myself, but with much less hassle.  Honestly, these days there&#8217;s less and less reason for me to spend hours setting up stuff myself, and that&#8217;s a great thing.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been spending some of my spare time recently putting together some <a href=\"http:\/\/www.assembla.com\/wiki\/show\/pythonmagickwand\">Python bindings for ImageMagick&#8217;s MagickWand API<\/a>. While most bindings I&#8217;ve seen just look like generated ctypes code from C header files, these bindings are more object-oriented, completely hiding the <a href=\"http:\/\/www.imagemagick.org\/script\/magick-wand.php\" title=\"MagickWand, C API for ImageMagick\">MagickWand methods<\/a>. While this is still in&nbsp;&hellip;&nbsp;<a class=\"read_more\" href=\"http:\/\/crazedmonkey.com\/blog\/python\/python-imagemagick-magickwand.html\" rel=\"bookmark\" title=\"Continue reading &ldquo;Python bindings for ImageMagick&#8217;s MagickWand API&rdquo;\"><span>Read more<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[29],"tags":[],"_links":{"self":[{"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/posts\/379"}],"collection":[{"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/comments?post=379"}],"version-history":[{"count":0,"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/posts\/379\/revisions"}],"wp:attachment":[{"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/media?parent=379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/categories?post=379"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/tags?post=379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}