Calculation of the focal length (in one run)
Posted: 2011-08-10T09:41:16-07:00
I am working on a Windows batch file that performs a correction for lens distortion. At the start, I have to identify the focal length of the photograph by
identify -format "%[EXIF:FocalLength]" testimage.jpg
Typically, EXIF data on focal length is given as a fraction, i.e. something like 27/1, meaning 27 mm, or 82/10, meaning 8.2 mm. In order to use this value in a comparison (with a list of focal lengths for which the correction parameters are known), I have to evaluate that fraction. I do this by means of IM's fx command in a two-step approach:
1) I assign the fraction to a environment variable.
2) I evaluate the content of the environment variable.
In a Windows batch file:
The focal length is then contained in the environment variable FL.
My question: Is there any way to combine these two statements into one, that is evaluating the EXIF fractional value directly with IM?
identify -format "%[EXIF:FocalLength]" testimage.jpg
Typically, EXIF data on focal length is given as a fraction, i.e. something like 27/1, meaning 27 mm, or 82/10, meaning 8.2 mm. In order to use this value in a comparison (with a list of focal lengths for which the correction parameters are known), I have to evaluate that fraction. I do this by means of IM's fx command in a two-step approach:
1) I assign the fraction to a environment variable.
2) I evaluate the content of the environment variable.
In a Windows batch file:
Code: Select all
SETLOCAL EnableDelayedExpansion
FOR /F %%i in ('identify -format "%%[EXIF:FocalLength]" %1') DO SET FL=%%i
FOR /F %%i in ('convert xc: -format "%%[fx:!FL!]" info:') DO SET FL=%%i
My question: Is there any way to combine these two statements into one, that is evaluating the EXIF fractional value directly with IM?