whugemann wrote:My question: Is there any way to combine these two statements into one, that is evaluating the EXIF fractional value directly with IM?
In IMv6 no.
IN IMv7 maybe...
I plan to ensure that IMv7 allows you better access to the global defines and per-image settings, both for any arguments and for -fx arguments. My plan however was for substitutions in FX expressions to be a 'values' that is in the same way FX currently handles internal assignments. For example, I was planing on allowing this...
That was the extent of my planned change.
The following is rambling thoughts as to solutions for IMv7
However to actually 'execute' an expression stored in a 'variable' such as EXIF:FocalLength would require the equivalent of a shell 'eval' or the ability to define a FX like function declaration. Alternately it would require string functions! That is the ability manipulate strings and not just numbers, so that you can 'split' the string into two numbers.
This is very similar to the UNIX 'awk' command (also perl) where all variables can be either a string or a number. How the variable contents is treated (as a number or a string) depends on the operators around it. Note that a string that does not contain a number, but is used in a numerical operation results in a value of zero).
Now in "awk" a variable assigned a string values of say "114/10" would actually have a value of 114, It would not be thought of as being 11.4. However in awk you could use string manipulation to extract the two numbers (assuming a '/' is present in the string) and divide them. Not exactly a nice solution either.
Now currently FX treats all variables, even its pre-assigned variables like 'r' and 's.r' purely as a number. It does not currently allow string manipulation. But if it did, it could do the same as awk, but it would not be as simple as an 'eval' solution.
Eval however is 'dangerous' and a
major security hazard. It is something to be avoided as much as possible as it is far to 'general purpose'! For example what if a hacker sets a special focal length string that was designed to 'crack' your photo web application!
Anyone has any thoughts or suggestions?