1 <?xml version="1.0" encoding="utf-8"?>
\r
2 <section id="GuideReferenceLua">
\r
3 <title>Lua Extensions</title>
\r
5 Lua scripts allow the functionality of Geeqie to be extended. Lua scripts may only be used in conjunction with the
\r
6 <link linkend="OverlayScreenDisplay">Overlay Screen Display</link>
\r
8 <link linkend="GuideSidebarsInfo" endterm="Listpanes-ExifFileinfoCopyrightLocationandGPS">List panes</link>
\r
9 on the Info Sidebar, and the
\r
10 <programlisting xml:space="preserve">geeqie --remote --lua:</programlisting>
\r
11 command line option.
\r
14 <para>Some knowledge of the Lua programming language is required.</para>
\r
15 <section id="Requirements">
\r
16 <title>Requirements</title>
\r
17 <para>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.</para>
\r
18 <para>If you are using a pre-compiled distribution, availability depends on the package maintainer.</para>
\r
20 <section id="HowToUseLua">
\r
21 <title>How to use Lua</title>
\r
23 Lua scripts must be stored in a single folder as defined in
\r
24 <link linkend="GuideReferenceConfig" endterm="titleGuideReferenceConfig" />
\r
28 A link to a Lua script must be inserted into the overlay template. Refer to the
\r
29 <link linkend="OverlayScreenDisplay">Overlay Screen Display</link>
\r
30 section of Window Options.
\r
32 <para>The full extent of the Lua language is available.</para>
\r
34 <section id="GeeqieBuiltIn Functions">
\r
35 <title>Geeqie Lua built-in functions</title>
\r
36 <para>The following functions are built in to Geeqie:</para>
\r
43 <emphasis role="strong">Function</emphasis>
\r
46 <emphasis role="strong">Returns</emphasis>
\r
50 <entry>Image:get_path()</entry>
\r
51 <entry>The full path of the file, including filename and extension</entry>
\r
54 <entry>Image:get_name()</entry>
\r
55 <entry>The full filename including extension</entry>
\r
58 <entry>Image:get_extension</entry>
\r
59 <entry>The file extension including preceeding dot</entry>
\r
62 <entry>Image:get_date()</entry>
\r
63 <entry>The file date in Unix timestamp format.</entry>
\r
66 <entry>Image:get_size()</entry>
\r
67 <entry>The file size in bytes</entry>
\r
70 <entry>Image:get_marks()</entry>
\r
71 <entry>An integer representing the marks set for the file</entry>
\r
74 <entry>Image:get_exif()</entry>
\r
75 <entry>A data structure containing the entire exif data</entry>
\r
78 <entry><exif_str>:get_datum("<exif_tag>")</entry>
\r
79 <entry>A single exif tag extracted from a structure output by the above command</entry>
\r
85 <para>The keyword "Image" refers to the file currently being displayed by Geeqie.</para>
\r
87 <section id="Examples">
\r
88 <title>Examples</title>
\r
90 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:
\r
91 <programlisting xml:space="preserve">
\r
92 path=Image:get_path()
\r
93 commentfile=io.popen("exiv2 -p c \"" .. path .. "\"" )
\r
94 comment = commentfile:read("*a")
\r
99 <para>Note that it is necessary to have escape characters surrounding path and filenames.</para>
\r
101 The following example demonstrates how to extract exif data from a file:
\r
102 <programlisting xml:space="preserve">
\r
103 --Retrieve the DateTimeDigitized exif tag
\r
104 exif_structure = Image:get_exif();
\r
105 DateTimeDigitized = exif_structure:get_datum("Exif.Photo.DateTimeDigitized");
\r
106 return (os.date(DateTimeDigitized))
\r
110 <section id="Warning">
\r
111 <title>Warning</title>
\r
113 <para>Lua is a powerful programming language. Errors in script files, besides having undesirable side-effects, may cause Geeqie to crash.</para>
\r