On Thu, May 16, 2019 at 12:35 PM <[email protected]> wrote:

> William Ferguson (2019-May-16, excerpt):
> > Lets try removing the image from the database, then importing it to
> > see if that forces a sidecar load.
>
> Okay, trying this.  How do I delete an image from the database?
> Searching for `delete` yields [1] then [2].  I really find darktable's
> Lua documentation frustratingly sparse.
>

They do the same thing, just 2 different ways to access it.

I use the online manual because I can click through to the data types when
I'm not sure what they are. However, the online manual isn't always up to
date so if you're looking for the newest features then you might have to
generate a manual from source.


> I've ended with this:
>
>     for _, i in pairs(dt.gui.action_images) do
>         [...]
>             if (os.execute(cmd)) then
>                 local path = tostring(i) -- why not a field in `i`?
>
local path = i.path .. "/" .. i.filename

>                 i:delete()
>                 dt.database.import(path)
>             end
>         [...]
>     end
>
> Works.  But there are downsides:
>
>   * It works more often than not, but sometimes the images disappear
>     completely, or are replaced by a skull (although still present the
>     file system, DT insists on "not available").  Cannot reliably
>     reproduce.  Why?
>

I'm not exactly sure why this happens, but I believe it's a timing issue.
I've not tried this specific set of actions, but I've done other display
manipulations and had to wait between operations for the display to catch
up.  You could try adding a dt.control.sleep(250) between the delete and
the import and see if that helps.  That would give you 1/4 of a second wait
between operations. You might have to vary the timing a little bit to see
what works.


>   * All images get a new image ID, and probably as a consequence,
>
>   * the selection of images is lost (meaning: deselected).
>

You could remove the deleted file from the selection and add the imported
one.  The selection is just a table, so you can add and remove image
items.  Then your code could

     for i,img in pairs(dt.gui.action_images) do
        [...]
           if (os.execute(cmd)) then
                local path = img.path .. "/" .. img.filename
                img:delete()
                dt.gui.action_images[i] = dt.database.import(path)
            end
        [...]
    end


> Is there any smart way to reload an XMP file?
>

There isn't a way to load the xmp file from lua.  It would require a change
to the API.


> Cheers
> Stefan
>
> ____________________
> [1] https://www.darktable.org/lua-api/index.html#d0e4845
> [2]
> https://www.darktable.org/lua-api/types_dt_lua_image_t.html#types_dt_lua_image_t_delete
>
>
> --
> http://stefan-klinger.de                                        o/X
> I prefer receiving plain text messages, not exceeding 32kB.     /\/
>                                                                   \
>
> ____________________________________________________________________________
> darktable user mailing list
> to unsubscribe send a mail to
> [email protected]
>
>

____________________________________________________________________________
darktable user mailing list
to unsubscribe send a mail to [email protected]

Reply via email to