Pour les plus curieux, voici mon script Perl dans sa version ß.
Si vous voulez l'utiliser, il faut préalablement installer
ExifTool. On considère que ce package est disponible dans /usr/bin/lib (ce qui est vrai après l'installation standard sous MacOS X "Lion"). Ensuite, il faut créer un fichier ExifLeicaR.pl contenant le code ci-dessous. Puis l'appeler via le Terminal, en mettant un fichier DNG en paramètre.
Attention, si l'objectif est déterminé, le fichier DNG sera modifié. Il est donc conseillé d'en faire une sauvegarde. Notez aussi que le traitement des zooms n'est pas clarifié.
- Code : Tout sélectionner
#!/usr/bin/perl -w -I /usr/bin/lib
#------------------------------------------------------------------------------
# File: ExifLeicaR.pl
#
# Description: Create the tag 'Lens' with good values for Leica DMR images.
# The image must contain the focal length (true if the lens is
# equipped with a ROM).
#
# EXIF Tool (http://owl.phy.queensu.ca/~phil/exiftool/) required !
#
# Revisions: 0.1 - 04/2012 - Gautier
#------------------------------------------------------------------------------
use Image::ExifTool;
#------------------------------------------------------------------------------
#
# ### giveLensName ###
#
# Function using the focal length and the max aperture
# available in the EXIF to give a Leica R lens name
#
# Input 1: focal length (real)
# Input 2: max aperture (real)
#
# Output: list of lens names (empty if undefined, 1 element if determined, 2 or more if several possibilities)
#
# Revisions: 0.1 - 04/2012 - Gautier
#
sub giveLensName($$)
{
# Inputs
my $focalLength = $_[0];
my $maxAperture = $_[1];
# Outputs
my @lensName = ();
# Local variables
my $focalLengthReal;
# Code
if (!$focalLength)
{
$focalLength = "0.0";
$focalLengthReal = 0.0;
}
else
{
if ($focalLength =~ m/^\d+.?\d+$/ )
{
$focalLengthReal = $focalLength;
}
else
{
$focalLengthReal = 0.0;
}
}
if ($focalLength == 0.0)
{
# Lens without ROM or incomplete EXIF
if (!$maxAperture)
{
$maxAperture = 0.0;
}
# Try to find the right lens
if ($maxAperture == 0)
{
# Incomplete EXIF
# Unable to determine the lens without focal length and max aperture
# TBD : list all possibilities ?
}
elsif ($maxAperture == 1.4)
{
$lensName[0] = "Leica Summilux-R 35 mm f/1,4";
$lensName[1] = "Leica Summilux-R 50 mm f/1,4";
$lensName[2] = "Leica Summilux-R 80 mm f/1,4";
}
elsif ($maxAperture == 2)
{
$lensName[0] = "Leica Summicron-R 35 mm f/2";
$lensName[1] = "Leica Summicron-R 50 mm f/2";
$lensName[2] = "Leica Apo-Summicron-R 90 mm f/2";
$lensName[3] = "Leica Apo-Summicron-R 180 mm f/2";
$lensName[4] = "Leica Summicron-R 50 mm f/2 + Apo-Extender-R 2x";
$lensName[5] = "Leica Apo-Summicron-R 90 mm f/2 + Apo-Extender-R 2x";
}
elsif ($maxAperture == 2.8)
{
$lensName[0] = "Leica Super-Elmarit-R 15 mm f/2,8 Asph.";
$lensName[1] = "Leica Fisheye-Elmarit-R 16 mm f/2,8";
$lensName[2] = "Leica Elmarit-R 19 mm f/2,8";
$lensName[3] = "Leica Elmarit-R 24 mm f/2,8";
$lensName[4] = "Leica Elmarit-R 28 mm f/2,8";
$lensName[5] = "Leica Elmarit-R 35 mm f/2,8";
$lensName[6] = "Leica Macro-Elmarit-R 60 mm f/2,8";
$lensName[7] = "Leica Apo-Vario-Elmarit-R 70-180 mm f/2,8";
$lensName[8] = "Leica Elmarit-R 90 mm f/2,8";
$lensName[9] = "Leica Apo-Macro-Elmarit-R 100 mm f/2,8";
$lensName[10] = "Leica Elmarit-R 135 mm f/2,8";
$lensName[11] = "Leica Elmarit-R 180 mm f/2,8";
$lensName[12] = "Leica Apo-Elmarit-R 180 mm f/2,8";
$lensName[13] = "Leica Apo-Telyt-R 280 mm f/2,8";
$lensName[14] = "Leica Apo-Telyt-R 400 mm f/2,8";
$lensName[15] = "Leica Macro-Elmarit-R 60 mm f/2,8 + Apo-Extender-R 2x";
$lensName[16] = "Leica Elmarit-R 90 mm f/2,8 + Apo-Extender-R 2x";
$lensName[17] = "Leica Apo-Macro-Elmarit-R 100 mm f/2,8 + Apo-Extender-R 2x";
$lensName[18] = "Leica Elmarit-R 135 mm f/2,8 + Apo-Extender-R 2x";
$lensName[19] = "Leica Apo-Telyt-R 280 mm f/2,8 + Apo-Extender-R 2x";
$lensName[20] = "Leica Apo-Telyt-R 400 mm f/2,8 + Apo-Extender-R 2x";
}
elsif (($maxAperture == 3.4) || ($maxAperture == 3.5))
{
$lensName[0] = "Leica Super-Elmar-R 15 mm f/3,5";
$lensName[1] = "Leica Super-Angulon-R 21 mm f/3,4";
$lensName[2] = "Leica Apo-Telyt-R 180 mm f/3,4";
$lensName[3] = "Leica Apo-Telyt-R 180 mm f/3,4 + Apo-Extender-R 2x";
}
elsif ($maxAperture == 4)
{
$lensName[0] = "Leica Super-Angulon-R 21 mm f/4";
$lensName[1] = "Leica Vario-Elmar-R 80-200 mm f/4";
$lensName[2] = "Leica Macro-Elmar-R 100 mm f/4";
$lensName[3] = "Leica Elmar-R 180 mm f/4";
$lensName[4] = "Leica Telyt-R 250 mm f/4";
$lensName[5] = "Leica Apo-Telyt-R 280 mm f/4";
$lensName[6] = "Leica Apo-Telyt-R 560 mm f/4";
$lensName[7] = "Leica Macro-Elmar-R 100 mm f/4 + Apo-Extender-R 2x";
$lensName[8] = "Leica Apo-Telyt-R 400 mm f/4 + Apo-Extender-R 2x";
$lensName[9] = "Leica Apo-Telyt-R 560 mm f/4 + Apo-Extender-R 2x";
}
elsif ($maxAperture == 4.2)
{
$lensName[0] = "Leica Vario-Elmar-R 105-280 mm f/4,2";
}
elsif ($maxAperture == 4.8)
{
$lensName[0] = "Leica Telyt-R 350 mm f/4,8";
}
elsif (($maxAperture == 5.5) || ($maxAperture == 5.6))
{
$lensName[0] = "Leica Apo-Telyt-R 560 mm f/5,6";
$lensName[1] = "Leica Apo-Telyt-R 800 mm f/5,6";
$lensName[2] = "Leica Apo-Telyt-R 560 mm f/5,6 + Apo-Extender-R 2x";
$lensName[3] = "Leica Apo-Telyt-R 800 mm f/5,6 + Apo-Extender-R 2x";
}
elsif ($maxAperture == 6.3)
{
$lensName[0] = "Leica Telyt-S 800 mm f/6,3";
# But this lens doesn't exist with ROM.
}
elsif ($maxAperture == 6.8)
{
$lensName[0] = "Leica Telyt-R 400 mm f/6,8";
$lensName[1] = "Novoflex Telyt-R 560 mm f/6,8";
# But these lenses don't exist with ROM.
}
elsif ($maxAperture == 8)
{
$lensName[0] = "Leica MR-Telyt-R 500 mm f/8";
# But this lens doesn't exist with ROM.
}
}
else
{
if (!$maxAperture)
{
$maxAperture = 0.0;
}
# Try to find the right lens
if ($maxAperture == 0)
{
# Incomplete EXIF but focal filled, so we can continue
if ($focalLengthReal == 15)
{
$lensName[0] = "Leica Super-Elmarit-R 15 mm f/2,8";
$lensName[1] = "Leica Super-Elmar-R 15 mm f/3,5";
}
elsif ($focalLengthReal == 16)
{
$lensName[0] = "Leica Fisheye-Elmarit-R 16 mm f/2,8";
}
elsif ($focalLengthReal == 19)
{
$lensName[0] = "Leica Elmarit-R 19 mm f/2,8";
}
elsif ($focalLengthReal == 21)
{
$lensName[0] = "Leica Super-Angulon-R 21 mm f/4";
$lensName[0] = "Leica Vario-Elmar-R 21-35 mm f/3,5-4";
}
elsif ($focalLengthReal == 24)
{
$lensName[0] = "Leica Elmarit-R 24 mm f/2,8";
}
elsif ($focalLengthReal == 28)
{
$lensName[0] = "Leica Elmarit-R 28 mm f/2,8";
$lensName[1] = "Leica Vario-Elmarit-R 28-90 mm f/2,8-4,5";
$lensName[2] = "Leica Vario-Elmar-R 28-70 mm f/3,5-4,5";
}
elsif ($focalLengthReal == 35)
{
$lensName[0] = "Leica Summilux-R 35 mm f/1,4";
$lensName[1] = "Leica Summicron-R 35 mm f/2";
$lensName[2] = "Leica Elmarit-R 35 mm f/2,8";
$lensName[3] = "Leica Vario-Elmarit-R 35-70 mm f/2,8 Asph.";
$lensName[4] = "Leica Vario-Elmar-R 35-70 mm f/3,5";
$lensName[5] = "Leica Vario-Elmar-R 35-70 mm f/4";
}
elsif ($focalLengthReal == 50)
{
$lensName[0] = "Leica Summilux-R 50 mm f/1,4";
$lensName[1] = "Leica Summicron-R 50 mm f/2";
}
elsif ($focalLengthReal == 60)
{
$lensName[0] = "Leica Macro-Elmarit-R 60 mm f/2,8";
}
elsif ($focalLengthReal == 80)
{
$lensName[0] = "Leica Summilux-R 80 mm f/1,4";
$lensName[1] = "Leica Vario-Elmarit-R 28-90 mm f/2,8-4,5";
$lensName[2] = "Leica Vario-Elmar-R 80-200 mm f/4";
}
elsif ($focalLengthReal == 90)
{
$lensName[0] = "Leica Apo-Summicron-R 90 mm f/2";
$lensName[1] = "Leica Elmarit-R 90 mm f/2,8";
}
elsif ($focalLengthReal == 100)
{
$lensName[0] = "Leica Apo-Macro-Elmarit-R 100 mm f/2,8";
$lensName[1] = "Leica Summicron-R 50 mm f/2 + Apo-Extender-R 2x";
}
elsif ($focalLengthReal == 135)
{
$lensName[0] = "Leica Elmarit-R 135 mm f/2,8";
}
elsif ($focalLengthReal == 180)
{
$lensName[0] = "Leica Apo-Summicron-R 180 mm f/2";
$lensName[1] = "Leica Elmarit-R 180 mm f/2,8";
$lensName[2] = "Leica Apo-Elmarit-R 180 mm f/2,8";
$lensName[3] = "Leica Apo-Summicron-R 90 mm f/2 + Apo-Extender-R 2x";
$lensName[4] = "Leica Elmarit-R 90 mm f/2,8 + Apo-Extender-R 2x";
}
elsif ($focalLengthReal == 250)
{
$lensName[0] = "Leica Telyt-R 250 mm f/4";
}
elsif ($focalLengthReal == 280)
{
$lensName[0] = "Leica Apo-Telyt-R 280 mm f/2,8";
$lensName[5] = "Leica Apo-Telyt-R 280 mm f/4";
}
elsif ($focalLengthReal == 350)
{
$lensName[0] = "Leica Telyt-R 350 mm f/4,8";
}
elsif ($focalLengthReal == 400)
{
$lensName[0] = "Leica Apo-Telyt-R 400 mm f/2,8";
$lensName[1] = "Leica Apo-Telyt-R 400 mm f/4";
}
elsif ($focalLengthReal == 500)
{
$lensName[0] = "Leica MR-Telyt-R 500 mm f/8";
# But this lens doesn't exist with ROM.
}
elsif ($focalLengthReal == 560)
{
$lensName[0] = "Leica Apo-Telyt-R 560 mm f/5,6";
}
elsif ($focalLengthReal == 800)
{
$lensName[0] = "Leica Apo-Telyt-R 800 mm f/5,6";
}
else
{
# Certainly a zoom with an intermediate focal stored
if (($focalLengthReal >= 21) && ($focalLengthReal < 28))
{
$lensName[0] = "Leica Vario-Elmar-R 21-35 mm f/3,5-4";
}
elsif (($focalLengthReal >= 28) && ($focalLengthReal < 35))
{
$lensName[0] = "Leica Vario-Elmar-R 21-35 mm f/3,5-4";
$lensName[1] = "Leica Vario-Elmarit-R 28-90 mm f/2,8-4,5";
$lensName[2] = "Leica Vario-Elmar-R 28-70 mm f/3,5-4,5";
}
elsif (($focalLengthReal >= 35) && ($focalLengthReal < 70))
{
$lensName[0] = "Leica Vario-Elmarit-R 28-90 mm f/2,8-4,5";
$lensName[1] = "Leica Vario-Elmar-R 28-70 mm f/3,5-4,5";
$lensName[2] = "Leica Vario-Elmarit-R 35-70 mm f/2,8 Asph.";
$lensName[3] = "Leica Vario-Elmar-R 35-70 mm f/3,5";
$lensName[4] = "Leica Vario-Elmar-R 35-70 mm f/4";
}
elsif (($focalLengthReal >= 70) && ($focalLengthReal < 80))
{
$lensName[0] = "Leica Vario-Elmarit-R 28-90 mm f/2,8-4,5";
}
elsif (($focalLengthReal >= 80) && ($focalLengthReal <= 90))
{
$lensName[0] = "Leica Vario-Elmarit-R 28-90 mm f/2,8-4,5";
$lensName[1] = "Leica Vario-Elmar-R 80-200 mm f/4";
}
elsif (($focalLengthReal > 90) && ($focalLengthReal < 105))
{
$lensName[0] = "Leica Vario-Elmar-R 80-200 mm f/4";
}
elsif (($focalLengthReal >= 105) && ($focalLengthReal <= 200))
{
$lensName[0] = "Leica Vario-Elmar-R 80-200 mm f/4";
$lensName[1] = "Leica Vario-Elmar-R 105-280 mm f/4,2";
}
elsif (($focalLengthReal >= 105) && ($focalLengthReal <= 280))
{
$lensName[0] = "Leica Vario-Elmar-R 105-280 mm f/4,2";
}
else
{
# TBD : list all possibilities ?
}
}
}
elsif ($maxAperture == 1.4)
{
if ($focalLengthReal == 35)
{
$lensName[0] = "Leica Summilux-R 35 mm f/1,4";
}
elsif ($focalLengthReal == 50)
{
$lensName[0] = "Leica Summilux-R 50 mm f/1,4";
}
elsif ($focalLengthReal == 80)
{
$lensName[0] = "Leica Summilux-R 80 mm f/1,4";
}
else
{
# Undefined
}
}
elsif ($maxAperture == 2)
{
if ($focalLengthReal == 35)
{
$lensName[0] = "Leica Summicron-R 35 mm f/2";
}
elsif ($focalLengthReal == 50)
{
$lensName[0] = "Leica Summicron-R 50 mm f/2";
}
elsif ($focalLengthReal == 90)
{
# It can't be a Summicron-R because there is no no-APO one with ROM
$lensName[0] = "Leica Apo-Summicron-R 90 mm f/2";
}
elsif ($focalLengthReal == 100)
{
$lensName[0] = "Leica Summicron-R 50 mm f/2 + Apo-Extender-R 2x";
}
elsif ($focalLengthReal == 180)
{
$lensName[0] = "Leica Apo-Summicron-R 180 mm f/2";
$lensName[2] = "Leica Apo-Summicron-R 90 mm f/2 + Apo-Extender-R 2x";
}
else
{
# Undefined
}
}
elsif ($maxAperture == 2.8)
{
if ($focalLengthReal == 15)
{
$lensName[0] = "Leica Super-Elmarit-R 15 mm f/2,8 Asph.";
}
elsif ($focalLengthReal == 16)
{
$lensName[0] = "Leica Fisheye-Elmarit-R 16 mm f/2,8";
}
elsif ($focalLengthReal == 19)
{
$lensName[0] = "Leica Elmarit-R 19 mm f/2,8";
}
elsif ($focalLengthReal == 24)
{
$lensName[0] = "Leica Elmarit-R 24 mm f/2,8";
}
elsif ($focalLengthReal == 28)
{
# It can't be a PC-Super-Angulon-R because there is no PC with ROM
$lensName[0] = "Leica Elmarit-R 28 mm f/2,8";
}
elsif ($focalLengthReal == 35)
{
$lensName[0] = "Leica Elmarit-R 35 mm f/2,8";
}
elsif ($focalLengthReal == 60)
{
$lensName[0] = "Leica Macro-Elmarit-R 60 mm f/2,8";
}
elsif ($focalLengthReal == 70)
{
# The focal stored for the Apo-Vario-Elmarit-R 70-180 mm f/2,8 is always the shortest
$lensName[0] = "Leica Apo-Vario-Elmarit-R 70-180 mm f/2,8";
}
elsif ($focalLengthReal == 90)
{
$lensName[0] = "Leica Elmarit-R 90 mm f/2,8";
}
elsif ($focalLengthReal == 100)
{
$lensName[0] = "Leica Apo-Macro-Elmarit-R 100 mm f/2,8";
}
elsif ($focalLengthReal == 120)
{
$lensName[0] = "Leica Macro-Elmarit-R 60 mm f/2,8 + Apo-Extender-R 2x";
}
elsif ($focalLengthReal == 135)
{
$lensName[0] = "Leica Elmarit-R 135 mm f/2,8";
}
elsif ($focalLengthReal == 180)
{
$lensName[0] = "Leica Elmarit-R 180 mm f/2,8";
$lensName[1] = "Leica Apo-Elmarit-R 180 mm f/2,8";
$lensName[2] = "Leica Elmarit-R 90 mm f/2,8 + Apo-Extender-R 2x";
}
elsif ($focalLengthReal == 200)
{
$lensName[0] = "Leica Apo-Macro-Elmarit-R 100 mm f/2,8 + Apo-Extender-R 2x";
}
elsif ($focalLengthReal == 270)
{
$lensName[0] = "Leica Elmarit-R 135 mm f/2,8 + Apo-Extender-R 2x";
}
elsif ($focalLengthReal == 280)
{
$lensName[0] = "Leica Apo-Telyt-R 280 mm f/2,8";
}
elsif ($focalLengthReal == 400)
{
$lensName[0] = "Leica Apo-Telyt-R 400 mm f/2,8";
}
elsif ($focalLengthReal == 560)
{
$lensName[0] = "Leica Apo-Telyt-R 280 mm f/2,8 + Apo-Extender-R 2x";
}
elsif ($focalLengthReal == 800)
{
$lensName[0] = "Leica Apo-Telyt-R 400 mm f/2,8 + Apo-Extender-R 2x";
}
else
{
# Certainly a zoom with an intermediate focal stored
if (($focalLengthReal > 35) && ($focalLengthReal < 70))
{
$lensName[0] = "Leica Vario-Elmarit-R 35-70 mm f/2,8 Asph.";
}
elsif (($focalLengthReal > 70) && ($focalLengthReal < 180))
{
$lensName[0] = "Leica Apo-Vario-Elmarit-R 70-180 mm f/2,8";
}
else
{
# Undefined
}
}
}
elsif ($maxAperture == 3.4)
{
if ($focalLengthReal == 15)
{
# The f/3,5 Super-Elmar seems to record f/3,4 in EXIF
$lensName[0] = "Leica Super-Elmar-R 15 mm f/3,5";
}
elsif ($focalLengthReal == 21)
{
$lensName[0] = "Leica Super-Angulon-R 21 mm f/3,4";
}
elsif ($focalLengthReal == 180)
{
$lensName[0] = "Leica Apo-Telyt-R 180 mm f/3,4";
}
elsif ($focalLengthReal == 360)
{
$lensName[0] = "Leica Apo-Telyt-R 180 mm f/3,4 + Apo-Extender-R 2x";
}
else
{
# Undefined
}
}
elsif ($maxAperture == 3.5)
{
if ($focalLengthReal == 15)
{
$lensName[0] = "Leica Super-Elmar-R 15 mm f/3,5";
}
else
{
# Certainly a zoom
if (($focalLengthReal >= 21) && ($focalLengthReal < 28))
{
$lensName[0] = "Leica Vario-Elmar-R 21-35 mm f/3,5-4";
}
elsif (($focalLengthReal >= 28) && ($focalLengthReal < 35))
{
$lensName[0] = "Leica Vario-Elmar-R 21-35 mm f/3,5-4";
$lensName[1] = "Leica Vario-Elmar-R 28-70 mm f/3,5-4,5";
}
elsif ($focalLengthReal == 35)
{
$lensName[0] = "Leica Vario-Elmar-R 21-35 mm f/3,5-4";
$lensName[1] = "Leica Vario-Elmar-R 28-70 mm f/3,5-4,5";
$lensName[2] = "Leica Vario-Elmar-R 35-70 mm f/3,5";
}
elsif (($focalLengthReal > 35) && ($focalLengthReal <= 70))
{
$lensName[1] = "Leica Vario-Elmar-R 35-70 mm f/3,5";
}
else
{
# Undefined
}
}
}
elsif ($maxAperture == 4)
{
if ($focalLengthReal == 21)
{
$lensName[0] = "Leica Super-Angulon-R 21 mm f/4";
}
elsif ($focalLengthReal == 35)
{
$lensName[0] = "Leica PA-Curtagon-R 35 mm f/4";
$lensName[1] = "Leica Vario-Elmar-R 35-70 mm f/4";
}
elsif ($focalLengthReal == 80)
{
$lensName[0] = "Leica Vario-Elmar-R 80-200 mm f/4";
}
elsif ($focalLengthReal == 100)
{
$lensName[0] = "Leica Macro-Elmar-R 100 mm f/4";
$lensName[1] = "Leica Vario-Elmar-R 80-200 mm f/4";
}
elsif ($focalLengthReal == 180)
{
$lensName[0] = "Leica Elmar-R 180 mm f/4";
$lensName[1] = "Leica Vario-Elmar-R 80-200 mm f/4";
}
elsif ($focalLengthReal == 200)
{
$lensName[0] = "Leica Macro-Elmar-R 100 mm f/4 + Apo-Extender-R 2x";
}
elsif ($focalLengthReal == 250)
{
$lensName[0] = "Leica Telyt-R 250 mm f/4";
}
elsif ($focalLengthReal == 280)
{
$lensName[0] = "Leica Apo-Telyt-R 280 mm f/4";
}
elsif ($focalLengthReal == 400)
{
$lensName[0] = "Leica Apo-Telyt-R 400 mm f/4";
}
elsif ($focalLengthReal == 560)
{
$lensName[0] = "Leica Apo-Telyt-R 560 mm f/4";
}
elsif ($focalLengthReal == 800)
{
$lensName[0] = "Leica Apo-Telyt-R 400 mm f/4 + Apo-Extender-R 2x";
}
elsif ($focalLengthReal == 1120)
{
$lensName[0] = "Leica Apo-Telyt-R 560 mm f/4 + Apo-Extender-R 2x";
}
else
{
# Certainly a zoom with an intermediate focal stored
if (($focalLengthReal > 35) && ($focalLengthReal < 70))
{
$lensName[0] = "Leica Vario-Elmar-R 35-70 mm f/4";
}
elsif (($focalLengthReal > 80) && ($focalLengthReal < 200))
{
$lensName[0] = "Leica Vario-Elmar-R 80-200 mm f/4";
}
else
{
# Undefined
}
}
}
elsif ($maxAperture == 4.2)
{
$lensName[0] = "Leica Vario-Elmar-R 105-280 mm f/4,2";
}
elsif ($maxAperture == 4.8)
{
$lensName[0] = "Leica Telyt-R 350 mm f/4,8";
}
elsif (($maxAperture == 5.5) || ($maxAperture == 5.6))
{
if ($focalLengthReal == 560)
{
$lensName[0] = "Leica Apo-Telyt-R 560 mm f/5,6";
}
elsif ($focalLengthReal == 800)
{
$lensName[0] = "Leica Apo-Telyt-R 800 mm f/5,6";
}
elsif ($focalLengthReal == 1120)
{
$lensName[0] = "Leica Apo-Telyt-R 560 mm f/5,6 + Apo-Extender-R 2x";
}
elsif ($focalLengthReal == 1600)
{
$lensName[0] = "Leica Apo-Telyt-R 800 mm f/5,6 + Apo-Extender-R 2x";
}
else
{
$lensName[0] = "Leica Apo-Telyt-R 560 mm f/5,6";
$lensName[1] = "Leica Apo-Telyt-R 800 mm f/5,6";
$lensName[2] = "Leica Apo-Telyt-R 560 mm f/5,6 + Apo-Extender-R 2x";
$lensName[3] = "Leica Apo-Telyt-R 800 mm f/5,6 + Apo-Extender-R 2x";
}
}
elsif ($maxAperture == 6.3)
{
$lensName[0] = "Leica Telyt-S 800 mm f/6,3";
# But this lens doesn't exist with ROM.
}
elsif ($maxAperture == 6.8)
{
if ($focalLengthReal == 400)
{
$lensName[0] = "Leica Telyt-R 400 mm f/6,8";
# But this lens doesn't exist with ROM.
}
elsif ($focalLengthReal == 560)
{
$lensName[0] = "Novoflex Telyt-R 560 mm f/6,8";
# But this lens doesn't exist with ROM.
}
}
elsif ($maxAperture == 8)
{
$lensName[0] = "Leica MR-Telyt-R 500 mm f/8";
# But this lens doesn't exist with ROM.
}
}
return @lensName;
}
#------------------------------------------------------------------------------
#
# ### main ###
#
# ExifLeicaR - Test's program
#
# Usage: ExifLeicaR.pl <image name>
#
# Revisions: 0.1 - 04/2012 - Gautier
#
# A photo must be given as 1st parameter
my $photo = shift or die "Merci d'indiquer un nom de fichier image / Thanks to give an image file";
# Read EXIF from the photo
my $exifTool = new Image::ExifTool;
my $info = $exifTool->ImageInfo($photo);
# Check that the photo has been taken using a Leica Digital-Modul-R
my $camera = $exifTool->GetValue('UniqueCameraModel');
if (!$camera)
{
$camera = "?";
}
my $model = $exifTool->GetValue('Model');
if (!$model)
{
$model = "?";
}
if (($camera eq "Leica DMR") || ($model =~ /Digital Back DMR/) || ($model =~ /Leica DMR/))
{
# The image is a DMR one, we can create/modify the tag Lens
# Read the focal length
$focalLength = $exifTool->GetValue('FocalLength');
if (!$focalLength)
{
$focalLength = 0.0;
}
my @focalLengthArray = split(' ', $focalLength);
my $focalLengthReal = $focalLengthArray[0];
print "Longueur focale / Focal length = $focalLengthReal mm\n";
# Read the MaxApertureValue tag (to determine the type of lens)
$maxAperture = $exifTool->GetValue('MaxApertureValue');
if (!$maxAperture)
{
$maxAperture = 0.0;
}
print "Ouverture maximale / Max aperture = f/$maxAperture\n";
# Try to find the right lens
my @tabLenses = ();
#print "giveLensName($focalLengthReal, $maxAperture)\n";
@tabLenses = &giveLensName($focalLengthReal, $maxAperture);
if (exists($tabLenses[0]) && !exists($tabLenses[1]))
{
$lensName = $tabLenses[0];
print "Objectif determiné / Lens defines [$lensName]\n";
$exifTool->SetNewValue(Lens => $lensName);
print "Mise à jour / Update \"$photo\"\n";
$exifTool->WriteInfo($photo);
}
else
{
if (!exists($tabLenses[0]))
{
print "Objectif indeterminé / Lens undefined [$focalLengthReal mm @ f/$maxAperture]\n";
}
else
{
print "Plusieurs objectifs possibles / Several possible lenses [$focalLengthReal mm @ f/$maxAperture]\n";
foreach my $element (@tabLenses)
{
print " - $element\n";
}
# This list should be compared to a personal list of lenses. If there is only one lens in the two lists, we can conclude.
# If not, we have to chose manually the right lens.
# TBD
}
}
}
else
{
# The script is stopped because the image is not a DMR one
print "La photo \"$photo\" n'a pas été prise avec un Leica DMR (ou données manquantes) [$camera / $model].\n";
print "The photo \"$photo\" has not been taken with a Leica DMR (or lack of data) [$camera / $model].\n";
}
Exemple d'appel :
./ExifLeicaR.pl Exemples/L1041528.DNG
Longueur focale / Focal length = 560.0 mm
Ouverture maximale / Max aperture = f/5.5
Objectif determiné / Lens defines [Leica Apo-Telyt-R 560 mm f/5,6]
Mise à jour / Update "Exemples/L1041528.DNG"
Dans Lightroom, on peut demander à ce que les métadonnées soient relues depuis le fichier. L'affichage devient alors pour ce fichier L1041528.DNG :
Ca ne sert pas à grand chose, mais mes Leica R se démarquent moins des autres
