Better Templates for iPhoto's BetterHTMLExport
by Dave Sag04/02/2002
In his recent O'Reilly article on iPhoto export filters, Derrick Story made reference to the BetterHTMLExport filter by Simeon Leifer.
|
BetterHTMLExport, at version 1.3 at time of writing, provides significant improvements over the built-in HTMLExport filter, including the option for you to create your own templates.
In this article I will walk you through the process of creating your own template set. I assume that you know a bit about HTML already and you have followed the instructions for installing the BetterHTMLExport.iPhotoExporter by copying the entire 'BetterHTMLExporter.iPhotoExporter' folder you downloaded into the 'iPhoto/Contents/PlugIns' folder. (To open a package up Control/Right click on iPhoto and select 'Show Package Contents')
First up if you have not already done so, select a couple of images in iPhoto, click on 'share' and then 'export'. If you have installed BetterHTMLExport properly you'll see its tab in the top right of the export options pane, as shown to the right.
The default template provided by BetterHTMLExport is not bad, but it's certainly not great. The following comparison shows the difference between the builtin template and the template I made. The HTML code from my new templates also includes appropriate description and keyword fields.
The following thumbnails highlight the difference between the default template and the more detailed and attractive template we will make. You can click on either image to see the outout in detail. Opens in a new window.
![]() |
![]() |
| The default image page output | Image page output from my new template |
For anything other than the most trivial of examples you are going to want to create your own templates.
|
Note: Under MacOSX you put items you only want available to yourself in your local ~/Library folder, and items you want to be globally accessable in your /Library folder at the root level of your startup disk. |
You should create the following folder
~/Library/BetterHTMLExport/templates
Control click on iPhoto to open up the package and copy the contents of the templates folder into the templates folder you just created. Rename the files as follows:
| Old | New |
|---|---|
| builtin.plist | my.plist |
| image.template | myimage.template |
| index.template | myindex.template |
Now if you have installed the OSX Developer tools you will have Apple's own PropertyList editor. This nothing more than an XML editor for editing property lists. If you don't have a PropertyList editor then you can use any text editor to edit property lists.
![]() |
![]() |
| Use the Property editor to edit plists | Or you can use a text editor. |
|
| |
The first thing you will want to do is edit my.plist. The properties you must change are image_template_name, index_template_name, template_description, and template_name. The template_name is the name that will appear in the templates popup menu in iPhoto. The template_description can be anything you like and the file names should match the file names you just created. Assuming all is okay your plist should look something like the one pictured above.
If it doesn't, don't panic. I have zipped up the this example template and it is available for download at http://www.davesag.com/BHTMLXtemplate.zip. Go get it.
A small note about the 'default' item in the plist. This is an undocumented, but fairly obvious feature. If the 'default' item is present and set to '1', BetterHTMLExporter will make that the default template. If more than one template has the default flag set then BetterHTMLExport will pick the first one it finds as being the default. When you are happy with your new template I suggest you make it the default and delete the default from the other templates.

