[Bug report] if condition FocalLength evaluation bug

Started by bobby, October 11, 2018, 07:43:36 AM

Previous topic - Next topic

bobby

Hi,

I wrote a command to return all images in the focal length range of 16 to 35mm. Unfortunately, Exiftool seems to only evaluate the first two digits once three digit numbers are thrown into the mix. For example:

IMG006.tif is correctly reported to be in the range at 28.0 mm
IMG016.tif is incorrectly reported to be in the range at 271.0 mm

If you go through the list, you'll notice that all images at  >= 100mm are only reported to be in the range if the first two digits are. There are some pictures in the folder that were shot at 400mm and they aren't included in the query results (rightfully so, since 40 is out of the range).

Here's the command:
exiftool -FocalLength -if '$FocalLength# ge "16" && $FocalLength# le "35"' dir

Here's the output:
======== /Users/robert/Desktop/2018-09 - Velvia 50 - Airport cropped/IMG009.tif
Focal Length                    : 16.0 mm
======== /Users/robert/Desktop/2018-09 - Velvia 50 - Airport cropped/IMG008.tif
Focal Length                    : 16.0 mm
======== /Users/robert/Desktop/2018-09 - Velvia 50 - Airport cropped/IMG032.tif
Focal Length                    : 278.0 mm
======== /Users/robert/Desktop/2018-09 - Velvia 50 - Airport cropped/IMG014.tif
Focal Length                    : 16.0 mm
======== /Users/robert/Desktop/2018-09 - Velvia 50 - Airport cropped/IMG015.tif
Focal Length                    : 16.0 mm
======== /Users/robert/Desktop/2018-09 - Velvia 50 - Airport cropped/IMG017.tif
Focal Length                    : 271.0 mm
======== /Users/robert/Desktop/2018-09 - Velvia 50 - Airport cropped/IMG002.tif
Focal Length                    : 349.0 mm
======== /Users/robert/Desktop/2018-09 - Velvia 50 - Airport cropped/IMG016.tif
Focal Length                    : 271.0 mm
======== /Users/robert/Desktop/2018-09 - Velvia 50 - Airport cropped/IMG012.tif
Focal Length                    : 16.0 mm
======== /Users/robert/Desktop/2018-09 - Velvia 50 - Airport cropped/IMG006.tif
Focal Length                    : 28.0 mm
======== /Users/robert/Desktop/2018-09 - Velvia 50 - Airport cropped/IMG007.tif
Focal Length                    : 35.0 mm
======== /Users/robert/Desktop/2018-09 - Velvia 50 - Airport cropped/IMG013.tif
Focal Length                    : 16.0 mm
======== /Users/robert/Desktop/2018-09 - Velvia 50 - Airport cropped/IMG005.tif
Focal Length                    : 234.0 mm
======== /Users/robert/Desktop/2018-09 - Velvia 50 - Airport cropped/IMG011.tif
Focal Length                    : 16.0 mm
======== /Users/robert/Desktop/2018-09 - Velvia 50 - Airport cropped/IMG010.tif
Focal Length                    : 16.0 mm
1 directories scanned
   21 files failed condition
   15 image files read


1) Your system type (Windows XP, Linux, Mac, etc).
Mac OS X 10.14 (18A391)

2) The ExifTool version you are using (the output of the "exiftool -ver" command).
Exiftool 11.13


Thanks for creating and maintaining this wonderful piece of software! Means a lot to me!
Bobby

Phil Harvey

Hi Bobby,

You should use the numerical comparisons ">=" and "<=" instead of the string comparisons "ge" and "le".

- 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 ($).

bobby

Hi Phil,

Thanks, that fixed it!

Just out of curiosity: I thought exiftool basically works with all perl operators including ge and le? Does exiftool just support a subset of them?

- Bobby

Phil Harvey

Hi Bobby,

ExifTool works with all Perl operators.  "ge" and "le" are Perl string comparison operators.  For example, as a string "100" is less than "20" (ASCII "1" is less than ASCII "2").

- 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 ($).