forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: wuschel_lux on November 17, 2014, 11:16:52 am

Title: EXIF data: showing lens model info
Post by: wuschel_lux on November 17, 2014, 11:16:52 am
Hi all,

I'am searching for a solution for my actual gallery. I want to display some EXIF data below the photo. I also started this and I am quite happy with the result. Just the lens info is missing for me.
In the documentation I found the hint to look for example the file /include/markers/canon.php.
Now it would be great to use "case "0095": $tag = "LensInfo";break;".

In the forum I found following article: http://forum.coppermine-gallery.net/index.php?topic=59103.0 But I cant follow all the code replacements in the actual version 1.5.34.

Is there anybody out the, who can give me a hint how to integrate the lens info in the EXIF string I use in my template?

here a small extract of my theme.php:
      
Code: [Select]
// EXIF String on Image page
if ($exif_string != '' && $exif[$lang_picinfo['Model']] !='') {
$exif[$lang_picinfo['FocalLength']] . ', ' . $exif[$lang_picinfo['FNumber']] . ', ' . $exif[$lang_picinfo['ExposureTime']] . ', ISO '. $exif[$lang_picinfo['ISOSpeedRatings']] .', '. $exif[$lang_picinfo['Flash']] .')';
}
else $exif_string = ' not indicated';

.....

                                          <tr>
                                            <td class="tableh1">
                                          <strong>Photo details:</strong>
                                        </td>
                                          </tr>
                                          <tr>
                                            <td>
                                          photo by: <i>{USER}</i>
                                        </td>
                                          </tr>
                                          <tr>
                                            <td>
                                          Hits: <i>{IMAGEHITS}</i>
                                        </td>
                                          </tr> 
                                            <tr>
                                            <td>
                                          Equipment: <i>{EXIF_STRING}</i>
                                        </td>
                                          </tr>
                                          <tr>
                                            <td>
                                          Keywords: <i>{KEYWORDS}</i>
                                          <br /><br />
                                        </td>
                                          </tr>


Live site preview: http://www.volleyball.lu/fotogallery/displayimage.php?album=708&pid=50672#top_display_media

actual line: Equipment: Canon EOS 7D (Manual, 115 mm, f/2.8, 1/640 sec, ISO 6400, No Flash)
expected line: Equipment: Canon EOS 7D / Canon EF 70-200mm F2.8L IS (Manual, 115 mm, f/2.8, 1/640 sec, ISO 6400, No Flash)

Thanks a lot in advance.
Title: Re: EXIF data: showing lens model info
Post by: Αndré on December 26, 2014, 10:37:41 pm
Please attach a test picture with the corresponding EXIF data, so we can test ourselves.
Title: Re: EXIF data: showing lens model info
Post by: wuschel_lux on January 16, 2015, 03:25:39 pm
Hi André,
I am so sorry for the late reply, but I didn't got the notification of a reply.

This is the link to my gallery for a sample photo:
http://www.volleyball.lu/fotogallery/displayimage.php?album=713&pid=51062#top_display_media

As Attachment the requested photo with full EXIF info. The second pic, is a screenshot from Lightroom with EXIF info.

Hope this could help you.

Thank's a lot.
Title: Re: EXIF data: showing lens model info
Post by: Αndré on January 20, 2015, 09:21:06 pm
As you seem to embed the EXIF info with some custom code to your gallery, this is maybe a very short and easy mod. Please try the following.

