+static FileData *lua_check_image(lua_State *L, int index)
+{
+ FileData **fd;
+ luaL_checktype(L, index, LUA_TUSERDATA);
+ fd = (FileData **)luaL_checkudata(L, index, "Image");
+ if (fd == NULL) luaL_typerror(L, index, "Image");
+ return *fd;
+}
+
+/* Interface for EXIF data */
+static int lua_exif_get_datum(lua_State *L)
+{
+ const gchar *key;
+ gchar *value = NULL;
+ ExifData *exif;
+ FileData *fd;
+
+ fd = lua_check_image(L, 1);
+ key = luaL_checkstring(L, 2);
+ if (key == (gchar*)NULL || key[0] == '\0')
+ {
+ lua_pushnil(L);
+ return 1;
+ }
+ exif = exif_read_fd(fd);
+ if (!exif)
+ {
+ lua_pushnil(L);
+ return 1;
+ }
+ value = exif_get_data_as_text(exif, key);
+ lua_pushstring(L, value);
+ return 1;
+}
+