The Ultrashock Ultra Bundle
  • Home
  • Community
  • Forum
  • Development
  • Server Side
  • Thread
  •  
  • Previous topic
  • Next topic
Sign up to post

Development
 Server Side

  • klous-1 Author 
    • 2430 
    • 0 
    • 1 
    EXIF data together with slideshowpro
    klous-1

    Last reply Feb 10 2008, 04:04 PM

    by klous-1

    Posted: Feb 09 2008, 05:59 PM

    by klous-1

     

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] // 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 . ‘/’ . $i, 0, true);
      $caption = $exif[‘IFD0’][‘software’];
  }
 
  $link = ‘’;
  if (isset($_GET[‘link’])) { $link = $loc_path . $large_folder . ‘/’ . $i; }
  $o .= “\t\t” . ‘[img]’ . $i . ” caption=”’ . $caption . ’”  link=”’ .

$link . ’” [/img]’ . “\n”;
  }
 
  // Close the album tag
  $o .= “\t</album>\n”;
[/PHP]

AND the full script::

[PHP]

<?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 . ‘/’ . $i, 0, true);
      $caption = $exif[‘IFD0’][‘software’];
  }
 
  $link = ‘’;
  if (isset($_GET[‘link’])) { $link = $loc_path . $large_folder . ‘/’ . $i; }
  $o .= “\t\t” . ‘[img]’ . $i . ” caption=”’ . $caption . ’”  link=”’ .

$link . ’” [/img]’ . “\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]

Thanks to anyone who can help!
Nick

  1 REPLY
 
klous-1 Author 
1  
klous-1

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]<?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” . ‘. $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;

 

[/PHP]

  • 10 February 2008 04:04 PM
  •  
  •   Log in or join for free to make a comment.
 
Topic actions
  •  Share on Facebook
  •  Share on Twitter
Topic Categories
  •  Show All Topics
  •  Development
    •  Server Side
    •  Client Side
  •  Creative Software
    •  Web
    •  Video
    •  3D
    •  Illustrator
    •  Photoshop Battles
    •  Photoshop
  •  Design
    •  Typography
    •  Resources & Insight
    •  Checkpoint
  •  Career
    •  Copyright Matters
    •  Advice & issues
    •  Job Seekers
    •  Job Offers
  •  Flash
    •  UltraMath
    •  OOP
    •  Third Party Tools
    •  Open Source alternatives
    •  Data Communication
    •  Components
    •  Flex
    •  AIR
    •  Flash Lite
    •  Flash Professional
    •  Flash Newbie
    •  ActionScript
    •  XML
  •  Lounge
    •  Polls
    •  Random Chat
    •  Showcase And Critique
    •  BombShock Award Nominations
  •  Community Essentials
    •  BombShock Award Winners
    •  Tutorials
    •  Interviews
    •  News
    •  Bitmap tutorials
Popular Topics
  • Sort by: 
  • Activity
  • Views
  • Comments
  • Likes
Advertise with us
  • Your advertisement here!
  • loading
Ultrashock
  • Creative Assets
  • Community
  • Blog
  1. Home
  2. Forum
+/-
Creative Assets
  • Categories
  • Contributors
  • How to buy
Make Money
  • Commission Rates
  • Referral Program
  • Contributor Program
Community
  • Activity Feed
  • Forum
  • Profiles
About
  • Quick Tour
  • Our History
  • Banners & Logos
Support
  • Contact Ultrashock
  • Advertise with us
  • Legal Information
  •  Keep up to date
  • Flash 775  Flash
  • Audio 6,481  Audio
  • Vector 2,130  Vectors
  • Image 12,338  Images
  • Creative Assets 21,724  Assets
  • Profiles 282,659  Members
  • Topics 93,762  Topics
  • Blog 4  Blog
  • Facebook 1,680  Facebook
  • Twitter 1,165  Twitter
  • Join our FREE monthly newsletter!
  • Archive
  • Invalid email address. Please try again.
Subscribe
  • ©2012 Ultrashock LLC - All rights reserved
  • Terms of Use
  • Privacy Policy
  • Switch to dark theme
  • RSS Feeds
  • Top

©2012 Ultrashock LLC - All rights reserved

Printed on Sat, February 04, 2012 - 19:38:19