$30 off During Our Annual Pro Sale. View Details »

Wand Lightning Talk

Wand Lightning Talk

Introduction to Wand, a ctypes-based simple ImageMagick binding for Python. You can find the original of the presentation in this link: http://j.mp/pykr2012-wand

Hong Minhee (洪 民憙)

November 24, 2012
Tweet

More Decks by Hong Minhee (洪 民憙)

Other Decks in Programming

Transcript

  1. Speaker: Hong Minhee Hobbyist programmer since 1999 Python programmer since

    2005 PyPy enthusiast Anti-fan of Django StyleShare (2011–2012)
  2. Speaker: Hong Minhee Hobbyist programmer since 1999 Python programmer since

    2005 PyPy enthusiast Anti-fan of Django StyleShare (2011–2012) Crosspop (2012–)
  3. Wand: Short introduction Image Processing Library Built on top of

    ImageMagick Modern PythonicTM API Supports CPython 2.6+, PyPy☆, Jython (soon) Well Documented Properly Packaged MIT Licensed Competitior of Python Imaging Library (PIL)
  4. Too many ImageMagick bindings PyPI Docs PyPy Update PythonMagick ☹

    ☹ ☹ 2012-10 PythonMagickWand Achim Domma ☺ ☹ ☹ 2008-07 PythonMagickWand Ian Stevens ☹ ☹ ☹ 2009-01 python-magickwand Benjamin Schweizer ☺ ☹ ☹ 2012-01 magickwand Oliver Berger ☺ ☹ ☹ 2010-06 Wand ☺ ☺ ☺ 2012-11
  5. try+finally < with from wand.image import Image try: image =

    Image(width=480, height=320) assert image.size == (480, 320) image.save(filename='transparent-480x320.jpg') finally: image.close()
  6. try+finally < with from wand.image import Image with Image(width=480, height=320)

    as image: assert image.size == (480, 320) image.save(filename='transparent-480x320.jpg')
  7. try+finally < with from wand.color import Color from wand.image import

    Image with Color('white') as bg: with Image(width=480, height=320, background=bg) as i: assert i.size == (480, 320) i.save(filename='white-480x320.jpg')
  8. Converting from urllib2 import urlopen from wand.image import Image with

    Image(file=urlopen('http://j.mp/wand-iu-1')) as i: assert i.format == 'jpeg' with i.convert('png') as png: png.save(filename='wand-iu-1.png')
  9. Resizing from urllib2 import urlopen from wand.image import Image with

    Image(file=urlopen('http://j.mp/wand-iu-1')) as i: i.save(filename='wand-iu-1.jpg') assert i.size == (1200, 800) i.resize(480, 320) i.save(filename='resized.jpg')
  10. Cropping from urllib2 import urlopen from wand.image import Image with

    Image(file=urlopen('http://j.mp/wand-iu-2')) as image: image.save(filename='wand-iu-2.jpg') assert image.size == (720, 887) with image[:230, :] as cropped: cropped.save(filename='cropped.jpg')
  11. 0.3 will be soon It will include: • Python 3

    compatibility • Drawing • Sequences • EXIF • Seam carving • Channels • and so on http://dahlia.kr/wand/roadmap.html
  12. Seam carving from urllib2 import urlopen from wand.image import Image

    with Image(file=urlopen('http://j.mp/wand-iu-3')) as i: i.save(filename='wand-iu-3.jpg') assert i.size == (1280, 1710) i.liquid_rescale(1280, 1500) i.save(filename='seam-carving.jpg')