Announcement

  •  » Extensions
  •  » Convert Focal Length to 35mm EQ

#1 2021-01-30 17:39:40

FelixPiwigo
Member
2021-01-30
3

Convert Focal Length to 35mm EQ

Hello, I prepared a small hack, which converts EXIF Focal Length to 35mm equivalent.
I tested it with version 11 and also Bootstrap Darkroom Template with PhotoSwipe Captions (but I think it works with all themes).

It leaves the value for not defined cameras (200 mm).
It adds eq. for $conf defined camera values (320 mm eq.)

In Local Files Editor add this configuration based upon your gear
('EXIF Camera Model Name' => crop factor)

Code:

$conf['exif_focal_length_to35mm'] = array(
        'Canon EOS 70D' => 1.6,
        'Canon EOS DIGITAL REBEL XTi' => 1.6,
        'C2100UZ' => 5.43,
        'DSC-T30' => 6
      );

You also have to modify /include/functions_metadata.inc.php
(line 194, add the code right before return $result;)

Code:

// 35mm eq convert

  if (array_key_exists('exif_focal_length_to35mm', $conf)) {
    $conv_fl = $conf['exif_focal_length_to35mm'];

    if (array_key_exists('model',$result)) {$model_key = 'model'; $focal_key = 'focal_length';}
    else {$model_key = 'Model'; $focal_key = 'FocalLength';}

    if (array_key_exists($focal_key, $result)) {
      $value = (int) filter_var($result[$focal_key], FILTER_SANITIZE_NUMBER_INT);
      $model = trim($result[$model_key]);

      if (array_key_exists($model, $conv_fl)) $f35 = round($value*$conv_fl[$model]).' mm eq.';
      else $f35 = $value.' mm';

      $result[$focal_key] = $f35;
    }
  }

// end of 35mm eq convert

That's all. I hope it helps somebody.
Following Piwigo upgrade may revert back this changes :-(

Last edited by FelixPiwigo (2021-01-30 22:20:40)

Offline

 
  •  » Extensions
  •  » Convert Focal Length to 35mm EQ

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2021 · Contact