If you use piwigo you might have noticed that EXIF is not working properly sometimes. Especially if you have multiple cameras and want to extract the lens data.

The reason for this is manyfold:

  1. Each Camera might use a different EXIF tag for the lens
  2. The lens might not even be written correctly in the EXIF data
  3. the PHP implementation that piwigo uses cannot correclty extract the required tag

At least for the first issue, I found a solution. Simply extract all possible tags and then merge them with this personal plugin:

<?php
/*
Plugin Name: EXIF Merge
Version: 1.0
Description: it merges EXIF tags
Plugin URI: -
Author: Sebastian Bachmann
Author URI: https://reox.at
*/

add_event_handler('format_exif_data', 'exif_merge');

/**
 * EXIF Merge.
 *
 * Merges some keys in the EXIF Data, so we have always a correct lens description
 *
 * @param $exif dictionary with EXIF keys and values
 * @return merged array
 */
function exif_merge($exif) {
   if (is_array($exif)) {
     // 5DmkII stores lens in UndefinedTag:0x0095
     if (array_key_exists('UndefinedTag:0x0095', $exif)) {
       $exif['UndefinedTag:0xA434'] = $exif['UndefinedTag:0x0095'];
       unset($exif['UndefinedTag:0x0095']);
     }
   }
   return $exif;
}

?>

In the settings, enable EXIF and add the following fields:

$conf['show_exif'] = true;

$conf['show_exif_fields'] = array(
  'FocalLength', 
  'ExposureTime',
  'ISOSpeedRatings',
  'FNumber',
  'Model',  // Camera Model
  'UndefinedTag:0xA434', // lens
  'UndefinedTag:0x0095',  //  lens tag for 5Dmkii
);

In addition, you might also want to use exif_view.

To check which tags are used and known by PHP, you can use the tools/metadata.php script. You have to change the filename to inspect inside the script though.