Quit iPhoto and relaunch it. Select a couple of photos and choose 'share' then 'export'. Under the BetterHTMLExport tab click on the 'Advanced options' button. If everything is working okay you will see your new template listed under the templates popup menu. Now we can get into editing the templates themselves.
BetterHTMLExport provides a series of special tags, enclosed in square braces '[...]'. Anyone familiar with template languages will have no problems deciphering this. The template language consist of the following commands. Note that these tags are described more fully in the documentation that comes with BetterHTMLExport.
| command | meaning | example |
|---|---|---|
| [comment some comment text] | for comments in your template that will not be rendered into the final html page | [comment this is a comment] |
| [date {date format}] | displays the date according to the optional date format provided. | [date %a %m/%d/%y %I:%M:%S %p] |
| [datevalue datekey{date format}] | (V1.3 only) displays the date provided in the datekey using to the optional date format provided. | [datevalue imageArchiveDate %a %m/%d/%y %I:%M:%S %p] |
| [each ID value listKey]content[endeach ID] | Repeats the content section of the template for each value in a list. The key 'value' will contain one value from the list referenced by listKey. 'value'_index will hold the index number, starting at zero. | [each rows directRows directTable] Index = [directRows_index] [endeach rows] |
| [if ID leftvalue test rightvalue]true content{[else ID]false content}[endif ID] | Includes the true content section of the template if 'leftvalue test rightvalue' results in true. if there is an else that content will be included if the test results in false. | [if usebackground useColorBackground == YES] <body bgcolor=""> [else usebackground] <body> [endif usebackground] |
| [include path to file] | Includes and parses the content of the specified file. | [include local_header.template] |
| [loop ID value start end increment]content[endloop ID] | Loops from start through to end, incrementing by increment. the value of value is maintained internal to the loop. | [loop test x 1 6 2] [x], [endloop test] would output 1, 3, 5, |
| [{value} key] | Inserts the value of the named key. the expression 'value' is optional | [useColorBackground] |
Some careful picking through the template code you have in myindex.template and myimage.template is all you need to see examples of this language in action. I shall highlight a key change in myimage.template for the purpose of example.
At line 21 of the original template, your current template in this case, the following lines proceed. The code change to make is inserted in bold text.
[if directnavif showDirectNavigation == YES] <td> <table border="0" cellspacing="2"> [each navrowseach directRows directTable] <tr> [each navcolseach directColumn directRows] [if curimgpgif directColumn.imagePageNumber == currentImagePageNumber] <td> <b> [directColumn.imagePageNumber] </b> </td> [else curimgpgif] <td> <a href="[directColumn.imagePageName]"> [directColumn.imagePageNumber] </a> </td> [endif curimgpgif] [endeach navcolseach] </tr> [endeach navrowseach] </table> </td> [else directnavif] <td align="center"><a href="../[indexFileName]#[imagePageName]"> [if showimgtitleif showImageTitles == YES] <h2>[imageTitle]</h2> [else showimgtitleif] <font size="-2">index</font> [endif showimgtitleif] </a></td> [endif directnavif]
The intention here is that if the user has elected not to show direct navigation, as per the checkbox in the BetterHTMLExport UI, then we should show the title here between the two navigation buttons, with a link back to the index page. Of couse if we are not showing the title, then just show the word "index".
|
Related Reading iPhoto: The Missing Manual |
Below the photo we want to add very similar code. If the user has checked 'show title' and not checked 'direct to page navigation' we'll just display the word 'index' in place of the photo title. This looks better than having the image title appear at both the top and bottom of the page.
The other changes are cosmetic and involve the reframing of the image in a table, and installing the text underneath cleanly.
The new template also inserts description and keyword meta tags in the header of the page.
BetterHTMLExport 1.3 comes with a template called Kitchen Sink that exports every piece of data it can. Study these templates and the documentation Simeon provides, as there is a wealth of neat data in there.
Dave Sag is a skilled Object Modeler and Software Designer, using Java as well as other programming environments.
Return to the Mac DevCenter.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 5 of 5.
-
doesn't work
2002-11-30 00:59:17 anonymous2 [Reply | View]
Sounds like a great idea but It doesn't work for me. I lose all ability to export after installing this plug-in. OS 10.2, iPhoto 1.1
-
FILE > EXPORT DOESN'T WORK!
2002-09-14 15:49:26 anonymous2 [Reply | View]
File > Export stopped working out of the blue for me. It just does nothing. I had already used BetterHTMLExport to export some web pages. I have posted this problem at apple forums under iPhoto, but noone answers. I doubt anyone here will help either.
iPhoto 1.1.1
OS X 10.2
iBook 600
-
Export Book from iPhoto
2002-09-10 22:29:26 anonymous2 [Reply | View]
Mr. Sag,
The Book formats in iPhoto offer more flexible layouts because you can have pages with 1, 2, 3 or more photos per page. As outlined below, you can export a Book from iPhoto using BetterHTMLExport and your layout. However, with a Book layout, there is no need for thumbnails because the photos are already reduced in size. Accordingly, I am trying to create an export layout that does not use thumbnails but has one full size image substituted for a thumbnail on your thumbnail page. Clicking on the full size image would not take you to another page. This new layout would provide an alternate to step (9) below. It's fine that BetterHTMLExport continues to make thumbnails and pages - these just would not be referenced and used. I am not a HTML coder and have not been able to edit your layout. Can you help me?
Regards,
Eugene Rooke
erooke@earthlink.net
Following is the procedure for exporting a Book from iPhoto. It's basically a process of creating a Book within iPhoto, previewing the Book and saving each page as a separate photoshop (epsf) file and exporting from iPhoto the epsf pages as a www site.
(1) BetterHTMLExport - Download and install the iPhoto export enhancement BetterHTMLExport from http://www.droolingcat.com/software/betterhtmlexport/ or from versiontracker.com.
(2) BetterHTMLExport - Download and install the additional HTML layout pages for BetterHTMLExport from http://www.davesag.com/BHTMLXtemplate.zip. This layout was written by Dave Sag to give you additional layout options to use with BetterHTMLExport.
(3) iPhoto - Within iPhoto, create album #1, copy your photos to this album and create a Book of these photos. Click the Book button at the bottom of iPhoto, select the number of photos for each page and insert captions for each photo. I prefer this approach, bcause creating a Book (unlike simple exporting) gives you the option to place different numbers of photos on each page.
(4) iPhoto - After assembling a Book, click the Preview button. This assembles the Book and allows you to see each page of the Book (and thumbnails of each page) using the Preview application.
(5) Preview - Within Preview, select Export from the File menu at the top of the screen. Click on each thumbnail page of the Book in order and save each page in a Photoshop format. This is a page by page process. Give each page a different name and for convenience, save them to a single folder (I use a folder on the desktop). Unlike the Photoshop format, the jpg and Tiff formats within Preview always save just the first page of the Book regardless of the page or thumbnail selected.
(6) iPhoto - Within iPhoto, create album #2 and copy your Photoshop photos to this new album #2.
(7) iPhoto - Within iPhoto and with album #2 selected, click the Share button at the bottom of iPhoto and the Export icon from the options that appear below.
(8) iPhoto Export - Select the BetterWebPage tab at the top of the Export screen (it was installed by BetterHTMLExport). Choose 1 column and 1 line. Set your background color or image. I set my image size to 10 times larger than the default or Max Width 64000 and Max Height 48000. Deselect the Show Title and Show Comments options because these insert file names and other text below each photo. Click the Advanced Settings button. Set Max Size and Quality for both thumbnails and images to 100. Set comments to
. Select Direct to Page Links, Links on Top and Links on Bottom. These insert the navigation arrows and page links on each www page. For Template, select My Template test (this was inserted by step (2)) from the templates listed. Pick whether you want a full size photo or the original photo copied to the www site. Click OK and click Export. By default, the www site will be created and copied to the Sites folder in your user folder.
(9) Preview your www site by clicking on the index.html page that was created in your Sites folder and navigate through the pages using the arrow buttons or page links. Better HTMLExport and the other export templates create thumbnails of each Book page. Click on the thumbnail to see the full size Book Page. You then can also navigate from full size Book page to full size Book page.
-
Export Book from iPhoto
2005-04-06 14:16:11 cephoto [Reply | View]
Eugene,
I was looking for an article just like yours never thinking I'd find
it. I want to use the feature in iPhoto "Book" to create a slide show of my portfolio with the assembled page images. Your article details just this only at step #4 you say-
(4) iPhoto - After assembling a Book, click the Preview button. This assembles the Book and allows you to see each page of the Book (and thumbnails of each page) using the Preview application.
(5) Preview - Within Preview, select Export from the File menu at the top of the screen. Click on each thumbnail page of the Book in order and save each page in a Photoshop format. This is a page by page process. Give each page a different name and for convenience, save them to a single folder (I use a folder on the desktop). Unlike the Photoshop format, the jpg and Tiff formats within Preview always save just the first page of the Book regardless of the page or thumbnail selected.
Well, I'm using iPhoto 4 and when you click "Preview" the Book, it
opens in a window within iPhoto, not Preview, and does not have the thumbnails mentioned in #5. And going to the File Menu with the preview window active, Export is grayed out. Clicking any image in the Book thumbnails, in iPhoto/Book allows you to Export but only all of the original images in the album, not pages in the book.
To be clear, I do not want to publish the pages to the web. I only want to create a QT Movie with the pages in the iPhoto Book.
What am I doing wrong??
Thanks,
Carl Edwards











Thanks for what you did provide.