Lens data within EXIF/IPTC

OESRules

Joined: 2006-04-06
Posts: 2
Posted: Fri, 2006-12-29 13:58

Nikon D50 D70 D70s D100 D200 store the lens data with the picture.
How can I extract this information, and view it under the EXIF/IPTC information in Gallery2 ?

 
pavel.pola

Joined: 2007-05-19
Posts: 30
Posted: Sat, 2007-05-26 08:29

I had the same problem and I think I've solved it. You need to modify some files to get basic lens information from the EXIF.

1. modify /modules/exif/lib/exifer/makers/nikon.inc - find and modify formatNikonData function


function formatNikonData($type,$tag,$intel,$model,$data) {

        if($tag=="0084" && $model == 1) { //LensInfo by PPl
            $data = bin2hex($data);
            if($intel==1) $data = intel2Moto($data);

            $focalShort = hexdec(substr($data,0,8));
            $divFocalShort = hexdec(substr($data,8,8));
            $focalLong = hexdec(substr($data,16,8));
            $divFocalLong = hexdec(substr($data,24,8));
            $apertShort = hexdec(substr($data,32,8));
            $divApertShort = hexdec(substr($data,40,8));
            $apertLong = hexdec(substr($data,48,8));
            $divApertLong = hexdec(substr($data,56,8));

            if ($divFocalShort > 0) $focalShort = $focalShort / $divFocalShort;
            if ($divFocalLong > 0) $focalLong = $focalLong / $divFocalLong;
            if ($divApertShort > 0) $apertShort = $apertShort / $divApertShort;
            if ($divApertLong > 0) $apertLong = $apertLong / $divApertLong;

            if ($focalShort == $focalLong)
                $data = $focalShort . "mm f/";
            else
                $data = $focalShort . "-" . $focalLong . "mm f/";

            if ($apertShort == $apertLong)
                $data = $data . $apertShort;
            else
                $data = $data . $apertShort . "-" . $apertLong;

        } else if($type=="ASCII") {
...

2. modify /modules/exif/classes/ExifHelper.class - find and modify getExifKeys functions


    function getExifKeys() {
        global $gallery;
        static $data;

        if (!empty($data)) {
            return $data;
        }

        $data['LensInfo'] = array($gallery->i18n('Lens Info'), 'SubIFD.MakerNote.LensInfo');
...

3. modify appropriate .po files and make them to see changes in gallery

 
OESRules

Joined: 2006-04-06
Posts: 2
Posted: Mon, 2007-05-28 14:24

Hi !

Thanks for your answer, I will try this !
I'm not a programmer, and I don't know the Gallery application as good as I would like too.
What changes do you mean when you say "modify appropriate .po files" ?
//

 
pavel.pola

Joined: 2007-05-19
Posts: 30
Posted: Mon, 2007-05-28 14:38

.po files includes localized messages. We have added localized string "Lens Info". So if you are satisfied with the text "Lens Info", you need not to change anything. But if you need to translate it, you must add lines

msgid "Lens Info"
msgstr "Your translation goes here"

into appropriate .po file (located under /modules/exif/po directory).

After you make this change, you need to call "make install PO=xx", where xx is the name (without an extension) of changed file.

In my case, I have changes cs.po, so I need to call "make install PO=cs".

And sorry for my previous posts, there are encoded HTML entities, so you need to replace them in PHP, otherwise you get syntax errors... ;-(((

I have also encountered, that for some reason this doesn't work on all EXIF informations. My Nikon D200 is producing some EXIFs, which I cannot decode using this version of exif plugin. The problem is somewhere in detection of type Intel/Motorola Endian which in some cases goes wrong and I don't know why...

 
albertolavolpe

Joined: 2007-05-24
Posts: 4
Posted: Mon, 2007-05-28 15:34
pavel.pola wrote:
I had the same problem and I think I've solved it. You need to modify some files to get basic lens information from the EXIF.

1. modify /modules/exif/lib/exifer/makers/nikon.inc - find and modify formatNikonData function


function formatNikonData($type,$tag,$intel,$model,$data) {

        if($tag=="0084" && $model == 1) { //LensInfo by PPl
            $data = bin2hex($data);
            if($intel==1) $data = intel2Moto($data);

            $focalShort = hexdec(substr($data,0,8));
            $divFocalShort = hexdec(substr($data,8,8));
            $focalLong = hexdec(substr($data,16,8));
            $divFocalLong = hexdec(substr($data,24,8));
            $apertShort = hexdec(substr($data,32,8));
            $divApertShort = hexdec(substr($data,40,8));
            $apertLong = hexdec(substr($data,48,8));
            $divApertLong = hexdec(substr($data,56,8));

            if ($divFocalShort > 0) $focalShort = $focalShort / $divFocalShort;
            if ($divFocalLong > 0) $focalLong = $focalLong / $divFocalLong;
            if ($divApertShort > 0) $apertShort = $apertShort / $divApertShort;
            if ($divApertLong > 0) $apertLong = $apertLong / $divApertLong;

            if ($focalShort == $focalLong)
                $data = $focalShort . "mm f/";
            else
                $data = $focalShort . "-" . $focalLong . "mm f/";

            if ($apertShort == $apertLong)
                $data = $data . $apertShort;
            else
                $data = $data . $apertShort . "-" . $apertLong;

        } else if($type=="ASCII") {
...

2. modify /modules/exif/classes/ExifHelper.class - find and modify getExifKeys functions


    function getExifKeys() {
        global $gallery;
        static $data;

        if (!empty($data)) {
            return $data;
        }
http://www.kredietlenenhypotheek.nl
        $data['LensInfo'] = array($gallery->i18n('Lens Info'), 'SubIFD.MakerNote.LensInfo');
...

http://www.lenenkrediethypotheek.nl
3. modify appropriate .po files and make them to see changes in gallery

That didn't work for me. Or maybe I'm doing something wrong. Can you explain it for dummies like me?

[img]http://www.paestarporaqui.com/images/TgC_emoticon28.gif[/img] Thanks

 
grgeorgios

Joined: 2009-08-18
Posts: 2
Posted: Tue, 2009-08-18 08:31

Hi guys

it doesn't work for me neither...
When I am opening a Nikon picture, the EXIF section seems to hang and is not displayed :(
Please help!

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2009-08-18 13:38

This is an old thread. Please start a new thread and post your information:
FAQ: What information is required when I ask for help in the forums?
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2011-09-03 17:09

Comments are now permitted for this topic.

 
eliz82

Joined: 2009-11-06
Posts: 71
Posted: Sun, 2011-09-04 14:00

the pavel.pola code didn't work because some characters are not correct.

replace :
&& with &&
> with >

tested, and work ok.