Does exiftool needs some special start-up init?

Started by Archive, May 12, 2010, 08:53:51 AM

Previous topic - Next topic

Archive

[Originally posted by tschnebeck on 2005-10-18 07:06:37-07]

Hi Phil,

ok, a new strange problem. As you know I use a perl program in a C++ program. As a debug message I print out the program and two non-string values. When using this program in a console window I get:

Code:
perl -e 'my $file="/home/schnebeck/EOS/20D-Test/2005-10-16/img_7365.cr2";use Image::ExifTool;my $exiftool = new Image::ExifTool;$exiftool->Options(PrintConv => 1);$exiftool->Options(Binary => 0);my $info = $exiftool->ImageInfo($file);$return01=$$info{'Make'};$return02=$$info{'Model'};$return03=$$info{'FocalLength35efl'};if ($return03 == "") {$return03=$$info{'FocalLength'};}$return04=$$info{'Aperture'}; print $return04;$return05=$$info{'ShutterSpeedValue'};if ($return05 == "") {$return05=$$info{'ShutterSpeed'};};$return05=$return05."s"; print $return05;$return06=$$info{'Lens'}."/".$$info{'MaxAperture'};$return07=$$info{'CreateDate'};if ($return07 == "") {$return07=$$info{'DateTimeOriginal'};}$return08=$$info{'ISO'};$return09=$$info{'FlashOn'};$return10=$$info{'ExifImageWidth'};if ($return10 == "") {$return10=$$info{'ImageWidth'};}$return11=$$info{'ExifImageLength'};if ($return11 == "") {$return11=$$info{'ImageHeight'};}$return12=$$info{'XResolution'};'
6.3
1/1000s
when using the same code in my embedded perl I get

Code:
KFileMetainfo (plugins): rawimagePlugin::readInfo: my $file="/home/schnebeck/EOS/20D-Test/2005-10-16/img_7365.cr2";use Image::ExifTool;my $exiftool = new Image::ExifTool;$exiftool->Options(PrintConv => 1);$exiftool->Options(Binary => 0);my $info = $exiftool->ImageInfo($file);$return01=$$info{'Make'};$return02=$$info{'Model'};$return03=$$info{'FocalLength35efl'};if ($return03 == "") {$return03=$$info{'FocalLength'};}$return04=$$info{'Aperture'}; print $return04;$return05=$$info{'ShutterSpeedValue'};if ($return05 == "") {$return05=$$info{'ShutterSpeed'};};$return05=$return05."s"; print $return05;$return06=$$info{'Lens'}."/".$$info{'MaxAperture'};$return07=$$info{'CreateDate'};if ($return07 == "") {$return07=$$info{'DateTimeOriginal'};}$return08=$$info{'ISO'};$return09=$$info{'FlashOn'};$return10=$$info{'ExifImageWidth'};if ($return10 == "") {$return10=$$info{'ImageWidth'};}$return11=$$info{'ExifImageLength'};if ($return11 == "") {$return11=$$info{'ImageHeight'};}$return12=$$info{'XResolution'};
6,0
1/512s
This error only happens with non string values. Maybe anything with LANG cause of dot and comma? Any idea?

Bye

Thorsten

Archive

[Originally posted by exiftool on 2005-10-18 11:53:54-07]

Hi Thorsten,

The incorrect aperture is definitely because of the comma instead of the decimal in the number.  I'm not sure about the shutter speed, but it could be the same problem.

Actually, I'm not sure how ExifTool works at all with commas in the numbers.  As far as I know, this is not standard Perl. ExifTool uses the following standard regular expression to test for a floating point number:

Code:
   /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/

This C++ version of Perl seems to have some odd peculiarities.  Maybe we should discuss these problems via email rather than in this forum since they probably aren't of interest to many others.

Archive

[Originally posted by exiftool on 2005-10-19 15:54:06-07]

Hi Thorsten,

I'm posting back in this thread after our email exchange since I think the solution is applicable to others using the ExifTool API if they are using locales in their scripts.  I had suggested going offline with your problems partly because I was anticipating other unique problems associated with using the C++ version of Perl, but it seems this wasn't the case since you now have things working after solving this problem.

The problem with different locales was a bit tricky, and from what I have seen Perl isn't very consistent about its handling of floating point numbers in locals which use a comma instead of a decimal point.  For example:

Code:
> perl -e 'use POSIX qw(locale_h);setlocale(LC_ALL,"de_DE");my $a = 3/2;print $a . " " .3/4 ,"\n"'
1,5 0,75
> perl -e 'use POSIX qw(locale_h);setlocale(LC_ALL,"de_DE");my $a = 3/2;print 3/2 . " " .3/4 ,"\n"'
1.5 0.75

But I have changed ExifTool and released a new version (5.69) which is more tolerant of these locales, and to convert floating point numbers properly if the locale uses commas instead of decimal points.  This also applies when writing floating point values.