Share
Embed
Purely Python Imaging with Pymaging
A little over a year ago, frustration with the state of image processing in Python led me to start a project called pymaging. Pymaging is a pure Python image processing library that works on Python 2.x and 3.x. This talk will dive into why I started this project, how I dug into the problems, what I learned about image formats and my goals for the future of this project.
PyCon 2013
March 17, 2013
Transcript
28 slides
-
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 1/28
PURELY PYTHON IMAGING WITH PYMAGING PyCon US 2013 Jonas Obrist -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 2/28
JONAS OBRIST github.com/ojii twitter.com/ojiidotch [email protected] django CMS core developer DjangoCon Europe 2012 Organizer Python Enthusiast -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 3/28
NO IDEA ABOUT DIGITAL IMAGING Can't code C Can barely read C Had no idea how images work -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 4/28
GOALS OF PYIMAGING Pure Python solution for common* imaging tasks Easily installable Easy to use Easy to hack Easy to extend Support for Python 2 and 3 -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 5/28
ORIGINS OF PYMAGING December 21st 2011 #django-cms on freenode "Installing PIL is hard" < o j i i > a n d I d o n ' t g e t h o w n o o n e c a m e u p w i t h a n a l t e r n a t i v e y e t < o j i i > i s t h a t r e a l l y T H A T h a r d ? < o j i i > a n d d o e s i t r e a l l y * N E E D * C ? < k e z a b e l l e > s o u n d s l i k e y o u ' r e v o l u n t e e r i n g ; ) < o j i i > h a h < o j i i > i w i s h i c o u l d < T r i b a a l > I t h i n k s o m e b o d y j u s t h a s t o d o i t -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 6/28
EARLY RESISTANCE "Not Fast Enough" < G o t e n X i a o > o j i i : t h e p r o b l e m i s t h a t p u r e P y t h o n r u n n i n g o n C P y t h o n i s n ' t f a s t e n o u g h < T r i b a a l > p y p y : ) < o j i i > p y p y ! -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 7/28
I TRIED IT ANYWAY (Shoutout to @katylava for picking the name!) -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 8/28
EARLY APPROACH Porting PIL C code line-by-line Previous success with this approach PIL proofed to be too complicated -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 10/28
EXISTING (PURE) PYTHON LIBRARIES PNG GIF* JPEG ... -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 11/28
LICENSE HELL All GIF libraries are GPL -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 12/28
GLUING THINGS TOGETHER Different library maturities Different internal storage But working proof-of-concept end of January 2012 -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 13/28
HOW PYMAGING WORKS Core provides APIs Packages provide format support -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 14/28
FORMATS Register through setuptools entry points Provide an encoder and/or decoder Separate from the main package -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 15/28
CORE Defines the internal data structure Defines the API Keeps track of installed formats Implements basic algorithms -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 16/28
HOW IMAGES ARE STORED INTERNALLY P i x e l A r r a y and friends Flat a r r a y . a r r a y of pixel data High-level API to manipulate pixels and the canvas -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 18/28
FORMATS PNG encoding/decoding JPG decoding (broken) BMP decoding PSD (by Mikhail Korobov) -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 19/28
APIS Resize/Crop (Thumbnailing) Affine transforms (thanks Craig de Stigter) Rotation Drawing Blit (merging) -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 20/28
PYTHON 3 Python 2.6 ~ 3.3 Not as hard as I thought Pymaging only handles bytes, not strings New libraries should really support 3! -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 21/28
LESSONS LEARNED Imaging is hard... ...but not impossible! -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 22/28
FORMATS Level of documentation varies a lot! PNG is amazing! BMP is weird JPEG is complicated GIF is really close to being easy -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 23/28
PYPY IS AWESOME The primary "speed" strategy Very helpful developers They fix PyPy if you find slow parts -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 24/28
YOU'RE NOT THE FIRST Chances are somebody tried before Google! Build on others work -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 25/28
FUTURE Fix JPEG Fix bugs Delayed loading -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 26/28
I NEED HELP You can most likely contribute Pick a format, implement it Pick a format, fix it Ask me for help -
3/17/13 reveal.js - The HTML Presentation Framework file:///home/jonas/Ubuntu One/presentations/pymaging/local/index.html#/ 28/28
THANK YOU / QUESTIONS? github.com/ojii/pymaging github.com/ojii/pymaging-png github.com/ojii/pymaging-bmp github.com/ojii/pymaging-jpg twitter.com/ojiidotch [email protected] github.com/ojii