contrib/gimp.lua - layers and aligning
Hi @wpferguson (and others)!
I was looking to modify the gimp contrib script. Specifically I wanted to add support for opening images as layers in gimp (thinking multi-page tiff, which gimp imports ok and can be created with tiffcp on linux) and also optionally aligning said layers before sending to gimp (align_image_stack, tiffcp, send layered tiff to gimp). While checking the issue queue, I noticed you mentioned back in 2016 that you had done some work on doing layers in gimp, but I couldn't see code for same, is it in the current tree?
https://github.com/darktable-org/lua-scripts/pull/55#issuecomment-207821733
I wrote the multi layer version last night. It adds a new export, 'Edit as layers in gimp'. I stacked three images and took the sky from one, the land from another and the water from another. It brings the result back as stack.tif.
If you already have something done it would make a better starting point for what I have in mind.
Another thing, and this is completely off-topic, but is there a simple way I am missing to reload lua scripts in darktable while hacking them, or does one have to close and reopen at every change?
Here's gimp_stack.lua. I wrote this before the libraries and when I was still pretty new to lua. I used imagemagick (convert) to build the stack.
You could steal the align_image_stack stuff from contrib/image_stack.lua.
You might want to use gimp.lua to model after, since it's pretty much up to date.
contrib/image_stack.lua has a naming convention for images based on multiple images that you might want to use instead of stack.tif.
I added a directory to my lua-scripts called development. I use script_manager for my luarc file. When I'm developing, and fixing coding errors, each time I try and get it to load and it fails, it doesn't set the button label to disable. So, therefore I can make code changes and click enable until I finally get it to load. The only drawback to this is if you're creating a lot of widgets. After awhile you have a bunch of orphaned widgets and you get garbage collection errors about destroying parented widgets so then you have to restart darktable. Once the script loads, then the only way to get it to reload is stop and start darktable.
Have fun,
Bill
Cheers Bill!
I've hacked it to work on my system (dt 2.6.x, dtlib differences) and added align_image_stack to the pipeline, and made it copy metadata from the source image as well.
My changes are all a bit hacky and I wouldn't champion its inclusion in dt in the current form but regardless, I've added it to my fork of lua-scripts at https://github.com/agittins/lua-scripts/blob/master/contrib/gimp_stack.lua
I do think that this functionality would be great to have out-of-the-box in dt, so it would be great if anyone took on cleaning it up a bit (such as adding UI elements to control align_image_stack, also I think my method of calling gimp is suboptimal etc) then I think it would be a valued addition.
The workflow that I find really works for me here is:
- pull in multiple images in dt
- apply any desired edits first (I just remove base-curve and export the images flat)
- plugin exports them as tiffs, aligns the tiffs, and merges them into a single multi-layered tiff
- plugin opens the image in gimp as layers (all aligned)
- edit in gimp (esp masking layers to control focus / exposure etc)
- save by File|Overwrite to replace the multi-layered tiff with the flattened edit
- (optionally) save as xcf in case later edit revisions are required
- return to darktable, tiff is imported and ratings etc copied over
- apply any desired edits in darktable
I've just edited a bunch of bracketed (for exposure, focus, elements and lighting) exposures using this method and it's been so much smoother and easier than any other method I've tried so far.
Thanks so much Bill for sharing the initial version, I hope it might be useful to others - and I'll try and clean it up a bit if I get time, but would welcome other contributions.
You're welcome
I would suggest that you clean up the script as far as you are able and then create a pull request. If you have questions feel free to ask. If you don't get an answer right away it is because we have jobs and families.