Remove Solid/Blank Images

In my work role, I need to programmatically clean up blank images mixed in with millions of usable images. For this, I turned to Python and PIL:

from PIL import Image
from sys import argv

script, filename = argv

img =
colors = img.getcolors()

if colors:
    if len(clrs) == 1:
        print str(filename)+": "+"solid color, remove"
    print str(filename)+": "+"has multiple colors, keep."

Set Environmental Variables

When working with login credentials, server addresses, etc you can hide them from git and other viewers by saving them as local environmental variables.


  1. create a .bash_profile if it does not exist yet.
  2. edit the .bash_profile to add or change the variables
  3. activate the .bash_profile

In a terminal/console:

touch ~/.bash_profile
vim ~/.bash_profile
source ~/.bash_profile

To set a new variable in the .bash_profile:

export AWS_KEY=$"foobarkey123"
export AWS_SECRET=$"foobarsecret123"

To use environmental variables in Python:

import os
awsKey = os.environ['AWS_KEY']
awsSecret = os.environ['AWS_SECRET']