Sök:

Summary | Usage | Source files | References

PhotoView

A PHP script which dynamically generates XHTML code for displaying images, in a structure following the directory structure in which the images are stored. The script extracts Exif information [1] encoded in the digital images, such as exposure time, aperture, date and time of exposure. The script also supports real-time switching between different languages, altering the labels and switches. The PhotoView script forms the server-side engine for the compilations of images you can find in the photography section of this site.

Summary of the script

The user interface to the collection of routines making up the PhotoView script is the top-level routine photoview($directory,$lang,$suffix), where $directory is a string containing the path of the directory to be scanned for images, $lang is the language to be used in displaying labels and titles, and $suffix is the file suffix of the graphic format used, for example "jpg" or "png". So far, only Swedish (sv) and English (en) are valid supported languages.

Suppiled with a string $directory, stating which directory to scan for images to display, the PhotoView script parses the directory structure in the following way:

  1. First the PhotoView extracts the language and view mode to use in the presentation of the images, by reading the parameters 'lang' and 'view' with the PHP statements $_GET["lang"] and $_GET["view"], respectively.
  2. PhotoView then checks if the subdirectories 00-thumbs, 00-lores and 00-hires exist in the directory pointed out by the contents of string $directory.
  3. If the check shows that any of the subdirectories 00-thumbs, 00-lores or 00-hires are missing in the directory, then PhotoView will consider the supplied string $directory to specify an »overview» directory, supposedly containing subdirectories which either are regular image repositories or further overview directories down the hierarchy. PhotoView will hence scan all present subdirectories for title images, which following the convention here used are named 00-title.<suffix>, for example 00-title.jpg.
  4. If the check shows that all of the subdirectories 00-thumbs/, 00-lores/ and 00-hires/ are present in the directory, and the supplied 'view' switch is unset (or set to 'contact'), then PhotoView will display all images present in 00-thumbs/ in »contact sheet» mode, with each image framed as a dia positive.
  5. If the check shows that all of the subdirectories 00-thumbs/, 00-lores/ and 00-hires/ are present in the directory, and the supplied 'view' switch is unset (or set to 'contact'), then PhotoView will display all images present in 00-thumbs/ in »contact sheet» mode, with each image framed as a dia positive.
  6. If, as in the previous case, all of the subdirectories 00-thumbs/, 00-lores/ and 00-hires/ are present in the directory, and the supplied 'view' switch is set to 'slideshow', then PhotoView will display the image selected by the 'id' switch, with this image surrounded by its nearest neighbour images in the directory.
    Example of switch: ?view=slideshow&id=3&lang=en.
  7. The 'id' switch relates to the order of an image in the alphabetical listing of the directory. Hence, if a certain order of the displayed images is required, then the images may be named as '01-....jpg', '02-....jpg', etc.
  8. When displaying the main image in »slideshow» mode, the script will attempt to extract any Exif [1] data encoded in the image. The feature of Exif extraction depends on the configuration of the PHP installation of the server [2]; however, if the Exif support is missing, the script will simply ignore the extraction.

Example of usage

In order to invoke PhotoView for displaying JPEG images in the current directory, simply add the script block to an (X)HTML page:

    <?php include "photoview.php"; photoview(".","en","jpg"); ?>

Current revision

Revision 1.0, as of 12/11/2006. Copyright © Fredrik Jonsson 2006, under GPL

Source files

photoview.php [24 kB] The entire PHP code for the PhotoView script, containing all necessary routines in one single file.
[ download | view source ]

References

[1] For information on the Exchangeable image file format (Exif), see http://www.exif.org/ or the Wikipedia article on http://en.wikipedia.org/wiki/EXIF.

[2] For information on the PHP support for extracting Exif data, see the PHP function reference manual at http://uk.php.net/exif.

Tillbaka till föregående sida

Lämna ett meddelande

Ditt namn:

Din epost-adress: (obligatorisk)

Meddelande:

Generated by ::emailform::

Senast modifierad Wednesday 15 Feb 2023
Denna sajt är XHTML 1.0 Strict