1
Mods & Plugins (Releases & Support) / [MOD] Lens information from jpg Metadata
« on: February 07, 2008, 10:07:12 AM »
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
this code:
Some lines below in functions.php insert after:
this code:
Above the line:
this code:
finally insert after:
this code:
in details.html insert behind the line
this code:
You can see the result here:
http://kleinermuck.myphotos.cc/details.php?image_id=45
The 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
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
Code: [Select]
function get_iptc_info($info) {
this code:
Code: [Select]
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:
Code: [Select]
$height = "";
$iptc_info = "";
$exif_info = "";
this code:
Code: [Select]
$lens_info = "";
Above the line:
Code: [Select]
$exif_array = get_exif_info($exif_data);
this code:
Code: [Select]
$lens_info = get_lens_info($src);
finally insert after:
Code: [Select]
"height" => $height,
"iptc_info" => $iptc_info,
"exif_info" => $exif_info,
this code:
Code: [Select]
"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
Code: [Select]
{exif_info}
this code:
Code: [Select]
{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=45
The 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