Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - cmuck

Pages: [1]
1
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  :D

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 above

in 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

Pages: [1]