Question to PrintConv function for rational numbers

Started by herb, July 22, 2011, 12:50:06 PM

Previous topic - Next topic

herb

Hello,

the PrintConv function of ExifTool is a very good feature.
In case of tags like Flash, that allow only some specific values, it is easy to understand how this function works.
For example the following output is for me selfexplaining:
   exiftool -n -flash <file>: 16
   exiftool    -flash <file>: Off, Did not fire

But it is not clear to me how PrintConv is working for rational numbers.
E.g. the tags -XResolution, -ExposureTime and -FNumber are all of type rational64u and for different values I get the following output.

Some of my images typically show the following output
   exiftool -n -xresolution -exposuretime -fnumber <file>:   72     0.002           8
   exiftool     -xresolution -exposuretime -fnumber <file>:   72     1/500           8.0

After writing new values
   exiftool -xresolution=75.12 -exposuretime=4.55 -fnumber=5.65
I get the following output
   exiftool -n -xresolution -exposuretime -fnumber <file>:   75.12  4.55            5.65
   exiftool     -xresolution -exposuretime -fnumber <file>:   75.12  4.6              5.7

After writing new values
   exiftool -xresolution=0.12 -exposuretime=1/300 -fnumber=0.45
I get the following output
   exiftool -n -xresolution -exposuretime -fnumber <file>:    0.12  0.00333333333   0.45
   exiftool     -xresolution -exposuretime -fnumber <file>:    0.12  1/300                   0.5


Now I have some questions
(Please do not discuss, whether the values in above examples make sense in real life)
- why is for ExposureTime a value < 1 converted to e.g. 1/300
  for  XResolution and FNumber it is not done
- why is for FNumber the value 0.45 converted to 0.5 (only 1 digit after separator ".")
  in case of 0.003333333333 I see 12 digits after separator
  (is 12 the maximum digits after separator ".")

Where can I find the (maybe tag-specific) information about the behavior of ExifTool for rational numbers.
Thanks for your comments and help in advance.

Herb

Phil Harvey

Hi Herb,

The print conversion for values like this is simply a conversion to a more common format.  Typically, shutter speeds less than one second are displayed as a fraction, so this is what ExifTool does.  Also, nobody wants to see a zillion decimal places in their FNumber, so ExifTool rounds to 1 decimal for the print conversion.

I hope this makes sense.

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

herb

Hello Phil,

thanks for your quick reply.
I fully agree that is makes no sense to see a zillion decimal places e.g. in FNumber.

My question was a more technical one:
- is there only one rule how ExifTool will behave
  or maybe are there onyl some rules for specific tag-groups, how ExfTool will behave
- or has each tag its specific rule for a print conversion
and
- is it hard coded inside ExifTool or
- does a "configuration file" exist where these"rules" are stored?

Thanks again for your comments in advance.

Herb

Phil Harvey

Hi Herb,

Each tag has its own rule, and the rules are hard-coded, but you can see them all by searching for PrintConv in the source code.  For example, the Exif module.

Note that all tag definitions may be overridden in the config file if you want to change any of these conversions.

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

herb

Hello Phil,

thanks again for your quick reply and thanks that I could have a look into the inner circle of ExifTool engine.
It is wonderful how many details you coded for each tag.

Thanks for your great ExifTool.

Herb