Defining Custom Columns

ExifPRo presents detailed EXIF information while in the details view mode. Apart from predefined set of columns representing different image attributes, users can define their own columns. Select Edit/Define Custom Columns or press Shift+Ctrl+F to open column definition window.

Custom Columns

Columns defined here may be selected in the Options/Columns dialog, or directly by right clicking on a column header.

Expression defining custom column is expected to return single value (either string or a number). Because scripting language Lua (www.lua.org) is used to define those expressions, there's much more than a simple arithmetical expression that can be used. Logical statements if ... then ... else are supported too, as well as loops, and local variables. Lua reference manual gives an idea what kind of functions and constructs are available.

Examples

Comments in the expression scripting language start with two dashes, and end at the end of line:

-- this is a comment; it is ignored by scripting language, but useful for describing purpose of calculations

Scripting language supports string operations. Here's an example using camera model and simple string comparison:

if img.model == "NIKON D200" then
    return "D200"
elseif img.model == "Canon EOS Digital Rebel Xti" then
    return "400D"
else
    return img.model
end

The same example can be rewritten to use equivalent of the switch statement (that is not available directly):

local trans= { ["NIKON D200"]="D200", ["Canon EOS Digital Rebel Xti"]="400D" }
return trans[img.model] or img.model  -- return translated name (if present) or original one otherwise

Using string functions to extract part of a string:

if string.sub(img.model, 1, 6) == "NIKON " then
    return string.sub(img.model, 7, -1)  -- substring from 7-th character to the end
else
    return img.model
end

Numerical attributes can be manipulated using arithmetical operators. Next example calculates 35mm focal length equivalent for cameras that have sensor smaller than a full frame:

return img.fl * img.fovc	-- multiply focal length by "field of view crop"

If calculations become complex, we can break them using local variables to hold temporary results. For instance, to calculate how much amplification camera used to take a picture, we can combine image attributes as follows:

if img.fn > 0 then
    local x= 1 / img.fn    -- local variable
    return x^2 * img.iso * img.et;
else
    return 0
end

When numerical result of calculation becomes unwieldy to display (has too many digits), we can round it such that it retains desired number of decimal places. To do so, we use round() function. It accepts number to round, and number of decimal places to retain.

For instance:

round(1/3, 2)       --> 0.33
round(123456, -3)   --> 123000