Solved: Auto import a directory when a file arrives?

darktable
(Kevin Saruwatari) #1

Just wondering if someone can direct me on how to make darktable automatically import a folder.

I am shooting a camera that doesn’t have port for tethering (so no entangle) but I have found that a 4th gen Toshiba flashair works well enough with this script (https://github.com/sleemanj/FlashAirSync) to automatically get the files on my computer. At the moment I am re-importing with mouse clicks.

Is there a way to do this through say a script in a command window (I’m a Linux guy)?

Thanks!

Kev

0 Likes

Transfering Images to Computer Issue
(Mica) #2

Put this in your luarc file to rescan a directory when darktable starts:

dt = import "darktable" 
dt.database.import("path/to your/directory") 
0 Likes

(Kevin Saruwatari) #3

Thank you!

To the end of /opt/darktable/share/darktable/luarc I added:

dt = import "darktable" 
dt.storage.import("<<em>/home/me/Pictures/Flashair/></em>") 

But it doesn’t work. I set the execute attribute on luarc and that didn’t make a difference either.

Did I make a syntax mistake?

P.S. Does this only import at startup? I’m looking to automatically re-import when a new file arrives with darktable already open.

0 Likes

(Colin Paul Adams) #4

Looks like unbalanced < to me

0 Likes

(Kevin Saruwatari) #5

Oops! Searched the <em> tag and I think it was just supposed to be italics!

Changed to:
dt = import “darktable”
dt.storage.import("/home/me/Pictures/Flashair/")

But still doesn’t work. To my eye this looks like it will only import on start up even if it does.

0 Likes

(darix) #6

My Idea for this problem would be the following:

use one of the inotify tools and then hook up dbus or lua with that to DT.

0 Likes

(Kevin Saruwatari) #7

I have used inotify in the past but how would I initiate a re-import from the command line?

0 Likes

(darix) #8

also needs:

maybe I should include that in my RPM.

So kinda a solved problem :))

If you prefer to do it in another language (e.g. one could imagine hooking up something in rapid-photo-downloader), then you find the needed dbus calls in the script.

0 Likes

(Kevin Saruwatari) #9

This is great! When I have a moment I will try this out!

Thank you!

0 Likes

(Bill Ferguson) #10

dt.storage.import should be dt.database.import

1 Like

(Mica) #11

Yes, that is what I meant by “when darktable starts.”

0 Likes

(Kevin Saruwatari) #12

darix thank you so much! I got a chance to test and it works perfectly with copying files in nautilus. I don’t have my camera with me but I will test it and the flashair when I get a moment.

Curiously those Git pages never came up in my Google searches.

0 Likes

(Kevin Saruwatari) #13

I tried it even though this isn’t what I want and dt.database.import doesn’t work for me either. No matter, the scripts darix linked above are exactly what I am looking for.

0 Likes

(Bill Ferguson) #14

I thought of a way to do it with a lua script. You could open up darktable, start a script to poll the directory, then import each new file it detects to the current collection. Kind of a poor mans tether, using the file system instead of a cable.

Bill

0 Likes

(Kevin Saruwatari) #15

Hi Bill;

If you mean read the Flashair directly, it can’t unfortunately. It is only accessible with the http protocol (lot of complaints about no ftp). The Git link in my initial post syncs the card to a directory on my computer and now the Git links from darix should auto load them into darktable.

I still need to test with my camera that it works end to end but the 3 scripts do indeed give a poor mans tether… funny enough the camera I’m tethering is a Leica M-D. It’s DNG files come across in about 5-7 seconds with the 4th gen card. My 3rd gen card was taking about 4.5 minutes. So this is quite workable considering how slow the camera is.

If the scripts were tweaked to only transmit the jpg’s (leave the raws on the card) this will work near instantaneously.

0 Likes

(Bill Ferguson) #16

I meant to read the directory where the Flashair was saving the files to. I was actually thinking of a way to make it cross platform, since I don’t know if dbus/ibus is in MacOS and I’m pretty sure it isn’t in windows. Therefore, I went lower tech and just read the directory every so many seconds and import anything new. I also gave it a start/stop button so that you could turn it on and off. So, if the multiple script solution doesn’t work there may be another alternative.

1 Like

(Kevin Saruwatari) #17

Hi Bill,

When you say “I went lower tech…” and “I also gave it a start/stop button…” this is programming you have already done? If so how do we access it? I’d sure be willing to give it a test. Sounds like it is very nice operationally.

Being greedy, I wasn’t thinking about cross platform or others but it could be a universal tether option for darktable… except that it depends on a proprietary Flashair.

Kev

0 Likes

(Bill Ferguson) #18

This became my afternoon coding challenge. It only took an hour to write, but quite a few more to get it to run correctly all the time (except for the “features” I haven’t found yet).

This uses the lua-scripts library files, so it needs at least the lib directory from the lua-scripts repository. If you have a full lua-scripts installation, then I recommend you add a testing subdirectory and put this in there, then add require “testing/filetether” to your luarc.

The module shows up on the left side below image information. Select the directory you want to monitor, the interval to sleep between checks, and view in darkroom if you want to view the imported file in darkroom, otherwise it just gets imported into lighttable.

There’s a lot of print statements in it, so if you have problems just run darktable with the -d lua switch and it should talk.

Any questions or bugs, let me know.

Thanks,

Bill

P.S. rename the file back to filetether.lua, since I had to add the .txt to get it to upload.

filetether.lua.txt (6.3 KB)

0 Likes

(Kevin Saruwatari) #19

Wow thanks Bill!

A couple of observations and there is one problem. First the problem: it tries to import the file into darktable before the transfer from the Flashair is complete and there seems to be a corruption. I get the dreaded “failed to read white balance” message and even after the transfer is complete the files won’t open in the darkroom. Not sure why this would be. Your program seems to work fine when I copy files across directories on the computer.

The scripts darix linked above open the file after the transfer is complete and there is no error problems with the Flashair.

The observations are your program flips to the lighttable then back to the darkroom. darix’s scripts never leave the darkroom so the screen doesn’t flash about as images come in. I prefer staying in the darkroom as it is less distracting. Theoretically, I should be able to enlarge the thumbs in the lighttable for viewing but my Leica makes the jpg previews in the dng files something hopeless like 480x320, so they don’t work for previewing at all.

On the other hand I like how your program opens the image for editing in the darkroom and I see it full size when it comes in. I noticed that darix’s script opens the image in the lower filmstrip in the darkroom but doesn’t activate it so I only get to see the thumbnail until I double click on it. I’ll double check this tomorrow on my computer I was using this afternoon as I can’t remember if it was activating it full size on that computer.

If there is a way to detect that the file x-fer is complete so we don’t corrupt files and it doesn’t flip back and forth to the lighttable, I would really like your program as it is fully operational within darktable. That said the scripts from darix are pretty useful as they are.

Thanks!

Kev

0 Likes

(Bill Ferguson) #20

I wondered if that would happen. The only way I had to test was just copying files into a directory, which was almost instantaneous. I could detect the file one interval, then import it the next, which would give it a full interval to finish downloading. The the user just has to choose an interval slightly larger than their normal file transfer time.

Currently the darktable lua API doesn’t have a way to change what file is displayed in darkroom. My workaround is to flip back to lighttable, then select the new image, then go back to darkroom. I put a 1 second delay in there, but I could try taking it out. That way it would seem to be more of a flicker than distinct display changes. That may also cause darktable to crash. The final solution will be to extend the API so that I can change images in darkroom.

Thanks for playing with it,

Bill

0 Likes