Extraction Tags issue

Started by Janc, May 05, 2010, 08:22:35 AM

Previous topic - Next topic

Janc

Dear Phil:

I found diferent output in next samples, and after many test, I can't find were is the diference:

Command 1:
> exiftool -FocalLength35efl picture0001.nef

Output is:
Focal Length                    : 95.0 mm (35 mm equivalent: 142.0 mm)
Which is the right one.

Command 2:
> exiftool -FocalLength -FocalLength35efl picture0001.nef
Output is:
Focal Length                    : 95.0 mm
Focal Length                    : 95.0 mm (35 mm equivalent: 142.0 mm)

But with Perl code:

use Image::ExifTool;
my $Original = picture0001.nef;
my $exifTool = new Image::ExifTool;
my $exif_info = $exifTool->ImageInfo($Original, , 'FocalLength35efl');

The output in $exif_info is:
95,0 mm (35 mm equivalent: 95,0 mm)
Which is wrong because both values are 95,0 mm.

I'm using, in my program, the Perl code.

Attached the full output of: exiftool picture0001.nef

Thanks a lot in advanced for your nice help.

My best regards.



Phil Harvey

Try also extracting "ExifToolVersion" to be sure you are using the same version of the library as your application.  I suspect you have a really really old version of the library installed somewhere else.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Janc

Quote from: Phil Harvey on May 05, 2010, 08:28:57 AM
Try also extracting "ExifToolVersion" to be sure you are using the same version of the library as your application.  I suspect you have a really really old version of the library installed somewhere else.

- Phil

I'm going to check it.

I will tell you as soon I have it.

Thanks.
Regards.

Janc

Hi Phil:

I discovered that I have two diferent instalations of ExifTool and Image::EXIFTOOL

My program is working under LAMPP.

In the LAMPP instalation:
/opt/lampp/bin/exiftool -ver
8.15


/opt/lampp/bin/cpan
cpan[15]> i Image::ExifTool
INST_FILE    /opt/lampp/lib/perl5/site_perl/5.10.1/Image/ExifTool.pm
INST_VERSION 8.15


In my Linux system
/usr/bin/exiftool -ver
8.10


/usr/bin/cpan
cpan[2]>  i Image::ExifTool
INST_FILE    /usr/lib/perl5/site_perl/5.10.0/Image/ExifTool.pm
INST_VERSION 8.10


So, I have version 8.15 under LAMPP and version 8.10 in my linux system.

Knowing this two diferent versions:
Do you mean they are mixing code or is it that ver 8.15 does not handle the tag FocalLength35efl in the same way?

Thanks.
My best regards.

Janc

Hi! Phil:

I have install version 8.15 in my Linux system, so now I have both the same version, in case there are any path mistakes.

I am still having some problem:

The tag I'm having trouble is:
The command line:
exiftool -FocalLength35efl picture0001.nef
Focal Length                    : 95.0 mm (35 mm equivalent: 142.0 mm)

But, in my script:
use Image::ExifTool;
my $Original = picture0001.nef;
my $exifTool = new Image::ExifTool;
my $exif_info = $exifTool->ImageInfo($Original, , 'FocalLength35efl');


The output in $exif_info is:
95,0 mm (35 mm equivalent: 95,0 mm)

If trying with tag: FocalLength
my $exif_info = $exifTool->ImageInfo($Original, , 'FocalLength');
The output:
95,0 mm

So, How can I get the nice output when: use Image::ExifTool; in my script?
Focal Length                    : 95.0 mm (35 mm equivalent: 142.0 mm)

I keep searching about.

Thanks for your nice attention.
Regards.



Janc

I find a way to get both focal distances.

use Image::ExifTool;
my $Original = picture0001.nef;
my $exifTool = new Image::ExifTool;
my $exif_info = $exifTool->ImageInfo($Original, 'FocalLength', 'FocalLengthIn35mmFormat');


So now the output in $exif_info is:
95,0 mm
142 mm
I will put them in the same output line in my script, as it was before.

About DOF tag, is something similar.
In command line:
exiftool picture0001.nef
Line about DOF is:
Depth Of Field                  : 165.98 m (18.42 - 184.40)

But if I try to extract it with:
my $exif_info = $exifTool->ImageInfo($Original, 'DOF');[/tt]
Output is:
inf (0,00 m - inf)

Perhaps those tags names are diferent in this Nikon D300 nef files?

Attached full output of:
exiftool -list janc_20100421_100323_0_0001.nef > exiftool_tags_names_in_nef.txt

Regards.

Phil Harvey

When I said really old, I meant 6.xx or maybe older.  The 35mm scaling factor calculation hasn't changed in a long time.

I ran the following script on a Nikon D300 NEF image here:

#!/usr/bin/perl -w
use strict;
use Image::ExifTool;
my $Original = "NikonD300.nef";
my $exifTool = new Image::ExifTool;
my $exif_info = $exifTool->ImageInfo($Original, 'FocalLength35efl');
print $$exif_info{FocalLength35efl},"\n";
# end


and it gave this output:

26.0mm (35mm equivalent: 39.0mm)

So I don't understand what is going on.  Try extracting and printing all tags/values with your script and posting the result.

Note that your script example won't run because the file name must be quoted.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Janc

Quote from: Phil Harvey on May 06, 2010, 07:01:10 AM
When I said really old, I meant 6.xx or maybe older.  The 35mm scaling factor calculation hasn't changed in a long time.

I ran the following script on a Nikon D300 NEF image here:

