Попередження: ця функція дуже експериментальна. Відомо, що кілька елементів ще не працюють у бібліотечному режимі. Настійно рекомендується ретельне тестування.
The lua interface allows you to use Ansel from any lua script. This will load Ansel as a library and provide you with most of the lua API (Ansel is configured headless, so the functions relating to the user interface are not available).
Наприклад, наступна програма надрукує список усіх зображень у вашій бібліотеці:
1#!/usr/bin/env lua
2package = require "package"
3package.cpath=package.cpath..";./lib/Ansel/lib?.so"
4
5dt = require("Ansel")(
6"--library", "./library.db",
7"--datadir", "./share/Ansel",
8"--moduledir", "./lib/Ansel",
9"--configdir", "./configdir",
10"--cachedir","cachedir",
11"--g-fatal-warnings")
12
13require("Ansel.debug")
14
15for k,v in ipairs(dt.database) do
16 print(tostring(v))
17end
Note the third line that points to the location of the libAnsel.so
file.
Also note that the call to require returns a function that can be called only once and allows you to set Ansel’s command line parameter. The :memory:
parameter to --library
is useful here if you don’t want to work on your personal library.