Hello,
i have developed a meothod to display the Lens informations of DSLR Cameras. It works on my Version 1.7.6 it has not been tested with oder versions.
The Lens informations are displayed for Canon DSLR Cameras, it has not been tested with other vendors.
Feel free to redistribute, change, or even better improve the code
Here are the modifications which have to be done:
Insert into functions.php
above the line
function get_iptc_info($info) {
this code:
function get_lens_info($filename) {
ob_start();
readfile($filename);
$source = ob_get_contents();
ob_end_clean();
$xmpdata_start = strpos($source,"<x:xmpmeta");
$xmpdata_end = strpos($source,"</x:xmpmeta>");
$xmplenght = $xmpdata_end-$xmpdata_start;
$xmpdata = substr($source,$xmpdata_start,$xmplenght+12);
$xmp_parsed = array();
$regexps = array(
array("name" => "AUX lens", "regexp" => "/Lens=\".+\"/")
);
foreach ($regexps as $key => $k) {
$name = $k["name"];
$regexp = $k["regexp"];
unset($r);
preg_match ($regexp, $xmpdata, $r);
$xmp_item = "";
$xmp_item = @$r[0];
array_push($xmp_parsed,array("item" => $name, "value" =>
$xmp_item));
}
foreach ($xmp_parsed as $key => $k) {
$item = $k["item"];
$value = $k["value"];
$myvalue = explode("\"", $value);
/* print $myvalue[1];*/
}
return $myvalue[1];
}
Some lines below in functions.php insert after:
$height = "";
$iptc_info = "";
$exif_info = "";
this code:
$lens_info = "";
Above the line:
$exif_array = get_exif_info($exif_data);
this code:
$lens_info = get_lens_info($src);
finally insert after:
"height" => $height,
"iptc_info" => $iptc_info,
"exif_info" => $exif_info,
this code:
"lens_info" => $lens_info
Be aware that you need to insert a "," right behind the "$exif_info" as printed abovein details.html insert behind the line
{exif_info}
this code:
{if lens_info}
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td class="bordercolor">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td class="head1" valign="top" colspan="2">Objektivdaten (sofern vorhanden)</td>
</tr>
<td valign="top" class="row1" width="50%"><b>Objektiv:</b></td>
<td valign="top" class="row1">{lens_info}</td>
</table>
</td>
</tr>
</table>
{endif lens_info}
You can see the result here:
http://kleinermuck.myphotos.cc/details.php?image_id=45The code to read the metadata has been found on google. The code has been written by Pekka Saarinen
http://photography-on-the.net. The code has been slightly changed by me to fit our requirements.
kind regards
carsten