Managing Digital Pictures
A relatively new and daunting task the everone with a digital camera finds themself faced with is "How do I manage the thousands of picture files in a sane manner?" and "How can I find picture X,Y&Z?". Gone are the days of simply looking through your picture box or drawer of negatives and prints all carefully saved in the envelope that you received when your film was developed. Also gone is the ability to jot a quick note of the back or your picture to remind yourself of the special significance of the photo. Here we will look a a few approaches to answering those questions and putting in place a solid photo management routine that works equally well for 100 or 100,000 photos. I will try and cover several approaches from simple naming conventions that help keep you from pulling your hair out, to complete indexed webhosted photo management using gallery2.[1]
Logical Organization
Before you do anything as far as indexing your photos or adding them to photo management or web applications, you shall organize your picture files into a sane, logical order with sane and meaningful filenames so that regardless what application you use to view or publish your photos you can navigate and find individual or groups of photgraphs. I cannot emphasize this enough. Once you approach 10,000 files, if you haven't put in place a good basic system of organization, the process of managing your pictures will become a nightmare.
Basic Logical Directory Structure
Directory Structure
The directory listing to the left shows the resulting directory structure created by the exiftool utility with the options described below. This is my preference for the picture directory layout. Regardless what you use to display your photos, by virtue of the structure, your photos are all organized by year, month, day and time. Further, in Gallery2, you can give your month directories their proper names (Jan., Feb, etc.) while preserving the proper sort order by sorting on the directory name. (01, 02, etc.).
Photo Filenames
The filenames are equally important to any logical structure. Take for example the files in 2008/01/ shown to the left. Each filename contains the complete date and time information for the picture in the form YYYY-mm-DD-HHMMSS.jpg. Why the year and month info again? Think about the name if you copied a picture somewhere else for use in another project. Without the year and month information, the filename becomes meaningless.
CLI Tools to Help Organize Your Files
A majority of digital cameras provide the date and time the photograph was taken as part of the digital file. This is called exif data. This is your saving grace for being able to salvage respectable organization out of huge collection of picture files you have stuffed in one or more loosely organized directories. Using this information combined with few basic command line tools will allow you to create order from chaos. The basic approach is to automate the reading of the exif data and the renaming and segregating of your picture files into a logical directory structure.
Both perl and bash have the ability to parse directories of pictures and to read exif information from the files and then to rename and reorder the files based on that information. The primary utilities available are exiftool and jhead. (both have windows executables as well) The utility exiftool illustrates the point. Running 'exiftool -s filename' will provide you with a list of exif tags available in your picture. Sample Listing of exif Parameters.
Using exiftool to Create The Structure
The following two forms of exiftool will read each jpg file in, for example, the directory 'year2008' and move the files to the directory /home/pictures/family_pictures in a four-digit year subdirectory and a two-digit month subdirectory with a file name of the form 'YYYY-mm-DD-HHMMSS.jpg' based on the time the picture was taken. This first form is useful for digital photographs that contain the CreateDate parameter:[2]
exiftool '-FileName<CreateDate' -d \ /home/pictures/family_pictures/%Y/%m/%Y-%m-%d-%H%M%S.%%e \ year2008/*.jpg
If your pictures weren't originally digital, but you received a CD along with your printed proofs when your original film was developed, a second form will use the file modify date, which is usually the date the photos were developed to reorganize your pictures.
exiftool '-FileName<FileModifyDate' -d \ /home/pictures/family_pictures/%Y/%m/%Y-%m-%d-%H%M%S.%%e \ year2008/*.jpg
Depending on where your photos were developed, you may need to manipulate the file create time if the developer used the same date and time as the file create time exif tag. It's not uncommon.
Using jhead
The jhead package also provides similar rename capability using the '-n[format-string]' option. It also provides the -nf option to provide a bit more control concerning whether files are over-written or whether a number sequence is added if similar names are encountered. This can get around some of the problems with the developed photos mentioned above with the same file modify date.
In timed comparisons, jhead is much faster on the file rename, but lacks the ability to handle additional directory information to accomplish my task of renaming and moving to a specified directory. Asking jhead to rename the files and put them in the /home/pictures/family_pictures/%Y/%m/%Y-%m-%d-%H%M%S directory simply resulted in an error. However, using jhead combined with the find command and a couple of lines of bash scripting would have accomplished the same thing -- probably in a fraction of the time. (however on the phenom 9850 with 4 Gig of OCZ Platinum 1066, the differences are shades of gray.)
All told, both exiftool and jhead will accomplish the task. exiftool is a bit more flexible for manipulating directories during the rename, but directory-by-directory comparison shows jhead to be the speed demon. The actual time test results between jhead and exiftool for renaming 82 images were as follows:
time comparison: jhead & exiftool
time jhead -n%Y-%m-%d-%H%M%S *.jpg real 0m0.213s user 0m0.008s sys 0m0.120s time exiftool '-FileName<CreateDate' -d \ %Y/%m/%Y-%m-%d-%H%M%S.%%e *.jpg 1 directories created 82 image files updated real 0m9.904s user 0m9.369s sys 0m0.196s
Note: the exiftool time renaming in the same directory was: real 0m9.726s, user 0m9.313s, sys 0m0.188s.
Gallery2 - The Only Web Management Suite in its Class
Getting and Installing Gallery2
Installing From a Source Package
If you are satisfied with the latest released version of Gallery2, then simply download the latest stable source package (ver. 2.3) from sourceforge.net: Gallery2 Download Link. After downloading the source package, simply change directories to your webserver's document root and unzip the package as follows:
cd /srv/http/htdocs tar -xzf gallery2file.tar.gz
Checking Out a SVN Copy
If you are looking for the latest-greatest Gallery2 packaging, then I would recommend checking a copy of Gallery2 out from the svn repository. The svn copy contains all of the bug fixes since the last release, but is slightly larger due to the additional svn information. To check out the svn version, change directories into your webserver's document root and checkout the svn version as follows:
cd /srv/http/htdocs svn checkout https://gallery.svn.sourceforge.net/svnroot/gallery/trunk/gallery2
Configuring Gallery2
After the package is loaded on your webserver, simply point your browser to http://www.yourserver.com/gallery2 and you will be guided through the setup process.
Note: If you have not already started, secured and configured your mysql server, do it now. See the MySQL section of my server setup page: MySQL - Securing Your Server All of gallery2's configuration and photo information is stored in a MySQL database.
Currently Under Construction -- Be Patient
- Gallery2 is a fantastic feature rich PHP & MySQL photo web application that allows public/private access to your photos: Gallery2 Site
- Adapted from examples given in the exiftool man page under the Rename Examples. The time and date format characters are the normal parameters from the strftime man page.