I'm working on a script to extract an EXIF thumbnail out of an image, so I can roll my own gallery software (nothing fancy, just pull images out of a directory, and put them into a table with thumbnails & EXIF info).
I'm finding that none of the gallery software I've installed has really met all the needs I have -- and if they do, they create multitudes of support files in a directory...
It seems that using EXIF thumbnails would be the way to go -- the image data is already stored in the file... it's just a matter of getting to it, and working with it.
In theory, the above linked script should work; however, it appears that EXIF thumbnails aren't included in the file by default (at least not by the A70). So it means I'll likely have to pre-process the files, running them through an application to build the EXIF thumbnail.
Which isn't necessarily a bad thing -- just a little extra work before uploading. However, since I don't have to do any preprocessing on the image side any more, it shouldn't mean that much more work in the long run.
If you have any ideas as to what I should use to create the EXIF thumbnails, let me know.
Update: Got it working over lunch. See inside for details.
It turns out that the EXIF thumbnail information is in the file to begin with on the images from my Canon A70. It was just a matter of passing along the information through a session variable, so I could display the image data.
Here's the script:
<?php
if ($imgtype=1 & $foo <> "") {
session_start();
$gallery = $_SESSION['gallery'];
$address = $_SESSION['address'];
header("Content-type: image/tiff");
echo $_SESSION['data'];
session_destroy();
}
else {session_start();
header("Content-type: text/html");
$EXIF_key[0]='';
$EXIF_val[0]='';
$_SESSION['gallery']=$gallery;
$_SESSION['address']=$file;
$address = $file;
$exif = read_exif_data ($gallery."/".$address,'EXIF',0,true);
$n=0;
while(list($k,$v)=each($exif)) {
if($k=="THUMBNAIL"){
$foobar = $v;
foreach ($foobar as $key=>$section) {
if ($key=="THUMBNAIL") {
$_SESSION['data']=$section;
}
// echo "Key:$key<br>Value:$section<br><br>";
}
$foo = $gallery."/".$file;
echo "Thumbnail:<br>";
echo "<a href=\"$gallery/$address\"><img src='$PHP_SELF?imgtype=1&foo=$foo'></a>\n";
echo "<br />\n";
}
else{
$EXIF_key[$n]=$k;
$EXIF_val[$n]=$v;
$n++;
}
}
?>
EXIF Data:<br>
<?
for ($i=0; $i < sizeof($EXIF_key);$i++) {
echo $EXIF_key[$i].": ".$EXIF_val[$i]."<br>";
}
}
?>
And here it is in action

>> Arcterex » Thursday, July 3, 2003 09:41 AM
>> Darren » Thursday, July 3, 2003 10:02 AM
>> fozbaca » Thursday, July 3, 2003 12:08 PM
>> Darren » Thursday, July 3, 2003 12:17 PM
>> Arcterex » Friday, July 4, 2003 11:06 AM
>> Darren » Friday, July 4, 2003 11:13 AM
Post a comment
* under no circumstances will your email address be traded for a sack of quarters. No-sirree.