Head of Digital Marketing @Bronco. Lover of Python and Data.

Image Manipulation With Python

So having recently got married, my Mrs wanted all the wedding photos turning into grey scale, I originally planned to do this with pixlr.com one at a time as I thought she only wanted a few doing - it turned out to be all of them and there are around 600 of them!

I took this as an opportunity to extend my python knowledge and I ended up with this...

from PIL import Image, ImageFilter
import glob

    for files in glob.glob('*.*'):
        im = Image.open(files).convert('L')
        print files
        im.save("grey_" + files)

This runs through all images in the directory the script is ran in and makes a grey scale version of each with the file name grey_original_file_name.jpg

Give Your Inbox Some Love

What You'll get?
  • Posts like this delivered straight to your inbox!
  • Nothing else.
Comment Policy

Any code snippets more than a line or 2, please include as a link to a gist

comments powered by Disqus