Ultrashock Forums > Development > Server Side
PHP - EXIF data together with slideshowpro

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
PHP - SOLVED - EXIF data together with slideshowpro
Old 2008-02-09 Last edited by klous-1 : 2008-02-20 at 01:05.

Hi all,

Basically I have an album structure;

Gallery/Album1...Album2.../large

And also thumbnails;
Gallery/Album1...Album2.../thumbs


I am using a PHP script to auto generate an XML for the slideshows photo content, and am trying to add a section of script to show the EXIF caption data (or XMP IPTC if it's easier?) from the respective pictures, for the caption in the XML/slideshow.

I think I'm way off, as I'm a complete novice, I am trying this (added to the full original script further below):

I get no errors, but no 'geoffin' data either and I've tried several EXIF fields with no joy, eventually I want to use captions, but I'm using these other fields to test it out as I was hoping to be more likely to find them.

PHP Code:
 // read EXIF headers

           // Album tag
            
$o .= "\t" '<album title="' $title '" description="" lgPath="' $loc_path 

$large_folder '/"' $tn $atn '>' "\n";
            
            
// Cycle through images, adding tag for each to XML
            
foreach($images as $i) {

                
//EXIF description
                
            
{
                       
$exif exif_read_data($loc_path $large_folder '/' $i0true);
                   
$caption $exif['IFD0']['software']; 
            }
            
                
$link '';
                if (isset(
$_GET['link'])) { $link $loc_path $large_folder '/' $i; }
                
$o .= "\t\t" '<img src="' $i '" caption="' $caption '"  link="' 

$link '" />' "\n"
            }
            
            
// Close the album tag
            
$o .= "\t</album>\n"


AND the full script::

PHP Code:

<?php
    
    
/**************************************************************************
    
    XML Generator for SlideShowPro
    Brad Daily - slideshowpro.net
    
    For instructions, see the readme.txt file that accompanied this download.
    
    This script is governed by the following license:
    http://creativecommons.org/licenses/by-nc-sa/3.0/us/
    
    **************************************************************************/
    
    /*
        CONFIGURATION
    */
    
    // Name of the folder in each album's folder that contains the full size imagery
    
$large_folder 'lg';
    
    
// Name of the folder in each album's folder that contains the thumbnails
    
$thumb_folder 'tn';
    
    
// Name of your album preview image. Should be placed at the root of each album's folder. 

(Optional)
    
$album_preview_name 'albumPreview.jpg';
    
    
/*
        END CONFIGURATION 
        (DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING)
    */
    
    // Set up paths
    
define('DS'DIRECTORY_SEPARATOR);
    
$dir dirname(__FILE__);
    
$server 'http://' $_SERVER['HTTP_HOST'];
    
$rel_path str_replace('images.php'''$_SERVER['PHP_SELF']);
    
$path $server $rel_path;

    
// Find all folders in this directory
    
$albums = array();

    
$d dir($dir);
    while (
false !== ($folder $d->read())) {
        if (
$folder != '.' && $folder != '..' && is_dir($folder)) {
            
$albums[] = $folder;
        }
        
            
                
    }
    
$d->close();
    
    
// Start writing XML
    
$o '<?xml version="1.0" encoding="utf-8"?>' "\n<gallery>\n";
    
    
// Cycle through albums
    
foreach($albums as $album) {
        
// Path variables
        
$loc_path $path $album '/';
        
$full_path $dir DS $album;
        
        
// Find images in the large folder
        
$images = array();
        
$d2 dir($full_path DS $large_folder);
        while (
false !== ($image $d2->read())) {
            { if (
eregi('.jpg|.gif|.png|.swf|.flv'$image)) {
                
$images[] = $image;}
            
            
                
                }}
        
$d2->close();
        
        
// Only write the album to XML if there are images
        
if (!empty($images)) {
            
natcasesort($images);
            
// Pretty up the title
            
$title ucwords(preg_replace('/_|-/'' '$album));

            
// See if there is an album thumb present, if so add it in
            
if (file_exists($full_path DS $album_preview_name)) {
                
$atn ' tn="' $loc_path $album_preview_name '"';
            } else {
                
$atn '';
            }
            
            
// Only write tnPath if that folder exists
            
if (is_dir($full_path DS $thumb_folder)) {
                
$tn ' tnPath="' $loc_path $thumb_folder '/"';
                
                
        

            }
            
            
// Album tag
            
$o .= "\t" '<album title="' $title '" description="" lgPath="' $loc_path 

$large_folder '/"' $tn $atn '>' "\n";
            
            
// Cycle through images, adding tag for each to XML
            
foreach($images as $i) {

                
//EXIF description
                
            
{
                       
$exif exif_read_data($loc_path $large_folder '/' $i0true);
                   
$caption $exif['IFD0']['software']; 
            }
            
                
$link '';
                if (isset(
$_GET['link'])) { $link $loc_path $large_folder '/' $i; }
                
$o .= "\t\t" '<img src="' $i '" caption="' $caption '"  link="' 

$link '" />' "\n"
            }
            
            
// Close the album tag
            
$o .= "\t</album>\n";
        }
    }
    
    
// Close gallery tag, set header and output XML
    
$o .= "</gallery>";
    
header('Content-type: text/xml'); 
    die(
$o);
?>
Thanks to anyone who can help!
Nick
postbit arrow 1 comment | 1779 views postbit arrow Reply: with Quote   
Registered User
klous-1 is offline
seperator
Posts: 2
2008-02-09
seperator

Ultrashock Member Comments:
klous-1 klous-1 is offline 2008-02-10 #2 Old  
Last edited by klous-1 : 2008-02-20 at 01:11.
OK, I soved this.

Script below which might be useful for people.

The PHP will autogenerate a XML file for a gallery containing multiple albums. It also looks for thumbnails and album preview thumbnails. The album description is the EXIF data field [IFD0][ImageDescription] (this can be edited with exifer easily). Also captions for each individual photo are taken from the same EXIF field, but from each of the full size images.

It is just a small edit of the free PHP from slideshowpro.
PHP Code:
<?php
    
/**************************************************************************
    
    XML Generator for SlideShowPro
    Brad Daily - slideshowpro.net
    
    For instructions, see the readme.txt file that accompanied this download.
    
    This script is governed by the following license:
    http://creativecommons.org/licenses/by-nc-sa/3.0/us/
    
    **************************************************************************/
    
    /*
        CONFIGURATION
    */
    
    // Name of the folder in each album's folder that contains the full size imagery
    
$large_folder 'lg';
    
    
// Name of the folder in each album's folder that contains the thumbnails
    
$thumb_folder 'tn';
    
    
// Name of your album preview image. Should be placed at the root of each album's folder. (Optional)
    
$album_preview_name 'albumPreview.jpg';
    
    
/*
        END CONFIGURATION 
        (DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING)
    */
    
    // Set up paths
    
define('DS'DIRECTORY_SEPARATOR);
    
$dir dirname(__FILE__);
    
$server 'http://' $_SERVER['HTTP_HOST'];
    
$rel_path str_replace('images.php'''$_SERVER['PHP_SELF']);
    
$path $server $rel_path;

    
// Find all folders in this directory
    
$albums = array();

    
$d dir($dir);
    while (
false !== ($folder $d->read())) {
        if (
$folder != '.' && $folder != '..' && is_dir($folder)) {
            
$albums[] = $folder;
        }
        
            
                
    }
    
$d->close();
    
natcasesort($albums);
    
    
// Start writing XML
    
$o '<?xml version="1.0" encoding="utf-8"?>' "\n<gallery>\n";
    
    
// Cycle through albums
    
foreach($albums as $album) {
        
// Path variables
        
$loc_path $path $album '/';
        
$full_path $dir DS $album;
        
        
// Find images in the large folder
        
$images = array();
        
$d2 dir($full_path DS $large_folder);
        while (
false !== ($image $d2->read())) {
            { if (
eregi('.jpg|.gif|.png|.swf|.flv'$image)) {
                
$images[] = $image;}
            
            
                
                }}
        
$d2->close();
        
        
// Only write the album to XML if there are images
        
if (!empty($images)) {
            
natcasesort($images);


            
// Pretty up the title
            
$title ucwords(preg_replace('/_|-/'' '$album));

            {
// See if there is an album thumb present, if so add it in
            
if (file_exists($full_path DS $album_preview_name)) {
                
$atn ' tn="' $loc_path $album_preview_name '"';
            } else {
                
$atn '';
            }
            
            
//Get Album Description from Album Thumbnail EXIF
            
{    $pathtoatn $album.DS.$album_preview_name;
                
                
                       
$exifalbum exif_read_data($pathtoatn,0,true);
                
$albumdescription $exifalbum[IFD0][ImageDescription];
             }}

            
// Only write tnPath if that folder exists
            
if (is_dir($full_path DS $thumb_folder)) {
                
$tn ' tnPath="' $loc_path $thumb_folder '/"';
            }                
        
            
            
// Album tag
            
$o .= "\t" '<album title="' $title '" description="' $albumdescription '" lgPath="' $loc_path $large_folder '/"' $tn $atn '>' "\n";
            
            
// Cycle through images, adding tag for each to XML
            
foreach($images as $i) {

            
                {    
$imagepath $album.DS.$large_folder.DS.$i;    }
                
            {    
//EXIF description
                
                
                       
$exif exif_read_data($imagepath,0,true);
                
$caption $exif[IFD0][ImageDescription];
             }


            
                
$link '';
                if (isset(
$_GET['link'])) { $link $loc_path $large_folder '/' $i; }
                
$o .= "\t\t" '<img src="' $i '" caption="' $caption '"  link="' $link '" />' "\n"
            }
            
            
// Close the album tag
            
$o .= "\t</album>\n";
        }
    }
    
    
// Close gallery tag, set header and output XML
    
$o .= "</gallery>";
    
header('Content-type: text/xml'); 
    die(
$o);
?>



//PHP code perhaps
//$dir="images/Products";
//$image=exif_thumbnail($dir."/".$_GET['file']);
//header("Content-Type: image/jpg");
//echo $image;
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: