Author Topic: [MOD] Lens information from jpg Metadata  (Read 22394 times)

0 Members and 1 Guest are viewing this topic.

Offline cmuck

  • Pre-Newbie
  • Posts: 4
    • View Profile
[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  :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
« Last Edit: February 07, 2008, 01:08:25 PM by mawenzi »

rinaldos

  • Guest
Re: [MOD] Lens information from jpg Metadata
« Reply #1 on: February 07, 2008, 11:03:21 AM »
Hallo cmuck,
ich habe gerade deinen Code bei mir eingebaut. Er funktioniert auch mit 1.7.4 :-)

Gruß
Ingo

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] Lens information from jpg Metadata
« Reply #2 on: February 07, 2008, 01:05:16 PM »
@cmuck
... thanks for that mod ...
... moved to "Mods & Plugins (Releases & Support)" ...

@rinaldos
... thanks for info and testing on version1.7.4 ...
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline om6acw

  • Full Member
  • ***
  • Posts: 187
    • View Profile
    • My Animal's World
Re: [MOD] Lens information from jpg Metadata
« Reply #3 on: February 08, 2008, 06:18:08 AM »
Not working with Nikon  :cry:

rinaldos

  • Guest
Re: [MOD] Lens information from jpg Metadata
« Reply #4 on: February 08, 2008, 08:23:47 AM »
The Lens informations are displayed for Canon DSLR Cameras, it has not been tested with other vendors.
I use a Canon DSLR, Nikon uses an other Format to write the extended EXIF Information. I think the script reads only the Canon "extended" EXIF Information:-(

Here are the EXIF Standards...
http://www.exif.org/samples.html

Ingo

Offline cmuck

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: [MOD] Lens information from jpg Metadata
« Reply #5 on: February 08, 2008, 10:42:55 AM »
Hello,

the Lens Informations are put into the metadata not in the common exif fields.

The Field i read out is aux:Lens.

If one can provide the field the Nikon Cameras places the Lens informations it can be easily changed in the code:
Quote
array("name" => "AUX lens", "regexp" => "/Lens=\".+\"/")

Replace aux:Lens against aux:Whatever and it should work.

Maybe you can provide me an Image taken with ohter vendors, so i can improve the code of reading the Lens information out of the metadata.

Kind regards
carsten


Offline om6acw

  • Full Member
  • ***
  • Posts: 187
    • View Profile
    • My Animal's World
Re: [MOD] Lens information from jpg Metadata
« Reply #6 on: February 13, 2008, 05:37:39 AM »

Maybe you can provide me an Image taken with ohter vendors, so i can improve the code of reading the Lens information out of the metadata.

Kind regards
carsten



Can you try it to do that? here is photo from mi Nikon D200 camera.
http://www.myanimalsworld.com/out/
« Last Edit: February 13, 2008, 05:58:18 AM by om6acw »

Offline cmuck

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: [MOD] Lens information from jpg Metadata
« Reply #7 on: February 29, 2008, 12:12:20 PM »
Long time no see  :cry:

Because i do not get any Mails when users Post here i did not read your post.

Hopefully i can enegneer a solution over the weekend.

kind regards

Offline cmuck

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: [MOD] Lens information from jpg Metadata
« Reply #8 on: February 29, 2008, 12:17:51 PM »

Can you try it to do that? here is photo from mi Nikon D200 camera.
http://www.myanimalsworld.com/out/

Sorry somehow your Nikon does not provide me any Lens informations in the Exif Data.

If one wants me to implement this, one should also sure that his camera provides the informations somewhere in the exifs. (I use the firefox addon "exif viewer" to take a look at the exifs.)

sorry

Kind reagrds
Carsten

Offline om6acw

  • Full Member
  • ***
  • Posts: 187
    • View Profile
    • My Animal's World
Re: [MOD] Lens information from jpg Metadata
« Reply #9 on: February 29, 2008, 05:33:07 PM »
Sorry somehow your Nikon does not provide me any Lens informations in the Exif Data.

If one wants me to implement this, one should also sure that his camera provides the informations somewhere in the exifs. (I use the firefox addon "exif viewer" to take a look at the exifs.)

sorry

Kind reagrds
Carsten

HI there,
you can try this software for checking EXIF data http://www.opanda.com/en/iexif/download.htm

Rembrandt

  • Guest
Re: [MOD] Lens information from jpg Metadata
« Reply #10 on: March 22, 2008, 08:43:19 PM »
Tag!

Also das funktioniert doch nur bei einen unbearbeiteten Bild, ein bearbeitetes Bild aus Photoshop auch bei "Speichern unter" als *.JPG hat keine xmp Daten mehr.
Falls ich mit dem richtig liege gibt es eine einfachere Lösung (für Canon DSLR):

In der funktions.php nach:
Quote
$exif_match = array();

diese Zeile einfügen:
Quote
$exif_match['UndefinedTag:0x0095'] = "UndefinedTag:0x0095";

in der lang/main.php nach:
Quote
// EXIF Tags
diese Zeile einfügen:
Quote
$lang['exif_UndefinedTag:0x0095'] = "Objektiv Daten:";

mfg Andi


Offline Nasenbär

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: [MOD] Lens information from jpg Metadata
« Reply #11 on: May 12, 2008, 02:20:37 AM »
Hallo zusammen

Leider fehlen mir einige Code´s für die Vers. 1.7.1  :? Würde dieses Mod aber gerne einbauen  :lol:

Kann mir einer bitte helfen von euch - wäre Super

Vielen Dank  :wink:

Rembrandt

  • Guest
Re: [MOD] Lens information from jpg Metadata
« Reply #12 on: May 12, 2008, 08:11:48 AM »
Morgen!

und woran scheitert es?

schau dir das mal an http://www.4homepages.de/forum/index.php?topic=11072.msg58059#msg58059

b.z.w würde ich an deiner stelle ein galerie update auf V 1.7.6 machen.
dann könntest du ja das vielleicht einbauen:
http://www.4homepages.de/forum/index.php?topic=21017.0
b.z.w
http://www.4homepages.de/forum/index.php?topic=21053.0

mfg Andi

Leider fehlen mir einige Code´s für die Vers. 1.7.1  :? Würde dieses Mod aber gerne einbauen ...

Offline Nasenbär

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: [MOD] Lens information from jpg Metadata
« Reply #13 on: May 12, 2008, 08:21:02 AM »
Hallo Andi

In der functions.php fehlt mir diese Zeile

Code: [Select]
$exif_array = get_exif_info($exif_data);
Jetzt weis ich nicht mehr wie es weiter geht  :?

Ich habe schon ein EXIF Mod eingebaut, das auch funktioniert  :) Aber die Zugabe mit den "Lens Infos" wäre noch ein Zuckerl obendrauf  :wink:
Ein Update auf 1.7.6 ist zu umständlich, da viele Mods aus 1.7.1 eingebaut sind, dann würde die Seite nicht mehr funktionieren!
« Last Edit: May 12, 2008, 08:34:46 AM by Nasenbär »

Rembrandt

  • Guest
Re: [MOD] Lens information from jpg Metadata
« Reply #14 on: May 12, 2008, 08:51:20 AM »
Hallo Andi

In der functions.php fehlt mir diese Zeile

Code: [Select]
$exif_array = get_exif_info($exif_data);
Jetzt weis ich nicht mehr wie es weiter geht  :?

Ich habe schon ein EXIF Mod eingebaut, das auch funktioniert  :) Aber die Zugabe mit den "Lens Infos" wäre noch ein Zuckerl obendrauf  :wink:
Ein Update auf 1.7.6 ist zu umständlich, da viele Mods aus 1.7.1 eingebaut sind, dann würde die Seite nicht mehr funktionieren!
versteh ich jetzt nicht.
einen post ober deinem, habe ich dir drei links hineingeschrieben.
bei dem ersten link findest du den exifmod für die vers. 1.7.1 darin enthalten ist die funktions.php dort steht doch alles drinnen?

für die lens info kommt in die exif. php
case "UndefinedTag:0x0095":
$val = $val;
break;

unten die übersetztung:
case "UndefinedTag:0x0095":
$name = "Kamera Objektiv";
break;

ganz oben bei der filter funktion:
Kamera Objektiv:

mfg Andi