Add Custom Guides

Is it possible to add custom guide lines/guides?

For now, I’m using the watermark module to load custom (svg) guide lines, it works, but the problem with using the watermark module is the overlay is not shown when cropping (maybe this could be an option?), and I have to create ones for every aspect ratio.

Thanks!

This is not currently possible.

One can use lua to write a nice guides for dt, you just have to have dimmensions figured out :slight_smile:

https://darktable-org.github.io/luadocs/lua.api.manual/darktable/darktable.guides/

and example of that is darktable lua documentation - passport_guide

1 Like

ah, ok, I’m thinking of submitting a feature request on github for the watermark module to be shown when cropping if it’s possible (maybe not for the composition guides, but for a case like photographing for a magazine cover where they have a predetermined text layout), but I’m not sure if it’s suitable as it’s more of an overlay rather than watermarks.

ah I see, I’m not familiar with writing Lua, but maybe I can try learn it, is the code/example of built-in guides file/code also accessible in the installation directory?

my custom (composition) guides is basically a combination of grid and diagonal line, I thought it easier for me to learn by the example of the built-in guides because the passport example is using a position relative to a 36x47 rectangle.

I want to ask if anybody could help me creating a grid with LUA script (example script: darktable lua documentation - passport_guide (darktable-org.github.io) )

I don’t have any experience with scripting (maybe just a little HTML/CSS, and reads/edit a little python script).

Is it better if create another topic and mark this one as solved?

This is the guides I want to create


It is a variation/simplification of the Dynamic Symmetry grid, quite similar to Rosarivo grid I often used in publication design. This is my go-to grid because it contains an intersection point of ROT, a center grid, and a diagonal grid, I also added a little Crossmark for the golden ratio intersection references.

Thanks!

I think you may have more success converting your crop guide to an SVG and trying it in the watermark module.

I’ve already written the reason/problem when using the watermark module on the first post…

1 Like

Except for golden ratio crossmark this looks rather easy. I’ll try later today.

1 Like

@adrs On a side note:

Dynamic.Symmetry.zip (12.1 MB)

Maybe these will come in handy, assuming for the moment that you don’t already created these yourself. 50 or so dynamic symmetry based, multi ratios PNGs. The lines are black (easily changed to any colour) and the backgrounds are fully transparent.

I use these at times in Krita. The only thing you need to do is scale them up/down.

This does not solve your current darktable request but it might save you some time and/or include ratios that you do not yet have.

2 Likes

I’ve tried. It was easy :smiley:

here’s the script. If you have script manager place it into say guides dir and have a go:

--[[
  Custom dynamic symmetry guide for darktable

  copyright (c) 2021  Hubert Kowalski
  
  darktable is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  darktable is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with darktable.  If not, see <http://www.gnu.org/licenses/>.
]]

--[[
DYNAMIC SYMMETRY GUIDE
guide based on custom symmetry from Sandy Adriadi
https://discuss.pixls.us/t/add-custom-guides/26288/5?u=johnny-bit

INSTALLATION
* copy this file in $CONFIGDIR/lua/ where CONFIGDIR is your darktable configuration directory
* add the following line in the file $CONFIGDIR/luarc
  require "dynamic_symmetry"


USAGE
* when using the cropping tool, select "dynamic symmetry" as guide
]]

local dt = require "darktable"
local du = require "lib/dtutils"
local gettext = dt.gettext

du.check_min_api_version("2.0.0", "dynamic_symmetry") 

-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("dynamic_symmetry",dt.configuration.config_dir.."/lua/locale/")

local function _(msgid)
  return gettext.dgettext("dynamic_symmetry", msgid)
end

dt.guides.register_guide("dynamic symmetry",
-- draw
function(cairo, x, y, width, height, zoom_scale)
  cairo:save()

  cairo:translate(x, y)
  cairo:scale(width, height)


  cairo:move_to(0,0)
  cairo:line_to(1, 0.5)
  cairo:line_to(0.5, 1)
  cairo:line_to(0,0)
  cairo:line_to(1, 1)
  cairo:line_to(0.5, 0)
  cairo:line_to(0, 0.5)
  cairo:line_to(1, 1)

  cairo:move_to(1, 0)
  cairo:line_to(0, 0.5)
  cairo:line_to(0.5, 1)
  cairo:line_to(1, 0)
  cairo:line_to(0, 1)
  cairo:line_to(0.5, 0)
  cairo:line_to(1, 0.5)
  cairo:line_to(0, 1)

  cairo:move_to(0,0.5)
  cairo:line_to(1,0.5)
  cairo:move_to(0.5,0)
  cairo:line_to(0.5,1)

  cairo:restore()
end,
-- gui
function()
  return dt.new_widget("label"){label = _("dynamic symmetry"), halign = "start"}
end
)
5 Likes

WOW! I really can’t thank you enough for this @johnny-bit ! It perfectly works :grinning:.

Now I have two example scripts for creating a grid and I think it will be easier now for me if I want to create another custom guides (i found and look at the code for built-in guides in the repository, but still not sure which function to call). The golden ratio is not really important, I can guess it visually or by looking at another point, it just a “nice to have” feature.

Thank you once again!

I’ve already created the PNG based image for the aspect ratio i often used, as i used it in another software too, but thank you nevertheless, those included variation will come in handy :pray:t3:

Just a question though, is PNG can be used in dt’s watermarks?

No, but it’s not at all hard to use inkscape to import a png and export to svg. I don’t use these in darktable, but I did try when I made them and that works nicely.

I thought so, at first I tried using png and it didn’t work, thankfully I already have the vector-based guide in the vector editor I’ve used when doing design things.

I checked and it looks like dynamic symmetry guides are based on width/height ratio to be usable. The one I did is actually harmonic armature.

so… actually… if you plan on adding dynamic symmetry the passport guide with it’s ratio is great example of how to do dynamic symmetry guides.

Now that I’ve read the book again, yes you’re right, the correct name for this grid is the harmonic armature. I vaguely remember it that’s why I only write it as “variation/simplification”.

I’m interested in adding the dynamic symmetry, but the reason I’ve to choose this grid as my go-to grid is that it can be used in any aspect ratio. but I’ll try it as I want to learn a bit about LUA for adding custom grids.

If you need help we can help. Please do contribute your guides to GitHub - darktable-org/lua-scripts! If you need help I bet dt devs and @wpferguson especially will be happy to help

3 Likes

I am thinking to add PNG support to watermark module.
On top of custom overlays, the feature can be useful to put on Color palettes from Paletton or similar to use for color grading, without having to convert to SVG with Inkscape.
Stay tuned

3 Likes

I even think there’s active Feature Request (or was it already closed by the bot…) for supporting bitmaps in watermark.

That’s good news, if it’s possible, I’d like to see an option to show the overlay while cropping too (I’ve been hesitant to request it because it’s a “watermark” module, not an “overlay” module).

Will wait for the implementation!

Here is the pull request.
Now there will be a review, but in the meantime you can test it.
when coming to crop, I am afraid this can’t be done with watermark module, which always come to the end of the pipeline

3 Likes