# Lua Extensions

- The Geeqie User Manual
- Reference

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.

- 11.6.1.Requirements
- 11.6.2.How to use Lua
- 11.6.3.Geeqie Lua built-in functions
- 11.6.4.Examples
- 11.6.5.Warning

## 11.6.1.Requirements

Use of Lua within Geeqie requires Lua 5.1 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.

## 11.6.2.How to use Lua

Lua scripts must be stored in a single folder:

        ~/.config/geeqie/lua/

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.

## 11.6.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.

## 11.6.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:

    --Retrieve the jpeg comment of a file
    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))

## 11.6.5.Warning

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