Automatic tagging: Create custom tags

For certain actions darktable creates auto tags—as described here. Is there a way to create custom automatic tags?

I’d like to create a set of automatic tags for aspect ratio (e.g. darktable|aspect|4:3 or darktable|aspect|3:2) orientation (e.g. darktable|orientation|landscape or darktable|orientation|portrait) and other stuff (colored vs grey scale, etc). Is it possible to hook somewhere in to create that tags automatically?

That should be possible with a Lua script.

Here is a good starting point:

You can find the Lua API documentation here:

And a lot of example scripts here:

If you need help, ask here. :slight_smile:

Not that I’m aware of in a straight forward way, because you need to detect this kind of images properties.

But if you apply styles to images, tags like darktable|style|name of your style are attached to your images.

Is it possible to let scripts run automatically? E.g. if I export an image or use a module (e.g. the crop and rotate module)?

That would be perfect.

Is it possible to let scripts run automatically?

Yes, there are several events:

E.g. if I export an image


or use a module (e.g. the crop and rotate module)?

No, that is not possible. Here we need @houz to add it to darktable.

Two questions:

  • Is types.dt_lua_image_t.get_tags just a link to the get_tags function? I thought it could be called without passing an dt_lua_image_t because that’s done automatically—same for attach/detach_tag.
  • Is the dt_lua_image_t passed by the events.intermediate-export-image event a reference to the original image? It has the same width and height for every export regardless the settings in crop and rotate. I thought, it would have the dimensions after cropping. If there is no way to get that data, there is no way to set the actual aspect ratio accordingly.


local function add_tags(event, image, filename, format, storage)
	-- Won't work (bad argument)
	-- dt_img_tags = image.get_tags()
	dt_img_tags = image.get_tags(image) -- <- seems kind of redundant to me
	-- Prints size of the raw image