> home
> how we work
> who we're working for
> about us
> publications
> buy apache essentials
> client login

play
static·red
edmonton and area web development

Current Projects

Edmonton Weather


>>Le blog.

speakeasy archives


EXIF Thumbnails...

<< perhaps... | Main | Happy 4th of July >>

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

Posted by Darren James Harkness on Thursday, July 3, 2003 09:25 AM
Trackbacks...


Comments:
>> Arcterex » Thursday, July 3, 2003 09:41 AM

You too eh? I didn't know that EXIF stored actual thumbnails embedded... that's cool. I haven't found a gallery software that works quite right for me. I want something that I can use to archive/view as well as display, that extracts exif data and displays it, and does the thumbnailing, etc. Gallery is mostly there except for the exif data (it has the ability to do stuff with it, I've seen it in the code, it's just not all there yet), the one you use is just is too feature filled for what I need, and other stuff I've seen is too minimulistic. If you find something good let me know :) Something like this but with exif display maybe...

>> Darren » Thursday, July 3, 2003 10:02 AM

The script I want to work on would be relatively simple, but would include the following:

1) Directory security & users [DONE on other scripts, easy portability]
2) Thumbnails without extra files [Developing]
3) Displays all EXIF data embedded in the file [DONE]

Albums would essentially be created by creating a new directory... it'd be a matter of somehow throwing an apache rewrite rule into a central .htaccess file, so that when new directories were created, you wouldn't have to add an index file, or do anything through an admin tool (except, perhaps, to secure a directory)

>> fozbaca » Thursday, July 3, 2003 12:08 PM

You might want to give a lookse at Apache::Gallery . There is some EXIF work in there.

>> Darren » Thursday, July 3, 2003 12:17 PM

I've got it extracting what I think is the thumbnail image information... it's just a matter of working with it now.

>> Arcterex » Friday, July 4, 2003 11:06 AM

Apache::Gallery works not too bad (test at http://gallery.arcterex.net), but doesn't extract thumbnail data, instead using ImLib to do it, which makes it slow. I found someone who hacked A:G to grab thumbnails, but he hasn't gotten back to me about things yet.

A:G would be awsome with some minor tweaks. I like the simplistic way it does things, getting all data from the dir structure and from the exif data itself, but I'd like to set up number of images on a page, and allow reading/editing of the user comment field in the exif data so that you can store info about the picture as well as display it without having extra files.

Hmm.... maybe a good weekend project!

>> Darren » Friday, July 4, 2003 11:13 AM

I'm going to be working on a PHP-based gallery using the above script. Kirsten is graciously offering up our spare box (her spare windows box, in case anything happened to the laptop) to let me set up a headless apache box, so I can start developing it.

Which reminds me... (goes to start a new entry)


Post a comment









Remember personal info?


Comments:


* under no circumstances will your email address be traded for a sack of quarters. No-sirree.