NAME

Photography::Website - Photography Website Generator

SYNOPSIS

    use Photography::Website;

    my $source      = "$ENV{HOME}/Pictures";
    my $destination = "$ENV{HOME}/public_html";

    # Process the pictures tree
    my $website = Photography::Website::create_album($source);

    # Generate the website
    Photography::Website::generate($website);

DESCRIPTION

The Photography::Website module contains the core of the Photog! photography website generator. Please refer to photog for a more general introduction on how to run Photog! and how to configure it. All of the configuration options are documented in Photography::Website::Configure. If you want to learn about the internals of Photog!, read on.

A photography website is generated in two stages. The first stage searches the source directory tree for images and optional photog.ini files, and processes them into a data structure of nested albums. An album is simply a hash of configuration variables one of which ($album->{items}) references a list of further hashes. This stage is kicked off by the create_album() function.

The second stage loops through this data structure, compares all the sources with their destinations, and (re)generates them if needed. It builds a website with nested album pages that contain image thubmnails and album preview thumbnails. The structure of album pages mirrors the structure of the source image directory. This process is started with the generate() function.

FUNCTIONS

create_album($source[, $parent])

The main entry point for creating a website structure. $source should be a directory name, $parent is only used when this function is called recursively. Returns an album with nested sub-albums that represents the source directory tree.

generate($album)

The second main entry point that generates the actual website images and HTML files at the destinations specified inside the $album data structure. Returns true if the index of $album has been regenerated.

update_image($image[, $force])

Given an $image node, checks if the image source is newer than the destination. If needed, or if $force is true, it builds new destination files. Returns true if any images have been (re)generated.

update_album($album[, $force])

Given an $album node, first deletes any destination files that don't have a corresponding source. Then it (re)builds the album's preview and index if an update is needed or if $force is true. Returns true if any changes have been made at the destination directory.

build_image($image)

Builds the image's destination files, by shelling out to the the watermark or scale and thumbnail commands.

build_index($album)

Given an $album node, builds an album preview image and the album's index.html after sorting the album's images according to Exif dates.

create_preview($album)

Creates an album preview image by making a random selection of the album's images and calling the photog-preview command.

select_images($album)

Returns a list of image paths that are eligible for inclusion in an album preview. It makes sure that the list only contains images whose filename does not appear in the parent album. The reason for this is that the author of Photog! likes to show the best photographs from an album on the front page, but not also have those photographs included in an album preview.

list($dir)

Returns a list of absolute pathnames to all the files and directories inside $dir.

is_newer($file1, $file2)

Determines the modification times of $file1 and $file2 (which should pathnames). It both files exist and $file1 is newer than $file2, it returns true. Beware: if both files are of the same age, $file1 is not newer than $file2.

exifdate($file)

Extracts the value of the Exif tag DateTimeOriginal from the provided image path, converts it to ISO 8601 format, and returns it. Prints a warning and returns 0 if the Exif tag could not be found.

SEE ALSO

photog, Photography::Website::Configure

AUTHOR

Photog! was written by Jaap Joris Vens <jj@rtts.eu>, and is used to create his personal photography website at http://www.superformosa.nl/