Saturday, February 19, 2005

My Photo Importer

I wrote a program to import my photos. With all my searching, I didn't find anything that did it the way I want. With my own program I can do anything. I've kinda been looking for projects to combine my two hobbies: programming and photography. This seemed like a fun thing to do this afternoon.
 
Here's my first version. It lets you specify:
  • Import directory
  • Destination Directory
  • Folder to create
The import directory defaults to "f:\". The destination directory defaults to my pictures directory. I had to make the dialog box really wide, because some brainiac at Microsoft though it was a good idea to put my pictures in a directory like this: "C:\Documents and Settings\Tod\My Documents\My Pictures\". Way back in the day it was "C:\My Pictures". If you left it up to me I'd make it: "C:\Tod\Pictures". Long paths and paths with spaces suck. The "folder to create" defaults to "Photos_Feb_19_2005" with the "Photo" part highlighted and with the focus. I can type something like "San_Mateo" and press enter and it will start copying the files to "San_Mateo_Feb_19_2005". That's the directory format I decided on.
 
My program will search through all the subdirectories under the import directory. My 20D camera is silly and makes lots of annoying subdirectories that I don't want to pay attention to.
 
It renames the files as it copies them. The source is like "IMG_1234.JPG". This filename is bad because:
  • the extension should be lowercase
  • it's not unique, because I have two cameras that use this format and the number space is going to wrap.
  • it doesn't sort well when we go out and use two cameras at the same time. I want it to sort by picture taken date. Last modified date would work, but when you rotate the image that date changes. I could use the EXIF picture taken date, but that makes the directory sort slowly and also not all image viewers will sort by that.
The file format I choose was date-time-index. So "IMG_1234.JPG" taken today at 9:18:24 AM would turn into "050219-091824-1234.jpg". This is a reasonably short file name that will sort correctly and is unique. (ok, if I take my two cameras and shot at exactly the same time when they are on exactly the same index number I'll get a collision, but I'll chance that.) It's easy to find the corresponding original file because it keeps the 1234 part.
 
When my program copies the files, it creates the new directory with a "favorites" directory under it. This is where I later will copy the files that I like so I can find them quickly.
 
If there are any raw (.cr2) files in the import directory it will create a subdirectory called "raw". It will try to find the matching jpg file and use the last modified time from that so that the file prefixes will match. The last modified time is a few seconds off between the .jpg and .cr2.
 
There's still a few things I want to add to my importer:
  • Directory browsing buttons for import and destination directories.
  • History in a combo drop down for import, destination, and folder edit boxes.
  • A cancel button.
  • It doesn't keep drawing after it loses the focus or something. Yeah fun, drawing bugs.
  • Auto-open directory before it starts copying so I can open them in an image view before it's done.