#!/usr/bin/perl -w
use strict;
use Image::ExifTool;
my $Original = "NikonD300.nef";
my $exifTool = new Image::ExifTool;
my $exif_info = $exifTool->ImageInfo($Original, 'FocalLength35efl');
print $$exif_info{FocalLength35efl},"\n";
# end


and it gave this output:

26.0mm (35mm equivalent: 39.0mm)

So I don't understand what is going on.  Try extracting and printing all tags/values with your script and posting the result.

Note that your script example won't run because the file name must be quoted.

- Phil


I am goint to test your script and extract all tags/values in my system. I will let you know about.

My script was just as example, the nef file name is in a variable.

Janc, I will be back soon. Thanks.


Janc

When run on a terminal:
With shebang:
#!/usr/bin/perl -w
the output is OK:
95.0 mm (35 mm equivalent: 142.0 mm)

but when run as cgi inside the LAMPP server that has its own Perl and Exiftool install,
With shebang:
#!/bin/perl -w
the output is wrong:
95,0 mm (35 mm equivalent: 95,0 mm)

I'm going to check all Exiftool install under LAMPP.

I will let you know about.

Cheers. Janc.


Janc

#9
I test with your script in terminal and the same code under LAMPP and output is:
Terminal: 95.0 mm (35 mm equivalent: 142.0 mm)
LAMPP: 95,0 mm (35 mm equivalent: 95,0 mm)

I also check with diff both installations of Exiftool version 8.15

diff -ras --normal /usr/lib/perl5/site_perl/5.10.0/Image /opt/lampp/lib/perl5/site_perl/5.10.1/Image
and found both dirs and files are identical.

The only diference is perl 5.10.0 and perl 5.10.1 but I don't think it could be the problem.

About RandomAccess.pm
INST_FILE    /usr/lib/perl5/site_perl/5.10.0/File/RandomAccess.pm
INST_VERSION 1.10

INST_FILE    /opt/lampp/lib/perl5/site_perl/5.10.1/File/RandomAccess.pm
INST_VERSION 1.10

Anything about code page? I have all system with LANG=es_ES.UTF-8

I don't know where to look for more differences, but I will keep searching about.

I will be interesting to know where is the trouble.

Regards.
Janc





Janc

I narrowing the problem.

I have commented all references to locale and utf8 and now it is OK

# use POSIX qw(locale_h);
# use utf8;
# setlocale( LC_ALL, "es_ES.utf8" ) or die "Error";


I need them in another script because the use of spanish letters like á é í ó ú and ñ Ñ.

Now output of tag 'FocalLength35efl' is:
95.0 mm (35 mm equivalent: 142.0 mm)

So all the problem is about POSIX or locale or utf8. I will study a bit more about Locale and UTF-8.

Cheers.
Janc



Phil Harvey

Hi Janc,

Interesting.  This makes a bit of sense now.  I have had problems with "use utf8" in the past, but thought that I had them all solved.  If you can come up with a sample code so I can reproduce the problem it would be useful.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Janc

Quote from: Phil Harvey on May 06, 2010, 07:26:11 PM
Hi Janc,

Interesting.  This makes a bit of sense now.  I have had problems with "use utf8" in the past, but thought that I had them all solved.  If you can come up with a sample code so I can reproduce the problem it would be useful.

- Phil

Hi Phil.

Here is a test code, it runs under Apache 2.2.14, Perl 5.10.1, Exiftool 8.15.
#!/bin/perl -w

use strict;
use Image::ExifTool;

# All problem are about the next three lines.
#~ use POSIX qw(locale_h);
#~ use utf8;
#~ setlocale( LC_ALL, "es_ES.utf8" ) or die "Error";

BEGIN {
$|=1;
print "Content-type: text/html\n\n";
use CGI::Carp('fatalsToBrowser');
}

print <<EOM;
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Pragma" content="no-cache"><meta http-equiv="expires" content="0">
</head><body>
EOM

my $PathOriginal = "/home/user/htdocs/img/picture0001.nef";

# ########### Problem appear only with 'DOF' and 'FocalLength35efl' #############

my @TagList = qw(ISO Aperture ShutterSpeed ExposureCompensation DOF FocalLength FocalLengthIn35mmFormat FocalLength35efl ImageSize);

my $exifTool = new Image::ExifTool;

my $exif_info = $exifTool->ImageInfo($PathOriginal, @TagList);

print "<table><tr><td colspan=2><h1>Datos Exif:</h1></td></tr>";

for (my $z=0; $z < @TagList; $z++ ){
        print "<tr><td><font class=\"texto_1\">$TagList[$z]</font></td>";
        print "<td><h3>$exif_info->{$TagList[$z]}</h3></td></tr>";
}
print "</table></body></html>";

undef $exifTool;

__END__


This code as it is here is working OK, but if uncomment any of the three lines on top of code, it became unestable.

I am self-taught Perl programmer so I still don't have a clear knowledge about 'locale' 'utf-8' and so on.

Cheers.
Janc.

Phil Harvey

Thanks.  I'll look into this as soon as I can.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Janc

Quote from: Phil Harvey on May 08, 2010, 05:46:36 AM
Thanks.  I'll look into this as soon as I can.

- Phil

Hi Phil.

I have been reading a little bit about utf-8 and locale and I arrived to know that in my system, openSUSE 11.1, where every code is working as UTF-8 I must use in my Perl scripts only:
use utf-8
and in html pages:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
I have changed all my scripts to only "use utf-8" and the are working nicely with exiftool.
use utf8;
# use POSIX qw(locale_h);
# setlocale( LC_ALL, "es_ES.utf8" ) or die "Error";


If I can take a little free time I will investigate a little bit more.

Thanks a lot.
Regards.
Janc