Open include/exif_php.inc.php, find
Code: [Select]
$exif_names = explode("|", $exif_info);and above, add
Code: [Select]
$exif_info .= "|LensInfo";
This will read the lens info and stores it in the MySQL table (so you maybe have to clear the EXIF table if the info isn't displayed for existing pictures, but new ones). The output in a default gallery currently looks like at the attached screenshot.
Title: Re: EXIF data: showing lens model info
Post by: wuschel_lux on January 20, 2015, 09:57:20 pm
thanks André, for your help.

I just added the code to the mentioned file. For new files (e.g. http://www.volleyball.lu/fotogallery/displayimage.php?album=725&pid=51815#top_display_media) I can find the LensInfo in the MySQL table

Code: [Select]
........ "ExposureMode";i:1;s:12:"WhiteBalance";i:0;s:16:"SceneCaptureMode";i:0;s:8:"LensInfo";s:27:"EF70-200mm f/2.8L IS II USM";}
but there is no output to the picture info like in your test gallery. Please see attachment.


Title: Re: EXIF data: showing lens model info
Post by: Αndré on January 20, 2015, 10:42:11 pm
actual line: Equipment: Canon EOS 7D (Manual, 115 mm, f/2.8, 1/640 sec, ISO 6400, No Flash)
expected line: Equipment: Canon EOS 7D / Canon EF 70-200mm F2.8L IS (Manual, 115 mm, f/2.8, 1/640 sec, ISO 6400, No Flash)

If this is what you want to have as result, I suggest to skip what Coppermine displays by default. Instead, we should adjust your custom code. However, I assume the code you posted won't work, as this actually doesn't anything:
Code: [Select]
if ($exif_string != '' && $exif[$lang_picinfo['Model']] !='') {
$exif[$lang_picinfo['FocalLength']] . ', ' . $exif[$lang_picinfo['FNumber']] . ', ' . $exif[$lang_picinfo['ExposureTime']] . ', ISO '. $exif[$lang_picinfo['ISOSpeedRatings']] .', '. $exif[$lang_picinfo['Flash']] .')';
}

Do you already have working code for your actual line? If so, please post it, so we can add the lens info to that line.
Title: Re: EXIF data: showing lens model info
Post by: wuschel_lux on January 21, 2015, 07:36:23 am
you are right with your "expected line".

Here my working code in theme.php:
Code: [Select]
if ($exif_string != '' && $exif[$lang_picinfo['Model']] !='') {
// EXIF String on Image page
$exif_string = $exif[$lang_picinfo['Model']] . ' ('. $exif[$lang_picinfo['ExposureProgram']] .', ' . $exif[$lang_picinfo['FocalLength']] . ', ' . $exif[$lang_picinfo['FNumber']] . ', ' . $exif[$lang_picinfo['ExposureTime']] . ', ISO '. $exif[$lang_picinfo['ISOSpeedRatings']] .', '. $exif[$lang_picinfo['Flash']] .')';
tryed to add someting like this for the lens info:
Code: [Select]
$exif[$lang_picinfo['LensInfo']] or $exif['LensInfo']but without success. No output.
Title: Re: EXIF data: showing lens model info
Post by: wuschel_lux on January 21, 2015, 10:22:42 am
here the complete code in theme.php for reading the EXIF data:
Code: [Select]
  // read exif data
    if ($CONFIG['read_exif_data']) {
        $path_to_pic = $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'];
        $path_to_orig_pic = $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CONFIG['orig_pfx'] . $CURRENT_PIC_DATA['filename'];
        $metadata_path = file_exists($path_to_orig_pic) ? $path_to_orig_pic : $path_to_pic;
        $exif = exif_parse_file($metadata_path, $CURRENT_PIC_DATA['pid']);
        if (is_array($exif)) {
            array_walk($exif, 'sanitize_data');
        }
        print_r($exif);
       
    $exif_bracket_array = array('Focal length', 'FNumber', 'Exposure Time', 'Model',);
$exif_string = '';
foreach ($exif_bracket_array as $key) {
$exif_string .= $exif[$key] . ', ';
}
$exif_string = rtrim($exif_string);
$exif_string = rtrim($exif_string, ',');
//print_r($exif_string);
if ($exif_string != '' && $exif[$lang_picinfo['Model']] !='') {
// EXIF String on Image page
$exif_string = $exif[$lang_picinfo['Model']] .' - '. $exif['LensInfo']. ' ('. $exif[$lang_picinfo['ExposureProgram']] .', ' . $exif[$lang_picinfo['FocalLength']] . ', ' . $exif[$lang_picinfo['FNumber']] . ', ' . $exif[$lang_picinfo['ExposureTime']] . ', ISO '. $exif[$lang_picinfo['ISOSpeedRatings']] .', '. $exif[$lang_picinfo['Flash']] .')';
}
else $exif_string = ' not indicated';
//print_r($exif_string); //Test output string
    }

the print_r returns the following array:
Code: [Select]
Array ( [Colour Space] => sRGB [DateTime Original] => 2015:01:02 20:13:59 [Exposure Program] => Manual [Exposure Time] => 1/800 sec [FNumber] => f/2.8 [Flash] => No Flash [Focal length] => 135 mm [ISO] => 6400 [Make] => Canon [Metering Mode] => Pattern [Model] => Canon EOS 7D )so the LensInfo is not included.
Title: Re: EXIF data: showing lens model info
Post by: Αndré on January 21, 2015, 09:21:15 pm
That's because exif_parse_file strips the EXIF data, which has not been enabled in the EXIF manager:
Code: [Select]
    $exifCurrentData = array_keys(array_filter(explode("|", $CONFIG['show_which_exif'])));

    foreach ($exifCurrentData as $i) {
        $name = $exif_names[$i];
        if (isset($exif[$name])) {
            $exifParsed[$lang_picinfo[$name]] = $exif[$name];
        }
    }


To fix this, open lang/english.php and add
Code: [Select]
$lang_picinfo['LensInfo'] = 'Lense info';before the closing PHP tag
Code: [Select]
?>
Additionally, open exifmgr.php, find
Code: [Select]
$exifRawData = explode("|", $exif_info);and above, add
Code: [Select]
$exif_info .= "|LensInfo";

Now, open the EXIF manager and enable the lens info row.
Title: Re: EXIF data: showing lens model info
Post by: wuschel_lux on January 22, 2015, 08:44:50 am
many thank's André for giving me the missing piece for my puzzle.

Now it works fine for me.