Reading Picasa captions in PHP
This post was written 3 years 4 months 7 days days old, so is a bit old now. Feel free to read and comment on this post, just remember some things change with time and any facts in this post may not be accurate anymore.Ok, it’s going to get technical.
Although I’ve recently bought Photoshop Elements, Picasa used to be my photo browser of choice (in fact it still is as I get used to Photoshop). Therefore when I wanted an easier way to add photos to the BMTG website, I developed it with Picasa in mind.
Apart from the site generating its own thumbnails, it also gets its description from the embedded Picasa data. I found out the data after reading on the PHP site about looking at EXIF and other image data and writing a program to display it all – this revealed the Picasa caption field.
However, it did seem to have an anomaly in that it ended with a null character. I therefore coded around this. Unfortunately1 with Picasa 3, this appears to have been fixed and so recently described photos are being truncated on my site. It’s not too much of a hassle, though, to detect for this. The code I use is as follows…
list($width, $height) = getimagesize($full_filename, $info);
$iptc = iptcparse($info["APP13"]);
$description = $iptc["2#120"][0];
if (ord(substr($description,-1))==0) {
$description=substr($description,0,-1);
}Simply populate $full_filename with, well, the filename of the image. At the end of it all the Picasa caption will be in $description and the image width and height in $width and $height.
The last line of the code is where I’m working around the null character at the end of the caption (or not).
- depending how you look at it [↩]

Considering how regularly new versions of Firefox now come along, that's quite some bug fix list in version 10! 














Copyright © 2000-2012
Artiss.co.uk is checked by