Lua Extensions

Lua scripts allow the functionality of Geeqie to be extended. Lua scripts may only be used in conjunction with the Overlay Screen Display .

Some knowledge of the Lua programming language is required.

13.5.1. Requirements

Use of Lua within Geeqie requires Lua to be installed. If you are compiling from sources, Lua functionality will be available if the development files dependencies are met.

If you are using a pre-compiled distribution, availability depends on the package maintainer.

13.5.2. How to use Lua

Lua scripts must be stored in a single folder as defined in Configuration Files and Locations .

A link to a Lua script must be inserted into the overlay template. Refer to the Overlay Screen Display section of Window Options.

The full extent of the Lua language is available.

13.5.3. Geeqie Lua built-in functions

The following functions are built in to Geeqie:

Function Returns
Image:get_path() The full path of the file, including filename and extension
Image:get_name() The full filename including extension
Image:get_extension The file extension including preceeding dot
Image:get_date() The file date in Unix timestamp format.
Image:get_size() The file size in bytes
Image:get_exif() A data structure containing the entire exif data
<exif_str>:get_datum("<exif_tag>") A single exif tag extracted from a structure output by the above command

The keyword "Image" refers to the file currently being displayed by Geeqie.

13.5.4. Examples

The following example, which outputs the jpeg comment of a file, demonstrates the use of a built-in function and how to call a system command from a Lua script:

        path=Image:get_path()
        commentfile=io.popen("exiv2 -p c \"" .. path .. "\"" )
        comment = commentfile:read("*a")
        commentfile:close()
        return (comment)
      

Note that it is necessary to have escape characters surrounding path and filenames.

The following example demonstrates how to extract exif data from a file:

        --Retrieve the DateTimeDigitized exif tag
        exif_structure = Image:get_exif();
        DateTimeDigitized = exif_structure:get_datum("Exif.Photo.DateTimeDigitized");
        return (os.date(DateTimeDigitized))
      

13.5.5. Warning

Lua is a powerful programming language. Errors in script files, besides having undesirable side-effects, may cause Geeqie to crash.