Juli, 2009


21
Jul 09

Migrating from Coppermine to SmugMug with 100 LOC (or so)

Since I was spending a great deal of last weekend’s time on migrating my Coppermine photo albums over to my brand-new SmugMug account, I thought it might be helpful to others to summarize my experiences here. First of all, the whole process (transferring several thousands of photos uploaded over the last 7 years into my Coppermine installation) went pretty smooth, that is mostly because of the brilliant pysmug Python library by Brian Zimmer as well as SmugMug great and reliable API (provided as a RESTful web-service).

Here is a step-by-step instruction on how to upload your existing coppermine albums into your SmugMug account. You need to have generated an API Key inside the SmugMug control panel for the upload process.

(1) Download and install pysmug package on your system, usually boils down to something like:
tar xvzf pysmug-0.5.tgz
cd pysmug-0.5
sudo python setup.py install

(2) Prepare SmugMug API access by setting up ~/.pysmugrc according to your individual user ID and API Key:
[pysmug]
login=login_withHash
smugmug=pysmug.SmugTool

[login_withHash]
APIKey = UZm0Y4...
userId = 999999
passwordHash = $1$.s...

(3) (optional) If your camera happens to embed rotation information as EXIF inside the JPEGs, you might want to rotate the photos before uploading accordingly. Unfortunately the upload API call does not support rotating on the SmugMug server-side, and also it seems like the rotation information got somehow eaten on upload. A small bash script using the great ImageMagick toolkit can do the conversion in a moment:

#!/bin/bash
path=$1
find $path* -type f -iname "*.jpg" ! -iname "thumb*" ! -iname "square*" ! -iname "medium*" | while read FILE
do
echo $FILE
convert -auto-orient "$FILE" "$FILE"
done

(4) Download my Python script cpg2smugmug.py and modify the header according to your Coppermine installation (specifically the MySQL connection settings and the path to your album root directory).

(5) Execute python cpg2smugmug.py and watch how the categories and albums got created and after wards the photos (on an album by album batch) uploaded into your SmugMug account.

Have fun!