Introduction: Digital Picture Management - Del Weak Pics With Python
Back in the days with film it cost money every time you pressed the shutter button, now “film” is free so we often take duplicates in case the focus, framing or some other detail is off. Sometimes we will take pictures from slightly different angles of zoom. The result is that we have some better pictures but they are often mixed in with a lot of second or third best. If we show these pictures without editing the result is a boring repetitious show. What is needed is a application that lets us quickly review the pictures and eliminate the weak ones while keeping the good ones. This instructable describes a Python program that lets you do that. With a bit more work you can add your own improvements to the program. (Twins picture from Wikipedia )
Step 1: Tools and Materials
Set up the following:
- Working Python Installation - I used 2.7, not sure all components are available in 3.x, if you get it working let me know.
- Download the files here and unzip. Add to your Python environment.
I built and ran this program on Windows 7, Spyder with Python 2.7, it should work in any Python 2.7 environment on any major PC OS, but I have not tested this.
Step 2: Build It
The main program is in image_edit.py run it. Odds are it will not work as there are several dependencies that you probably do not have. I have fixed this with “pip” ( and since I use Spyder “conda” ) After installing the components you should also run them with the update option.
The import statements give most of this away, some of the modules include: shutil, glob, os, wx ( wxPython ), pprint, and PIL ( Image Python Image Library ).
Some of the commands I found useful ( pip has analogs of these commands ). Always end with the update all option just in case.
- conda update --all
- conda install wxpython
- conda update -f six
Step 3: Use It
Run image_edit.py you should get a screen like the first one shown in the picture. Eof stands for end of film, meaning there are no more pictures to show, that is because you need to open a directory, this is done with the first icon on the tool bar. When used you should get a screen like the second one above. All jpg files in the directory should be shown, they are sorted by file name which is normally the same as by date ( if they came from one camera ). Duplicate pictures are generally shown in close proximity. I usually “delete” the obviously poor ones first. ( they are not actually deleted, they are moved to a sub-directory called “” ). Picture classified as duplicates are also moved ( sub-directory called ). As each picture is “processed” the pictures slide to the left and a new picture is brought into view. When you have determined the best picture press ok. As a convenience I have added 3 buttons for picture rotation ( the rotated picture is put in the original directory, the original in a sub-directory called “” ). Just work through all the pictures until “eof” appears for all pictures. The “good” pictures are all in the original directory, the others in various sub-directories. You can process the directory over and over if you wish to refine your selection. You can undo the operations by moving the files back from the sub-directories.
The program should leave the modified date of the files unchanged even if they have be modified, this is nice for later sorting or processing.
Step 4: Modifications
The simplest modifications are made by changing the parameters in parameters.py. Other involove more coding. Make an interesting modification? Let me know, email or comment below.
We have a be nice policy.
Please be positive and constructive.