$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. Hong Minhee
    Wand

    View Slide

  2. View Slide

  3. Speaker: Hong Minhee
    http://dahlia.kr/
    https://github.com/dahlia
    https://bitbucket.org/dahlia
    @hongminhee

    View Slide

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

    View Slide

  5. https://stylesha.re/

    View Slide

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

    View Slide

  7. http://crosspop.in/

    View Slide

  8. 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)

    View Slide

  9. 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

    View Slide

  10. Install
    $ pip install Wand
    $ easy_install Wand

    View Slide

  11. ImageMagick
    $ apt-get install libmagickwand-dev
    $ yum install ImageMagick-devel
    http://dahlia.kr/wand/guide/install.html

    View Slide

  12. 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()

    View Slide

  13. 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')

    View Slide

  14. 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')

    View Slide

  15. 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')

    View Slide

  16. Resizing

    View Slide

  17. 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')

    View Slide

  18. Resizing

    View Slide

  19. Cropping

    View Slide

  20. 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')

    View Slide

  21. Cropping

    View Slide

  22. Cropping

    View Slide

  23. 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

    View Slide

  24. Seam carving

    View Slide

  25. 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')

    View Slide

  26. Seam carving

    View Slide

  27. Seam carving

    View Slide

  28. Further reading
    http://dahlia.kr/wand/

    View Slide

  29. Fork/pull request
    https://github.com/dahlia/wand

    View Slide

  30. Discussion
    [email protected]
    http://librelist.com/browser/wand/

    View Slide

  31. Talk permalink
    http://j.mp/pykr2012-wand

    View Slide