I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2010-06-23 12:37:44.45881-07 by alyda
Duplicate tags (Nikon:FlashExposureComp) return different values

Hi Phil,


I had some help from you a while back (2010-02-03) on writing exposure compensation values into keywords if I was shooting in Exposure Bracketing mode.


Command line:

exiftool -sep ", " '-keywords+<EBV: ${Nikon:ExposureBracketValue}, EC: ${EC}' -overwrite_original - +if '$Nikon:ShootingMode =~ "Exposure Bracketing"' *.nef

My .ExifTool_config file looks like this:

%Image::ExifTool::UserDefined = ( 'Image::ExifTool::Composite' => { FN => { Require => 'Nikon:FileNumber', PrintConv => 'sprintf("%07d",$val)', }, SC => { Require => 'Nikon:ShutterCount', PrintConv => 'sprintf("%07d",$val)', }, EC => { Require => { 0 => 'ExposureBracketValue', 1 => 'EXIF:ExposureCompensation', }, ValueConv => '$val[1] - $val[0]', PrintConv => 'Image::ExifTool::Exif::ConvertFraction($val)', }, FEC => { Require => 'Nikon:FlashExposureComp', PrintConv => 'Image::ExifTool::Exif::ConvertFraction($val)', }, }, ); #end

I'm making the switch to a perl script because I can't think of a way to use two '-if' conditions--one for exposure compensation, the other for flash compensation (-if 'not $ExifIFD:Flash =~ "No Flash"')--without making two passes.


It looks like I can get where I want to go if I take advantage of the GetValue, SetNewValue and WriteInfo methods of the Image::ExifTool module: 'SetNewValue - Set the new value for a tag. The routine may be called multiple times to set the values of many tags before using "WriteInfo" to write the new values to an image.'


The problem is that I'm seeing duplicate tags for 'Nikon:FlashExposureComp' and they return different values.


Code:

#!/usr/bin/perl use Image::ExifTool; my $exifTool = new Image::ExifTool; my $filename = '20100619-14320274_0025637_3092117.nef'; my $tag1 = 'ExifIFD:Flash'; my $tag2 = 'Nikon:FlashMode'; my $tag3 = 'Nikon:FlashExposureComp'; my $flash = $exifTool->ImageInfo($filename, $tag1, $tag2, $tag3); foreach (keys %$flash) { print "$_ => $$flash{$_}\n"; }

Returns:

FlashExposureComp (1) => -5/3 FlashExposureComp (2) => -5/3 FlashExposureComp => 0 FlashMode => Fired, TTL Mode Flash => On, Return detected

Help!


Direct Responses: 12799 | Write a response