Visit our site to listen to past episodes, support the show, join our community, and sign up for our mailing list.
Summary
If you need to work with images the Pillow is the library to use. The Python Image Libary (PIL) has long been the gold standard for resizing, analyzing, and processing pictures in Python. Pillow is the modern fork that is bringing the PIL into the future so that we can all continue to use it moving forward. This week I spoke with Alex Clark about what first led him to fork the project and his experience maintaining it, including the migration to Python 3.
Brief Introduction
- Hello and welcome to Podcast.__init__, the podcast about Python and the people who make it great.
- I would like to thank everyone who has donated to the show. Your contributions help us make the show sustainable. For details on how to support the show you can visit our site at pythonpodcast.com
- Linode is sponsoring us this week. Check them out at linode.com/podcastinit and get a $20 credit to try out their fast and reliable Linux virtual servers for your next project
- We also have a new sponsor this week. Rollbar is a service for tracking and aggregating your application errors so that you can find and fix the bugs in your application before your users notice they exist. Use the link rollbar.com/podcastinit to get 90 days and 300,000 errors for free on their bootstrap plan.
- Visit our site to subscribe to our show, sign up for our newsletter, read the show notes, and get in touch.
- To help other people find the show you can leave a review on iTunes, or Google Play Music, and tell your friends and co-workers
- Join our community! Visit discourse.pythonpodcast.com for your opportunity to find out about upcoming guests, suggest questions, and propose show ideas.
- Your host as usual is Tobias Macey
- Today we’re interviewing Alex Clark about the Pillow project
Interview with Alex Clark
- Introductions
- How did you get introduced to Python? – Tobias
- What were you working on that led you to forking the Python Image Library (PIL)? – Tobias
- What does Fredrik Lundh (author of PIL) think of Pillow?
- When you first forked the PIL project did you think that you would still be maintaining and updating that fork by now? – Tobias
- Who else works on the project with you and how did they get involved? – Tobias
- What kinds of special knowledge or experience have you found to be necessary for understanding and extending the routines in the library and for adding new capabilities? – Tobias
- Can you describe what PIL and now Pillow are and what kinds of use cases they support? – Tobias
- How does Pillow compare to libraries with a similar purpose such as ImageMagick? – Tobias
- I have seen Pillow used in computer vision contexts. What are some of the capabilities of the library that lend themselves to this purpose? – Tobias
- What architectural patterns does Pillow use to make image operations fast and flexible? Have you found the need to do any significant refactorings of the original code to make it compatible with modern uses and execution environments? – Tobias
- Have you kept up to date with newer image formats, such as webp? Are there any image formats that Pillow does not support that you would like to see added to the project? – Tobias
- What are some of the most interesting or innovative uses of Pillow that you have seen? – Tobias
- What do you have planned for the future of Pillow? – Tobias
Keep In Touch
Picks
- Tobias
- Alex
Links
The intro and outro music is from Requiem for a Fish The Freak Fandango Orchestra / CC BY-SA
Hello, and welcome to podcast.init, the podcast about Python and the people who make it great. I would like to thank everyone who has donated to the show. Your contributions help us make the show sustainable. For details on how to support the show, you can visit our site at pythonpodcast.com. Linode is sponsoring us this week. Check them out at linode.com/podcastinit and get a $20 credit to try out their fast and reliable Linux virtual servers for your next project. We're also sponsored by Rollbar this week. Rollbar is a service for tracking and aggregating your application errors so that you can find and fix the bugs in your application before your users notice they exist. Use the link rollbar.com/podcastinit to get 90 days and 300, 000 arrows tracked for free on their boot strap plan. You can visit our site to subscribe to our show, sign up for our newsletter, read the show notes and get in touch. And And to help other people find the show, you can leave a review on iTunes or Google Play Music, and also tell your friends and coworkers.
You can also join our community by visiting our discourse forum at discourse.pythonpodcast.com for your opportunity to find out about upcoming guests, suggest questions, and propose show ideas. Your host as usual is Tobias Macy. And today, I'm interviewing Alex Clark about The Pillow Project. So, Alex, could you please introduce yourself?
[00:01:24] Unknown:
Sure. I'm Alex Clark, author of the pillow fork of the Python Imaging Library. I'm also a Python web developer, system administrator, and a few other things.
[00:01:38] Unknown:
And how did you get introduced to Python?
[00:01:41] Unknown:
In the early 2000, I was working at the National Institutes of Health in Bethesda, Maryland, USA as a system administrator, and my group needed a website. A neighboring group was using clone, and I decided to copy their approach. Clone is written in Python and built on top of, Zope Technologies written in Python and c. And to customize Plone, you had to know a little Python. So that was my introduction.
[00:02:11] Unknown:
Yeah. I think that was actually the first time I ever really used Python 2 was trying to upgrade a clone installation by about 2 or 3 major versions.
[00:02:20] Unknown:
Yeah. Lots of fun. That was that's 1 of my favorite things to do even still is to upgrade old versions of Plone.
[00:02:27] Unknown:
So what were you working on that led you to forking the Python image library?
[00:02:33] Unknown:
Well, by the mid 2000, I had quit my assistant job at NIH to do clone consulting full time. And in 2010, I was doing Django Consulting at, National Geographic in DC. And I came in to work the next day, and I said to a guy named Rich Leland, who I was working with. I said I forked a pill last night, and his reaction was basically yawn because no 1 knew what it would become including me. And, I created the fork because I was annoyed that I couldn't install pill from pypy and, the pill package on Pypi was hosted off-site, and it also had some flaws that no 1 was able to get incorporated into pill. And so you started to see all these forks all over the place, not on Pypie, and that just annoyed me. So, that's what led to me taking in 1 of these existing forks created by a clone guy named and put that into a GitHub repository and, released to PyPI, and that was it.
[00:03:51] Unknown:
You were mentioning 1 of the issues being that you were having trouble getting it installed from PyPI. And I know that at least in some portions of its history, the Python image library has been somewhat difficult to install because of its heavy use of c extensions and additional libraries for being able to support things like JPEGs and PNGs. So has that story gotten better as you have progressed the PillowFork forward?
[00:04:15] Unknown:
I think a little bit. I mean, there's certainly been backlash against non PyPI hosted projects. And so, as a packaging fork, we, you know, we were free to fix a lot of things that caused those problems unlike with pill, which where, you know, fixes weren't incorporated as rapidly. We could, you know, take a fix from someone and release it to the packaging index, you know, almost immediately once once we had that fork. You know, once we started it, the ball started rolling quickly.
[00:04:53] Unknown:
So what does the original author of PIL, Friedrich Lund, think of the pillow fork?
[00:05:00] Unknown:
My favorite story about Friedrich is his comment on a mailing list, on the Image Sig mailing list where he said something to the effect of a lot of people complain, at least someone's doing something about it. And you can look at Image Sig around August 2010 for the full story there. And so, basically, he just, I guess, begrudgingly acknowledged that, someone had done something more than just attacking him or just complaining, I guess.
[00:05:31] Unknown:
So when you first forked the image library projects, did you think that you would still be maintaining and updating that fork by now? No. Not at all.
[00:05:39] Unknown:
I just knew my Plone installations were gonna be awesome. And when Pillow caught on, I was happy others found it useful. Nowadays, most of the day to day operations are done by the team, which is, you know, a handful of people and also the global community. And I pop in about once per quarter to make sure releases go according to plan and to sort of clean up and, prune repositories and issues. And I recently registered the domain pythonpillow.org so we could receive security related emails, which we're starting to get now.
[00:06:19] Unknown:
And, you mentioned some of the other members of the team. Are there any particular people you'd like to call out and maybe share how they got involved with the project?
[00:06:26] Unknown:
Absolutely. There's someone I call pillow man number 2, and that's Eric Swarus. He goes by Wired Fool and he does a lot of the c programming that no 1 else is willing to do. And he has surpassed me now in commits to pillow. Let's see. I'm gonna call people out by their GitHub username and possibly their real name depending on whether or not it looks like that's public information.
[00:06:55] Unknown:
Okay.
[00:06:57] Unknown:
Let's see. And Eric is the guy who would take over if I were hit by a bus. So I'm I was really happy when he came along, and he just started doing c programming. And, beyond that, we have, let's see, 3 other guys. I think that they're not publicly members of the organization, but you can see in the repository their commits, and that is hom, h o m m. That's Alexander Karpinski. Hugo v k, who is Hugo. Radar here, who's Andrew Murray. And so that's what I call the pillow team. And Hugo is, I think, most active after wired fool and then followed by Andrew Murray radar here. And Ham was making some interesting commits at 1 point, and so we added him to the team. And so it's really cool to have all these guys just, you know, working on this day to day. I sort of drop off and then I check-in, like I said, once a quarter, and everyone is still doing pillow development, and it's awesome.
[00:07:59] Unknown:
Yeah. I imagine that given the low level nature of a lot of the code and working in C and having to have at least decent knowledge of image manipulation and image formats, it must be somewhat difficult to attract contributors.
[00:08:13] Unknown:
Absolutely. I mean, I did see in college in the nineties and, you know, if I had to do it now, we'd probably be in big trouble. I I sort of feel like if something has to be done, someone somewhere will do it. And since big Linux distributions are using Pillow and big companies like Atlassian. You know, someone will do something if it's absolutely needed, but someone who having someone who actually likes to do it is better, obviously.
[00:08:40] Unknown:
And, touching on that a bit more, what kinds of special knowledge or experience have you found to be necessary for being able to understand and extend the routines and functionality of the library and adding new capabilities?
[00:08:53] Unknown:
I think the biggest is c and c extensions, which I think are a distutils thing. So there's about 30, 000 lines of c code. And looking at the setup pie and seeing how those are, how the package is built, and how the c code is exposed to Python routines is probably the most different thing about pill and pillow versus, you know, pure Python packages and libraries.
[00:09:21] Unknown:
And so we've, gotten this far into the conversation without really going deep on what the Python image library and Pillow are and what kinds of use cases they support and sort of the feature set. So if you could dig into that a bit for me, that'd be great.
[00:09:37] Unknown:
Absolutely. PIL allows Python programmers to perform complex image manipulation operations without having to know the details and algorithms involved in performing such operations. So, for example, basic image manipulation, like cropping, resizing, rotating, changing formats, and also things like viewing or extracting metadata like EXIF data, splitting the image into respective bands, red, green, and blue, applying filters, that sort of thing. And so as a Python web developer, I use Pillow to manipulate images in web applications. In some cases, the manipulation is seamless like with Plone. Plone uses Pillow to enable content editors to manipulate images on their website. In other cases, I write the Pillow code to do some manipulation that's needed for my app. But there's probably many, many more use cases.
[00:10:38] Unknown:
How does Pillow compare to other libraries with similar purpose and use case such as ImageMagick?
[00:10:46] Unknown:
When I think of ImageMagick, I think of command line tools for image manipulation, which Pillow definitely is not. I think ImageMagick's a little heavier. Pillow really is for basic image manipulation. And, also, I think if the standard library had an imaging, set of tools, it would be something like Pillow.
[00:11:07] Unknown:
And are there any other libraries that build on top of Pillow that are a little bit more high level for maybe simplifying some of the operations that are common to certain use cases?
[00:11:17] Unknown:
That's a good question. I haven't seen such a thing, but I wouldn't be surprised if it existed.
[00:11:24] Unknown:
And, I have seen Pillow used in some computer vision contexts. Wondering what are the capabilities of the library that lend themselves to that particular use case?
[00:11:33] Unknown:
I think basic in in as much as computer vision involves basic image processing, and Pill can help with, you know, cropping, resizing, rotating, changing formats. Beyond that, you'll probably need more powerful tools like matplotlib, opencv, and so on.
[00:11:49] Unknown:
Yeah. There's a, project called SimpleCV that I've used at 1 point a while back that wraps some of the PIL capabilities as well as OpenCV and I think a couple other things to give a much more high level computer vision toolkit for being able to do some common operations like doing facial detection using HAR classifiers and things like that. And also some manipulation of the images for being able to make it easier to run training algorithms on them?
[00:12:18] Unknown:
Yeah. I came across that when I was researching today, but I haven't tried it. It looks fairly interesting.
[00:12:24] Unknown:
So what are some of the architectural patterns in Pillow that are used to make image operations fast and flexible. And have you found the need to do any significant refactorings of the original code to make it compatible with modern uses and execution environments?
[00:12:40] Unknown:
As far as making operations fast and flexible, probably c code is what is responsible for that. And the biggest refactor was probably adding Python 3 compatibility, which is when we really started to make a bunch of changes. Before that, it was mostly a packaging fork.
[00:13:00] Unknown:
And in the process of making the compatibility jump, were there a large number of pieces of the code that needed to be modified? Or was it just a few points where it ties into the Python runtime?
[00:13:11] Unknown:
There was a guy that came along and contributed a pull request that added the bulk of the Python 3 compatibility. And beyond that, it was just a matter of cleaning up what was left. But I think he did a good bit of work on a lot of the code, to support 32 at the time.
[00:13:29] Unknown:
And as you have worked with and maintained the project, have you been keeping up to date with some of the newer image formats that have been coming out such as webp? And are there any image formats that Pillow does not support that you'd like to see added to the project?
[00:13:42] Unknown:
I think since the fork, we've added webp and JPEG 2, 000. And I went back to NIH in 2013. So I'd I'd definitely like to see some medical image format supported like DICOM or NFFTY.
[00:13:59] Unknown:
And, I think it was the last interview that I did, 1 of the things that they called out was they were trying to do some GIF manipulation or GIF, however you wanna pronounce it, and mentioned that they didn't see that in Pillow. So do you have any plans or intention of adding that to the project? Or would that just something that's too far outside of the use case, particularly given some of the animation support that GIFs have?
[00:14:23] Unknown:
Yeah. I'm not sure if that's Phil's thing. I guess, like anything else, you know, if someone wants it bad enough, they'll, you know, send they'll contribute. And, as far as me personally wanting it, no. It hasn't been on my radar.
[00:14:38] Unknown:
So what are some of the most interesting or innovative uses of Pill and Pillow that you've seen?
[00:14:44] Unknown:
There was a guy who did Jeremy Coon did a blog entry in 2012, I think it was, called random psychedelic art with pill, which has always stuck with me, and it's on the the pillow website. Created all kinds of cool images, random images with pill and NumPy, I think.
[00:15:04] Unknown:
And are there any plans or road maps that you have for the project going forward?
[00:15:10] Unknown:
I think just making sure we always do quarterly releases, which has worked out really well. Any security fixes that come along, possibly some code cleanup. We always love to see new features and image format supported. The documentation's in really good shape now, I think, but, you know, more documentation improvements and also, you know, growing the community. I just saw a blog entry about, oh my z z c h z shell, and their, GitHub, likes or stars is, like, 30 k, which is impressive. 30, 000 people loving a repository about customizing your shell is is very impressive. So I'd love to see Pillow grow to, you know, get the community to grow, to get Pillow to be better software for the foreseeable future.
[00:16:00] Unknown:
So are there any other topics that you would like to talk about or any other questions that I didn't ask that you think I should have?
[00:16:07] Unknown:
No. I just really appreciate you reaching out and hopefully people will learn more about the project and help make it better.
[00:16:14] Unknown:
Great. Absolutely. So for anybody who wants to keep in touch with you and follow what you're up to, what would be the best way for them to do that?
[00:16:21] Unknown:
Let's see. Aclark.net, aclark.net is my business web site. So that's a good way. I have a Twitter although I haven't been Twittering much lately. But from aclark.net you can get to a lot of places about me.
[00:16:36] Unknown:
Okay. Alright. So with that, we will move on into the picks. For my first pick today, I'm gonna choose a website called the minimalist baker. So it's a recipe website with a lot of really great, recipes, particularly for people on restrictive diets. So a lot of the recipes on there are for vegetarian or gluten free or vegan recipes. A lot of really good and innovative foods on there that even despite having a restricted set of foods that you can choose from, they still end up coming out quite tasty. And my next pick is going to be the bisect module from the Python standard library. I was doing some work recently where I needed to index into a list based on whether a number was within a certain range in in between a certain range of numbers from another list. And in searching for the best approach for doing that, I came across the bisect module, which was absolutely perfect for my needs. So you have a list of numbers. So you'd say you need to find out, you know, which quarter a number is in. So if it's between 025, 2550, 1575, etcetera, you know, you you have a list with those integers in it. You use the bisect module to pass in the list and your integer, and then it will give you the index of where that number falls in another list that's 1 element longer. So Wow. Very cool. Yeah. It was really useful, and absolutely perfect for my use case. So I figured just 1 that's pretty invisible until you need it. So I might as well
[00:18:07] Unknown:
try and raise its visibility a little bit more for in case people are in a similar situation. And with that, I will pass it on to you. What do you have, Alex? Alright. Great. I have I'm a musician. So I have a I have a tune that my wife and I got into recently by a band that I've have not paid attention to at all, but seem really cool. And that is Muse. They have a song called, Uprising, which you should check out. I like bands like Nirvana and Catherine Wheel, but these aren't my picks. And for my second pick, since you mentioned Python libraries, I'm gonna say I came across something yesterday called fan static, which seems like a really bad idea. It's storing, static CSS, I guess, and JavaScript resources in Python, but somehow I find compelling. I I think I've came across it once but didn't pay any attention to it. But recently, I have been doing, some Django with React, and for some reason, fan static came across my radar. And I just thought this was the coolest thing ever, but it's probably not.
[00:19:12] Unknown:
But it's interesting. Yeah. Definitely. I'll have to take a look at that. Alright. Well, I appreciate you taking the time out of your day to join us and tell us more about your work with the Python Image Library and Pillow. And, we look forward to seeing it continue on into the future. So thank you very much for your work and for your time. No problem. Thank you. It was a lot of fun. Alright. Have a great night. You too. Bye.
Introduction to Alex Clark and The Pillow Project
Alex's Introduction to Python
Forking the Python Image Library
Challenges and Improvements in Pillow
Original Author's Reaction and Project Maintenance
Team Contributions and Community Involvement
Capabilities and Use Cases of Pillow
Architectural Patterns and Refactoring
Interesting Uses and Future Plans for Pillow
Closing Thoughts and Contact Information