iphoto2spgm.sh is a shell script for converting iPhoto exported "web albums" to be used with SPGM. Before proceeding further, a word about SPGM. SPGM is the easiest-to-use web photo gallery software that I have ever seen. It only requires PHP - no MySQL, no GD, no ImageMagick, no XML libraries, no nuisance.
iPhoto's web albums have a lot to be desired. First off, there is no control on display styles. Second, there is no way to display the dates of photographs. And lastly, the only way to add or subtract photos from the web albums is to re-export the entire album and upload all the files anew. iPhoto changes the numbering every time photos are exported.
To make things easier, I wrote a shell script iphoto2spgm.sh which creates an SPGM compatible gallery directory from an iPhoto exported web album. The concept is quite simple - use the thumbnails and photos generated by iPhoto's web album export, browse through the HTML pages and extract the page titles and comments, and use an EXIF reader software - jhead - to extract EXIF data, such as date and time of the photograph, and camera model.
The script automatically generates picture descriptions in "pic-desc.txt", and the gallery directory is ready to be uploaded into the SPGM gallery area. Details on how to use SPGM are available here
A quick tutorial on how to use the script is given here. We will walk through the creation of a sample iPhoto web album and using the script to generate an SPGM compatible gallery.
Select the pictures you want for your album in iPhoto:
9 pictures have been selected.
Export the photos to a web album:
Ensure that the thumbnail and image sizes are as per your needs, and the "Show title" and "Show comment" options are clicked on.
Create a directory in which the web album files will be stored:
Note: You must then run the iphoto2spgm.sh script inside this directory.
Open Terminal, and change the path to the export directory created in Step 3. In this example, the following files and directories will be created:
saumil@knightrider:~/Desktop/my_photos$ ls -la total 4 drwxr-xr-x 6 saumil staff 204 Jan 25 13:13 ./ drwxr--r-- 12 saumil staff 408 Jan 25 13:14 ../ drwxr-xr-x 11 saumil staff 374 Jan 25 13:13 my_photos-Images/ drwxr-xr-x 11 saumil staff 374 Jan 25 13:13 my_photos-Pages/ drwxr-xr-x 11 saumil staff 374 Jan 25 13:13 my_photos-Thumbnails/ -rw-r--r-- 1 saumil staff 2159 Jan 25 13:13 my_photos.html
From here, run iphoto2spgm.sh
saumil@knightrider:~/Desktop/my_photos$ /usr/local/bin/iphoto2spgm.sh iphoto2spgm.sh - by Saumil Shah Creating my_photos... checking for my_photos-Images... checking for my_photos-Pages... checking for my_photos-Thumbnails... Copying images... Copying thumbnails... Processing (1/9) 0.jpg, Sunflowers at the Singapore airport - 3 Processing (2/9) 1.jpg, Lotus flowers at Nirma - 4 Processing (3/9) 2.jpg, Sidi Saiyed Jali - 6 Processing (4/9) 3.jpg, The cannons of Meherangarh Fort Processing (5/9) 4.jpg, Nathmalji ki haveli Processing (6/9) 5.jpg, Paintings in the rooms of the palace - Jaisalmer Processing (7/9) 6.jpg, Petronas Towers Reflection Processing (8/9) 7.jpg, Nagaru camp at 12500 feet Processing (9/9) 8.jpg, Landing into Hong Kong - 11
The script displays the progression, and when it finishes, a new directory with the same name as the export directory will be created.
saumil@knightrider:~/Desktop/my_photos$ ls -la total 4 drwxr-xr-x 7 saumil staff 238 Jan 25 13:15 ./ drwxr--r-- 12 saumil staff 408 Jan 25 13:14 ../ drwxr-xr-x 22 saumil staff 748 Jan 25 13:15 my_photos/ drwxr-xr-x 11 saumil staff 374 Jan 25 13:13 my_photos-Images/ drwxr-xr-x 11 saumil staff 374 Jan 25 13:13 my_photos-Pages/ drwxr-xr-x 11 saumil staff 374 Jan 25 13:13 my_photos-Thumbnails/ -rw-r--r-- 1 saumil staff 2159 Jan 25 13:13 my_photos.html
Inside the new "my_photos" directory, you will find the thumbnails and picture descriptions of the photos.
saumil@knightrider:~/Desktop/my_photos$ cd my_photos saumil@knightrider:~/Desktop/my_photos/my_photos$ ls -la total 1756 drwxr-xr-x 22 saumil staff 748 Jan 25 13:15 ./ drwxr-xr-x 7 saumil staff 238 Jan 25 13:15 ../ -rw-r--r-- 1 saumil staff 158357 Jan 25 13:15 0.jpg -rw-r--r-- 1 saumil staff 127293 Jan 25 13:15 1.jpg -rw-r--r-- 1 saumil staff 292308 Jan 25 13:15 2.jpg -rw-r--r-- 1 saumil staff 124620 Jan 25 13:15 3.jpg -rw-r--r-- 1 saumil staff 212988 Jan 25 13:15 4.jpg -rw-r--r-- 1 saumil staff 265646 Jan 25 13:15 5.jpg -rw-r--r-- 1 saumil staff 197711 Jan 25 13:15 6.jpg -rw-r--r-- 1 saumil staff 135431 Jan 25 13:15 7.jpg -rw-r--r-- 1 saumil staff 83474 Jan 25 13:15 8.jpg -rw-r--r-- 1 saumil staff 19340 Jan 25 13:15 _thb_0.jpg -rw-r--r-- 1 saumil staff 14891 Jan 25 13:15 _thb_1.jpg -rw-r--r-- 1 saumil staff 19452 Jan 25 13:15 _thb_2.jpg -rw-r--r-- 1 saumil staff 14321 Jan 25 13:15 _thb_3.jpg -rw-r--r-- 1 saumil staff 19178 Jan 25 13:15 _thb_4.jpg -rw-r--r-- 1 saumil staff 23217 Jan 25 13:15 _thb_5.jpg -rw-r--r-- 1 saumil staff 17399 Jan 25 13:15 _thb_6.jpg -rw-r--r-- 1 saumil staff 14546 Jan 25 13:15 _thb_7.jpg -rw-r--r-- 1 saumil staff 14122 Jan 25 13:15 _thb_8.jpg -rw-r--r-- 1 saumil staff 2394 Jan 25 13:15 pic-desc.txt -rw-r--r-- 1 saumil staff 55 Jan 25 13:15 pic-sort.txt
This directory may now be copied into the SPGM gallery area.
After the directory "my_photos" (the one created by the script, not iPhoto) is copied into the SPGM gallery area, you can preview the new gallery by pointing your browser to it.
Clicking on a thumbnail will show you the picture details, as follows:
That's it. The script is very simple and easy to use. If you have "jhead", the script will automatically get EXIF data from the pictures. SPGM is highly configurable - you can customise it to your tastes and liking. The script is very easy to modify as well, and reasonably well documented. It is free for use, and if you like it and/or come up with a better modified version of it, email me at <saumil _at_ saumil _dot_ net>, and I will include it here. Enjoy!