1084 Commits

Author SHA1 Message Date
dca1d1c25b feat: add darktable web API interface with gallery, image detail, and settings screens
- Implemented main entry point for React application in `main.jsx`.
- Created `Gallery` component for displaying images with infinite scroll and pull-to-refresh functionality.
- Developed `ImageDetail` component for showing detailed information and actions for selected images.
- Added `Settings` component for configuring API connection settings.
- Integrated Vite for build and development with PWA support.
- Implemented caching strategies for API responses and image previews using Workbox.
2026-06-10 23:38:06 -04:00
0831ee943c feat(api): enhance image module management and export functionality
- Added read-write access to the darktable SQLite catalog for module parameter edits.
- Implemented new endpoints for exporting images and retrieving full-resolution images.
- Introduced PATCH method for updating module parameters with optional preview.
- Added comprehensive tests for new API functionalities, including module retrieval and error handling.
- Updated CORS headers to support new HTTP methods.
- Created detailed documentation for new API endpoints and module operations.
2026-06-10 19:50:56 -04:00
bd40b4f850 Add darktable REST API implementation
- Introduced a new Lua-based REST API for darktable, allowing external applications to interact with the darktable library.
- Implemented core functionalities including image listing, retrieval, and preview serving.
- Added support for OAuth 2.0 authentication with token generation.
- Created a simple HTTP router to handle API requests.
- Included JSON encoding/decoding utilities for API responses.
- Developed a script to launch the API server alongside darktable, ensuring seamless integration.
- Added necessary configuration and setup for the API server, including CORS support and error handling.
2026-06-10 15:02:19 -04:00
wpferguson
5ebadd83ea Merge pull request #669 from wpferguson/sm_logging
tools/script_manager - changed log msg from debug to info
2026-04-19 16:00:05 -04:00
Bill Ferguson
01c3b7d2f6 tools/script_manager - changed log msg from debug to info 2026-04-19 15:58:35 -04:00
wpferguson
bfee6b12dc Merge pull request #668 from wpferguson/script_manager_fix
tools/script_manager - fixed gui safety test for gui installation
2026-04-19 14:56:04 -04:00
Bill Ferguson
503a59d590 tools/script_manager - fixed gui safety test for gui installation 2026-04-19 14:54:25 -04:00
wpferguson
78176e32e8 Merge pull request #631 from wpferguson/bundled_script_manager
Updated script_manager for bundled scripts

Part of https://github.com/darktable-org/darktable/pull/19899
2026-04-19 14:38:24 -04:00
wpferguson
4d8d076d8e Merge pull request #667 from bkhl/master
Missing argument in group_persistence.lua
2026-04-18 15:29:10 -04:00
Björn Lindström
72f31d6208 Missing argument in group_persistence.lua
`add_to_group` was still failing as the leader was not provided
as second argument.
2026-04-18 20:59:58 +02:00
wpferguson
784a6ea85d Merge pull request #666 from bkhl/group_persistence-function-order
Order functions in dependency order in group_persistance.lua
2026-04-18 14:49:59 -04:00
Björn Lindström
bbfd9d12e3 Order functions in dependency order in group_persistance.lua
The call to `add_to_group` in `build_group` failed as `add_to_group`
was a local function defined later. This reorders the functions to avoid
that.
2026-04-18 20:38:52 +02:00
wpferguson
a55de740e5 Merge pull request #663 from deekayhd/issue_661
fix incomplete removal of datetime_taken in PR #653
2026-04-11 11:11:20 -04:00
deekayhd
dc31b221ef fix username as nil 2026-04-11 14:36:30 +02:00
deekayhd
34b88490c2 fix assignment of empty variables derived from exit_datetime_taken 2026-04-11 14:30:29 +02:00
deekayhd
d9b77bb3a2 fix incomplete removal of datetime_taken in PR #653 2026-04-10 19:56:00 +02:00
wpferguson
cc198d6ca1 Merge pull request #662 from wpferguson/fix_transfer_hierachy
contrib/transfer_hierarchy bug fix
2026-04-09 12:21:31 -04:00
Bill Ferguson
84582cbf29 contrib/transfer_hierarchy - fixed unused variable being used as
boolean function
2026-04-09 12:18:54 -04:00
wpferguson
9e7a18e290 Merge pull request #660 from wpferguson/readd_toggle_group_view
re-add contrib/toggle_group_view
2026-04-06 21:23:41 -04:00
Bill Ferguson
8ff81fcfa4 contrib/toggle_group_view - re-added toggle_group_view after getting
button sensitivity figured out.

This script adds a way to toggle a selected or hovered group to it's
own collection and back again
2026-04-06 21:20:32 -04:00
wpferguson
b649e7a840 Merge pull request #659 from wpferguson/fix_siv_typo
contrib/selected_image_visible - corrected typo
2026-04-05 15:32:32 -04:00
Bill Ferguson
efa06ee34c contrib/selected_image_visible - corrected typo 2026-04-05 15:31:38 -04:00
wpferguson
77959422e0 Merge pull request #658 from wpferguson/remove_toggle_group_view
contrib/toggle_group_view - removed because there are too many problems
2026-04-04 20:10:29 -04:00
Bill Ferguson
0bff346b05 contrib/toggle_group_view - removed because there are too many problems
needing fixed.
2026-04-04 20:08:14 -04:00
wpferguson
d05c494147 Merge pull request #657 from wpferguson/fix_event_destroy
contrib/toggle_group_view - fixed event destroy call
2026-04-04 19:53:27 -04:00
Bill Ferguson
9cbbae9621 contrib/toggle_group_view - fixed event destroy call 2026-04-04 19:52:13 -04:00
wpferguson
fb2aade198 Merge pull request #656 from wpferguson/fix_button_function_call
contrib/selected_image_visible - corrected action button function call
2026-04-04 19:48:07 -04:00
Bill Ferguson
7ffd8bdc27 contrib/selected_image_visible - corrected action button function call 2026-04-04 19:44:53 -04:00
wpferguson
b689dbc7ee Merge pull request #655 from wpferguson/update_toogle_group_view
contrib/toggle_group_view
2026-04-04 17:20:49 -04:00
Bill Ferguson
027135a257 contrib/toggle_group_view - updated to current version from old
version I mistakenly used.
2026-04-04 17:19:23 -04:00
wpferguson
643057deaf Merge pull request #652 from wpferguson/selected_image_visible
contrib/selected_image_visible
2026-04-04 15:56:12 -04:00
Bill Ferguson
a00f71f533 contrib/selected_image_visible - Added action button to make
selected non visible image visible
2026-04-04 15:54:00 -04:00
wpferguson
36d6db24e7 Merge pull request #654 from wpferguson/fix_s2c_destroy
official/selection2collection - fixed 2 bugs with destroy function
2026-04-04 15:23:26 -04:00
Bill Ferguson
f62a5a817f official/selection2collection - fixed 2 bugs with destroy function 2026-04-04 15:21:41 -04:00
wpferguson
44b40b305b Merge pull request #651 from wpferguson/select_raw_non_raw
select_raw_non_raw
2026-04-04 15:01:46 -04:00
wpferguson
97dade06cf Merge pull request #650 from wpferguson/group_persistence
official/group_persistence
2026-04-04 15:01:25 -04:00
wpferguson
30167631e7 Merge pull request #649 from wpferguson/toggle_group_view
toggle_group_view
2026-04-04 15:01:01 -04:00
wpferguson
8235de1f0a Merge pull request #648 from wpferguson/select_unaltered
select_unaltered
2026-04-04 15:00:26 -04:00
wpferguson
d67ada8300 Merge pull request #646 from wpferguson/recent_bookmarks
recent_bookmarks
2026-04-04 15:00:07 -04:00
wpferguson
c6788e4370 Merge pull request #645 from wpferguson/use_paired_jpg_as_mipmap
use_paired_jpg_as_mipmap
2026-04-04 14:59:46 -04:00
wpferguson
d238fcee61 Merge pull request #644 from wpferguson/selection2collection
selection2collection
2026-04-04 14:58:52 -04:00
wpferguson
28d71c989f Merge pull request #643 from wpferguson/extract_burst_roll_images
extract_burst_roll_images
2026-04-04 14:58:16 -04:00
wpferguson
74f020c809 Merge pull request #642 from wpferguson/auto_straighten
auto_straighten
2026-04-04 14:57:43 -04:00
wpferguson
80769a753a Merge pull request #641 from wpferguson/select_duplicates
select duplicates
2026-04-04 14:57:14 -04:00
wpferguson
427359769e Merge pull request #647 from wpferguson/scheduler
scheduler
2026-04-04 14:56:17 -04:00
Bill Ferguson
5e5b073cec official/use_paired_jpg_as_mipmap - fixed typo in namespace table 2026-03-30 21:12:51 -04:00
Bill Ferguson
c771c5fc1b official/use_paired_jpg_as_mipmap - changed isc message to a broadcast
so that any cache building script could catch it and then execute.
2026-03-30 20:51:37 -04:00
Bill Ferguson
7cdf1d4c7f official/use_paired_jpg_as_mipmap - Added more logging and changed
trigger message for cache building scripts
2026-03-30 13:19:41 -04:00
wpferguson
b6ea6211db Merge pull request #653 from deekayhd/no_exif_date_corr
fix wrong month in EXIF.MONTH.LONG and EXIF_MONTH.SHORT when no exif date available in image

Thanks
2026-03-30 13:00:31 -04:00
deekayhd
4d3924939b remove unnecessary variable datetime_taken 2026-03-29 23:45:40 +02:00
deekayhd
80ff1ef0aa add warning message 2026-03-29 23:37:22 +02:00
deekayhd
af362315e8 set all vars derived from datetime_taken to "" 2026-03-29 23:22:04 +02:00
deekayhd
28f3e9f6a2 fix wrong month in EXIF.MONTH.LONG and EXIF_MONTH.SHORT when no date available 2026-03-29 14:29:39 +02:00
Bill Ferguson
4f05672809 contrib/selected_image_visible - add script that creates a shortcut
to make the selected image visible in lighttable.
2026-03-26 23:34:50 -04:00
Bill Ferguson
8d8f295c77 official/select_raw_non_raw - updated help url 2026-03-26 23:17:25 -04:00
Bill Ferguson
a81ab437cf official/select_raw_non_raw - added script that creates two selection
buttons, one to select raw images and the other to select non raw
images
2026-03-26 22:43:14 -04:00
Bill Ferguson
a94a0c2c90 contrib/toggle_group_view - updated help link 2026-03-26 22:41:28 -04:00
Bill Ferguson
0eda1b6ac5 official/group_persistence - add script to store group information in
xmp files so that groups can be maintained across database instances
2026-03-26 22:06:33 -04:00
Bill Ferguson
58bc3a69df contrib/toggle_group_view - moved from official to contrib to handle
event conflict with official/group_persistence.  Moving to contrib forces
toggle_group_view to load before group_persistence and thus get events that
both need, first.  If the order is reversed then toggle_group_view can bog
down in a loop making darktable unresponsive.

Fixed bad call in destroy and added check for selection-changed to make sure
there are images before trying to set sensitivity.
2026-03-26 13:57:04 -04:00
Bill Ferguson
35398c55e5 official/toggle_group_view - fix no images selected so can't get a count of nil 2026-03-25 13:07:03 -04:00
Bill Ferguson
1762b372b1 official/toggle_group_view - made button sensitive to group members
selected
2026-03-25 12:33:21 -04:00
Bill Ferguson
1907f9a1f5 official/toggle_group_view - added a script to view a group as
a collection when toggled from lighttable
2026-03-24 22:57:45 -04:00
Bill Ferguson
b1dd3eca5a official/select_unaltered - add select button to select images that
haven't been altered in any way
2026-03-24 22:18:46 -04:00
Bill Ferguson
732d2788ca official/scheduler - script to provide a FIFO scheduler for cooperative
Lua multitasking.
2026-03-24 21:38:20 -04:00
Bill Ferguson
04908e3f0b official/recent_bookmarks - Update the recently-used.xbel file showing
recently used files for images edited in or exported from darktable.

Current this only works on Linux
2026-03-24 21:01:20 -04:00
Bill Ferguson
3ba3facad2 official/use_paired_jpg_as_mipmap - Canon R series cameras don't
included a full size embedded jpeg so generating mipmap cache for
anything larger than mipmap 3 requires the raw to be loaded and
processed.  This script copies the paired jpeg from the RAW+JPEG
pair to the full resolution mipmap.  This can then be used to generate
the remaining mipmap cache.  The jpeg image can be discarded after
being copied to the cache or retained based on a preference in Lua
options.
2026-03-24 20:45:44 -04:00
Bill Ferguson
cb209d1d56 official/selection2collection - create a temporary collection from
a selection.  Temporary collections are removed when darktable exits.
Temporary collections can be kept by setting a preference in the Lua options.
2026-03-24 20:29:35 -04:00
Bill Ferguson
36533b1004 official/extract_burst_roll_images - script to extract Canon burst
roll images from a burst roll image container
2026-03-24 20:07:48 -04:00
Bill Ferguson
cbbf0f413f official/auto_straighten - add script to straighten image based on
roll and pitch metadata
2026-03-24 19:56:13 -04:00
Bill Ferguson
181aea5bc2 official/select_duplicates - Added script to detect and select duplicates.
Script adds a button to the select images module.
2026-03-24 17:10:08 -04:00
wpferguson
94c6dff245 Merge pull request #636 from deekayhd/rename_images_reset
enable reset in rename_images.lua
2026-03-21 10:48:09 -04:00
Bill Ferguson
79ac6fc31e tools/script_manager - added check for darktable_gui_safe to avoid
startup race condition hang
2026-03-20 16:08:20 -04:00
deekayhd
7a61d77c27 add reset of preference 2026-03-19 11:39:36 +01:00
deekayhd
2635e261a0 changes after review 2026-03-19 11:38:45 +01:00
wpferguson
d197851478 Merge pull request #637 from wpferguson/image_time_filename_sanitize
contrib/image_time - sanitize filenames so that spaces don't cause problems
2026-03-18 10:50:28 -04:00
Bill Ferguson
6f519b3ce8 contrib/image_time - sanitize filenames so that spaces don't cause
problems
2026-03-18 10:46:12 -04:00
deekayhd
03eb79e83a enable reset in rename_images.lua 2026-03-13 21:55:14 +01:00
wpferguson
fb03b49a93 Merge pull request #633 from lefth/photils-cli-path
Fix the path to photils-cli on mac

Thanks
2026-02-15 13:17:46 -05:00
Dan Zwell
c0865c37bb Fix the path to photils-cli on mac 2026-02-15 17:15:32 +08:00
Bill Ferguson
6bbb619513 tools/script_manager - Changed to allow running scripts included
with the darktable distribution.  User installed
                       scripts will override the bundled scripts
2026-02-02 19:29:37 -05:00
wpferguson
182a2c96c3 Merge pull request #630 from wpferguson/select_non_existing_speedup
Speed up select_non_existing
2026-01-28 21:22:46 -05:00
Bill Ferguson
06522802d8 contrib/select_non_existing - changed the logic to get a list of
files in the filmroll and check the
                              "known" files against the file list.
                              This cuts the number of system calls
                              from 1 per image to 1 per film roll
                              resulting an incredible speed up on
                              windows and a good speedup on other
                              platforms.
2026-01-28 21:14:39 -05:00
wpferguson
ad263fed11 Merge pull request #626 from ipalopezhentsev/patch-1
reorder lines
2026-01-04 14:17:42 -05:00
Ilya Palopezhentsev
ced60016fb reorder lines
oops, committed line before the line it should go after
2026-01-04 20:12:35 +01:00
wpferguson
1d6d0695fe Merge pull request #625 from ipalopezhentsev/patch-2
Fix enfuseAdvanced command line building bugs
2026-01-04 13:27:22 -05:00
wpferguson
fbe504b47a Merge pull request #624 from ipalopezhentsev/patch-1
fix dtutils_system.external_command ignoring bad return code on Windows
2026-01-04 13:26:52 -05:00
Ilya Palopezhentsev
7da38b3665 Fix enfuseAdvanced command line building bugs
1) enfuse has argument --contrast-min-curvature taking string with a percent sign. When that runs on Windows, it fails due to the fact that % means env var substitution in Windows command lines. we have to escape it with double percent
2) when enfuse produces a jpg, it takes argument --compression with an integer value. But the script takes it from GUI and passes as a float which breaks enfuse. 
3) When errors like these happen, the script forgets to stop darktable job leaving dangling string in UI.
2026-01-04 12:17:35 +01:00
Ilya Palopezhentsev
08fe1ba410 fix dtutils_system.external_command ignoring bad return code on Windows
On Windows, external_command calls windows_command which prepares a bat file with the command, surrounded with code page saving/restoration. If the "real" command fails, its error return code does not get anywhere and 0 is always returned, because the last line is a chcp call which always succeeds.
This breaks error logic in scripts, e.g. enfuseAdvanced, where they think everything went fine when it didn't.
2026-01-04 10:20:03 +01:00
wpferguson
088c79e140 Merge pull request #622 from dterrahe/patch-1
Update author name in x-touch.lua metadata
2026-01-01 11:47:19 -05:00
dterrahe
f06eebe316 Update author name in x-touch.lua metadata 2025-12-26 11:29:35 +01:00
wpferguson
d6a1cec9fa Merge pull request #620 from wpferguson/revert_ext_editors_sanitize
reverted export2collection sanitize for new file name
2025-12-20 19:53:12 -05:00
Bill Ferguson
e194ad2bc7 reverted export2collection sanitizing new file name as it causes a
problem on windows.
2025-12-20 19:50:24 -05:00
wpferguson
22e3c59d69 Merge pull request #611 from scorpi11/website_gallery
Website gallery replacement
2025-12-18 12:18:44 -05:00
Tino Mettler
eb743e4b3b Make some further strings transtlatable 2025-12-18 18:11:04 +01:00
Tino Mettler
7a8f3afc40 Portability: use system specific path separator, sanitize filenames 2025-12-18 17:23:00 +01:00
Tino Mettler
2b3910c698 CSS style cleanup 2025-12-18 08:19:14 +01:00
Tino Mettler
c584ee05c9 Remove unused JavaScript code and outdated comments 2025-12-18 08:02:43 +01:00
Tino Mettler
bb3a74feac CSS cleanup, separate functional and visual CSS code
Added file style.css which is aimed to contain CSS code that affects
the look of the gallery.

This could be extended to provide different or user-modified styles
to give each gallery an individual look.
2025-12-18 07:55:53 +01:00
wpferguson
90d2764a5a Merge pull request #604 from MStraeten/patch-3
Refactor x-touch script, basic AgX support
2025-12-10 20:39:29 -05:00
Tino Mettler
b0373f7166 Use subdirectories in the generated gallery
JavaScript files are now in js/, CSS files in css/, thumbnail images in
thumbnails/.
2025-12-10 08:46:24 +01:00
Tino Mettler
c6002e7eb7 Make UI text elements translatable 2025-12-10 08:46:11 +01:00
Tino Mettler
a47de82afd Show progress during thumbnail export 2025-12-08 14:53:58 +01:00
wpferguson
7f09e55525 Merge pull request #616 from wpferguson/fix_multi_os
examples/multi_os - replaced ufraw-batch with exiftool
2025-12-07 14:18:29 -05:00
wpferguson
f83ac1366a Merge pull request #617 from wpferguson/ext_editor_sanitize
ext_editor sanitize file name
2025-12-07 14:18:11 -05:00
Bill Ferguson
6cda27172e contrib/ext_editor - sanitize filename before importing to collection 2025-12-06 19:11:12 -05:00
Bill Ferguson
df78522a79 examples/multi_os - replaced ufraw-batch with exiftool to extract
the embedded jpeg or preview image.
2025-12-06 18:40:37 -05:00
wpferguson
6e64d6db6f Merge pull request #613 from wpferguson/string_lib_fixes
String lib fixes
2025-12-04 15:13:56 -05:00
Tino Mettler
7f00cb8d6c Update TODO list for the website gallery export 2025-12-04 19:09:22 +01:00
Tino Mettler
dfeff73fcd Add callback to check if export format is supported
Currently JPG, TIFF, PNG and WebP are supported.
2025-12-04 19:06:26 +01:00
Bill Ferguson
d75f00daa0 lib/dtutils/string - fixed ROLL.NAME to support the original and
the ROLL.NAME[n] variant in the same variable
                     string
2025-12-03 20:54:47 -05:00
Bill Ferguson
3e430ee2be lib/dtutils/string - converted element from string to number for use in test 2025-12-03 18:26:13 -05:00
Bill Ferguson
3856ae3449 lib/dtutils/string - added format_exposure function to take an
exif_exposure and return it as an exposure
                     string (exif_exposure = 500, string 1/500)
2025-12-02 20:40:03 -05:00
Bill Ferguson
d54a9f8b7e lib/dtutils/string - implemented variable substitution for ROLL.NAME[n] 2025-12-02 19:54:10 -05:00
Bill Ferguson
8f6cc850fb lib/dtutils/string - Added Xmp.darktable.version and Xmp.dc.[title,
description,publisher,rights,creator]
2025-12-02 18:57:05 -05:00
Bill Ferguson
e9f18a3d36 lib/dtutils/string - add IMAGE.ID and IMAGE.ID.NEXT variables 2025-12-02 18:34:18 -05:00
wpferguson
f3a89a89bd Merge pull request #612 from wpferguson/fix_apply_camera_style
official/apply_camera_style - fixed pattern matching bugs
2025-12-02 16:30:56 -05:00
Bill Ferguson
d075fb7128 official/apply_camera_style - fixed pattern matching bug that allowed
camera styles to be applied twice

                              fixed pattern matching bug affecting
                              Canon EOS R, RP, and R5

                              Added more debugging statements to
                              pattern matching functions
2025-12-02 16:23:28 -05:00
Tino Mettler
7f4bae4234 Update TODO 2025-11-26 22:31:10 +01:00
Tino Mettler
071a3527c1 Add new website gallery module to README.md 2025-11-26 21:32:19 +01:00
Tino Mettler
22c9a7cd6e Comments, remove cruft 2025-11-26 21:32:10 +01:00
Tino Mettler
12ccefcc3b Add missing copyright/license information 2025-11-26 21:31:41 +01:00
Tino Mettler
fa6014fefa Export module for a website gallery with selected images
This export module should replace the PhotoSwipe copy in darktable.

See https://github.com/darktable-org/darktable/issues/16205 for more
details.
2025-11-26 20:46:11 +01:00
wpferguson
e831f377bf Merge pull request #610 from wpferguson/fix_selection_to_pdf_open
official/selection_to_pdf
2025-11-23 21:09:02 -05:00
Bill Ferguson
d696e6e3f2 official/selection_to_pdf - added default opens for Linux, MacOS,
and Windows
2025-11-23 21:04:54 -05:00
wpferguson
db505f1e0a Merge pull request #608 from wpferguson/fix_metadata_string_substitution
lib/dtutils/string - image metadata may return a nil so check to
2025-11-14 20:04:29 -05:00
Bill Ferguson
57d15a3fa6 lib/dtutils/string - image metadata may return a nil so check to
see if there is a value and return it otherwise
                     return an empty string
2025-11-11 21:59:07 -05:00
Martin Straeten
3c131c41d1 adaption to recent agx update
renamed action and reordered sliders
2025-11-11 22:00:25 +01:00
wpferguson
4d54b5eaba Merge pull request #606 from wpferguson/add_official_regenerate_thumbnails
official/regenerate_thumbnails - add a script to fix skull thumbnails
2025-11-09 22:56:05 -05:00
Martin Straeten
ffa125b134 further improved customizability
to add a new module, simply add an entry to MODULE_PROFILES below.
direct usage of action paths from darktable's shortcut interface.
2025-11-09 20:15:34 +01:00
Bill Ferguson
dbf0c5d853 official/regenerate_thumbnails - added check to ensure job has not
been canceled.
2025-11-09 00:13:48 -05:00
Bill Ferguson
193a615772 official/regenerate_thumbnails - add a script to fix skull thumbnails
by dropping the cache for the image
                                 and regenerating it.  Adds a button
                                 to the actions on selected images
                                 module.  Also has a shortcut to
                                 apply the script by hovering and
                                 triggering the shortcut.
2025-11-08 21:27:14 -05:00
Martin Straeten
056f616283 Refactor x-touch script, basic AgX support
Refactored x-touch script to improve structure and maintainability. Mainly by adding helper functions for handling different module types.
the added support for AgX module
(credit goes to claude.ai which helped a lot )
2025-11-06 19:19:46 +01:00
wpferguson
447980ddc4 Merge pull request #603 from wpferguson/fix_stringlib_sequence_arguments
Fix sequence string substitution variable to accept starting number > 9
2025-11-02 17:05:22 -05:00
Bill Ferguson
8af5476f8d lib/dtutils/string - fixed string substitution sequence to accept
start argument of more than 1 digit
2025-11-02 16:59:32 -05:00
wpferguson
c95547caa7 Merge pull request #584 from balping/patch-1
Add manual coordinate input option to geoToolbox
2025-08-18 17:01:22 -04:00
wpferguson
b4d3b2901f Merge pull request #585 from mreiger/master
Add a script to automatically tag manually modified images
2025-08-18 16:57:00 -04:00
wpferguson
cb6b3161d8 Merge pull request #595 from sjjh/patch-1
Update README.md: added link to script_manager docs
2025-08-18 16:55:27 -04:00
wpferguson
2d82eea237 Merge pull request #594 from deekayhd/master
rename_images: error when renaming images without exif data
2025-08-18 16:53:28 -04:00
Michael Reiger
3beee93af4 Merge branch 'darktable-org:master' into master 2025-08-01 07:36:10 +00:00
sjjh
68291414f3 Update README.md: added link to script_manager docs
just for convenience: added a link to dt documenation for script manager module in the 'enable' section
2025-07-13 16:56:22 +02:00
deekayhd
5662519314 Merge pull request #1 from deekayhd/no_exif_data
rename_images: error with images without exif data
2025-07-09 21:15:42 +02:00
deekayhd
28ab065293 Merge branch 'darktable-org:master' into no_exif_data 2025-07-09 20:52:02 +02:00
wpferguson
aed3275943 Merge pull request #593 from wpferguson/592_fix_RL_out_sharp
fix RL_out_sharp crash
2025-07-05 12:43:12 -04:00
Bill Ferguson
d7aeb43340 contrib/RL_out_sharp - changed MODULE to MODULE_NAME so that message
would print and script wouldn't crash
2025-07-05 12:39:36 -04:00
deekayhd
ea79d10b11 Update string.lua
initialize datetime_taken with proper value if no exif_datetime_taken can be found (e.g. in TIFF files)
2025-07-01 13:55:47 +02:00
Michael Reiger
e4001f984f Merge branch 'darktable-org:master' into master 2025-06-26 22:13:59 +00:00
wpferguson
453d744b69 Merge pull request #588 from wpferguson/18366_fix_apply_style_camera_decoding
fix apply_camera_style style decoding
2025-06-01 17:07:36 -04:00
Bill Ferguson
b9cc0dccce official/apply_camera_style - made spaces in camera name conditional
matches as some are squashed and others
                              (Olympus) are not.
2025-06-01 16:36:52 -04:00
Michael Reiger
84fea20ee5 fixed script desription 2025-06-01 13:28:44 +02:00
Michael Reiger
e054bfc59d Added script to automatically tag manually modified images 2025-06-01 13:12:56 +02:00
Michael Reiger
8cd10dce68 Revert "Modified apply_camera_style script so that the application of a camera style does not mark the image as changed" because that attempt did not work.
This reverts commit f8d49ccd01.
2025-06-01 12:50:59 +02:00
Michael Reiger
f8d49ccd01 Modified apply_camera_style script so that the application of a camera style does not mark the image as changed 2025-05-24 19:31:23 +02:00
Balázs Dura-Kovács
25afb41924 Create tooltips for geoToolbox 2025-05-06 19:37:09 +02:00
Balázs Dura-Kovács
3001a0dc1a Add manual coordinate input option to geoToolbox 2025-05-04 23:23:33 +02:00
wpferguson
62e932990e Merge pull request #583 from wpferguson/fix_image_time_issue_582
Fix image time exiftime generation with blank fields
2025-05-01 20:40:48 -04:00
Bill Ferguson
980fe3962c image_time - added default values of 0 for fields not supplied in
set time so that an exiftime can be created.\
2025-05-01 20:37:24 -04:00
wpferguson
0043769946 Merge pull request #579 from tabac/rename-images-sequence-tooltip
Align sequence tooltip with code.
2025-04-10 20:40:31 -04:00
Tasos Bakogiannis
0cb9a8872e Update sequence variable order. 2025-04-10 19:26:45 +02:00
Tasos Bakogiannis
5309ff1726 Revert "Align sequence tooltip with code."
This reverts commit c6eee15d75.
2025-04-10 19:25:01 +02:00
Tasos Bakogiannis
c6eee15d75 Align sequence tooltip with code. 2025-04-09 23:48:48 +02:00
wpferguson
8c2d0ddf2e Merge pull request #577 from kmilos/patch-1
Fix de_DE translation charset
2025-04-02 22:24:42 -04:00
Miloš Komarčević
87d18549a6 Fix de_DE translation charset 2025-04-01 16:11:56 +02:00
wpferguson
6fdd78114f Merge pull request #576 from fjb2020/master
Fix issue #571, use of for _,image in ipairs(sel_images) do conflicts with function _(msgid)
2025-03-19 14:52:19 -04:00
fjb2020
f20721373a Fix issue #571, use of for _,image in ipairs(sel_images) do conflicts with function _(msgid) 2025-03-19 15:57:10 +00:00
wpferguson
9c0f8d63e6 Merge pull request #575 from Yurivanderburg/fix_typo_in_hugin
Fixed typo in hugin script - should resolve issue # 570

Thanks
2025-03-18 17:24:58 -04:00
Yuri van der Burg
ea2596ae13 Fixed typo in hugin script - should resolve issue # 570 2025-03-18 20:38:21 +01:00
wpferguson
a9191cf084 Merge pull request #568 from wpferguson/fix_script_manager_startup_button_states
Fix script_manager startup power button state
2025-03-08 15:52:26 -05:00
Bill Ferguson
59b5039579 tools/script_manager - Moved start_scripts() later in the script to ensure
the UI is populated before starting the scripts.  Added
                       a check to see if the script is started and if so the
                       power button is updated to show the script is running.
2025-03-08 15:46:55 -05:00
wpferguson
e070a1462c Merge pull request #553 from MStraeten/patch-2
Update x-touch.lua switch colorequal tab
2025-03-01 20:02:54 -05:00
wpferguson
faa3302a37 Merge pull request #566 from sercxanto/fix_dbmaint_log
Fix dbmaint.lua
2025-03-01 14:03:57 -05:00
wpferguson
115dbbec32 Merge pull request #563 from sercxanto/fix_version_comparison
Fix version comparison
2025-03-01 14:00:32 -05:00
Georg Lutz
9bf7efe71f Fix dbmaint.lua
"log.log_msg" triggers a lua function error, because that function does not exist.

Additionally add add set_log_level / restore_log_level to improve compatibility with other files.
2025-03-01 08:46:00 +01:00
wpferguson
3ec9dc4963 Merge pull request #565 from wpferguson/fix_autostyle_pattern_match
fix autostyle pattern match
2025-02-28 15:14:13 -05:00
Bill Ferguson
cddb86ded0 contrib/autostyle - fixed pattern match for tag result to handle spaces in the pattern 2025-02-28 15:11:15 -05:00
Georg Lutz
2624338100 Rename compare_versions to compare_api_versions 2025-02-23 18:29:34 +01:00
Georg Lutz
067fe29f76 Fix version comparison
Currently this is a textual string comparison which will break with 10.0.0 API version.
2025-02-23 12:23:37 +01:00
wpferguson
926272b1cd Merge pull request #560 from wpferguson/script_manager_delayed_start
script_manager - delay script start until all libraries are scanned
2025-02-15 20:28:26 -05:00
Bill Ferguson
363524fbaf tools/script_manager - added a start queue for scripts that start at
start up to allow for including and using libraries
                       in other than the default path.  Scripts are now
                       started after all directories are scanned instead of
                       being started as they were found.
2025-02-15 20:19:29 -05:00
wpferguson
edeceb268e Merge pull request #558 from wpferguson/fix_acs_pattern_match
Fix apply_camera_style pattern matching
2025-02-15 13:59:49 -05:00
Bill Ferguson
252cbc96f2 apply_camera_style - made spaces conditional in the pattern match
so that pattern names with spaces will match
                     models that don't have spaces
2025-02-15 13:55:08 -05:00
Bill Ferguson
b70fdc0ecf official/apply_camera_style - Fixed decoding errors caused by #18332. 2025-02-07 14:29:45 -05:00
Martin Straeten
96457bc598 Update x-touch.lua switch colorequal tab
added recommended additional shortcuts to switch between hue, saturation and brightness tabs:
midi:D0=iop/colorequal/page;previous
midi:D#0=iop/colorequal/page;next
2025-01-18 23:44:48 +01:00
wpferguson
cd31d18075 Merge pull request #552 from wpferguson/fix_windows_command_escaping
lib/dtutils/system.lua escaping fix
2025-01-17 14:22:07 -05:00
Bill Ferguson
4e140f10d1 lib/dtutils/system - fixed Lua escaping in windows_command() 2025-01-17 14:18:19 -05:00
wpferguson
593f8049a0 Merge pull request #550 from wpferguson/fix_autogrouper_use_of_group_leader
Fix AutoGrouper group mechanics
2025-01-07 13:43:13 -05:00
wpferguson
89973b3f9a Merge pull request #549 from Naahuel/master
Add change encoding to bat file for dtutils/system.lua windows_command

Thanks.
2025-01-07 13:42:54 -05:00
wpferguson
deca366ce4 Merge pull request #502 from koto/ultrahdr
Added UltraHDR export plugin to generate UltraHDR JPEG images.

Thanks
2025-01-07 13:36:22 -05:00
Bill Ferguson
914a17fb4e contrib/AutoGrouper - create group leader for first image in table.
Add grouped images to the group leader and not
                      the previous image.
2025-01-06 22:06:35 -05:00
Nahuel José
1e33ea4192 fix: add change encoding to bat file for dtutils windows_command 2025-01-06 18:47:57 -03:00
Krzysztof Kotowicz
9f3fb16161 Addressed review comments. 2025-01-04 00:49:56 +01:00
wpferguson
3f064783b7 Merge pull request #544 from MStraeten/patch-2
Enhanced x-touch.lua for colorequalizer
2025-01-02 15:45:34 -05:00
Krzysztof Kotowicz
0ab4b0cd6d Added 50ms sleep to the colorspace change.
The old profile still seems to be used occasionally without the sleep.
2025-01-02 15:21:59 +01:00
wpferguson
e2f5c993b8 Merge pull request #547 from darktable-org/update_links
README.md - updated links to current documentation
2025-01-01 17:36:24 -05:00
Bill Ferguson
3def8b43d9 README.md - fixed git clone links 2025-01-01 17:33:20 -05:00
Bill Ferguson
7b2942ca29 README.md fixed darktable-org to darktable.org 2025-01-01 17:28:03 -05:00
Bill Ferguson
bfed38f1db README.md - updated links to current documentation 2025-01-01 17:24:30 -05:00
Krzysztof Kotowicz
6d16a8778b Removed .DS_Store 2024-12-22 08:39:38 +01:00
Krzysztof Kotowicz
3c67c0c693 Create output directory if it doesn't exist. 2024-12-21 10:20:02 +01:00
Martin Straeten
1ba488d073 Enhanced x-touch.lua for colorequalizer
just adapted the colorzone stuff for color equalizer.
requires explicitly set the focus via a further switch
2024-12-15 19:08:24 +01:00
Krzysztof Kotowicz
3bdbfd12bf Apply write_image workaround only in 9.3.0 2024-12-05 00:45:34 +01:00
Krzysztof Kotowicz
77c405882d Added logging code and a workaround for https://github.com/darktable-org/darktable/issues/17528 in 9.4.0. 2024-12-03 19:49:57 +01:00
Krzysztof Kotowicz
ecc3fb29f5 Merge branch 'darktable-org:master' into ultrahdr 2024-12-03 07:20:51 +01:00
Krzysztof Kotowicz
a09140c03c Variable substitution in output directory. Force exporting files, but left the code to reconfigure it. Added more robust way to set export profile. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
95e2e4924e Added HDR only encoding variant.
- Increase timeouts to improve stability of choosing export profiles.
- Added peak nits setting.
2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
72ce0b0f93 Small fixes 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
e4da226661 Added gainmap downsampling. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
a3404b64de Renamed gainmap to "gain map" in UI. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
13ae486ab3 Verify raw file size in pixels.
Added option to keep temporary files around for analysis.
2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
268aa7df42 Removed darktable capitalization. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
ea7ac8e474 Abort and cleanup early when any of the binaries fail. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
2a4452cd20 Workaround https://github.com/darktable-org/darktable/pull/17529 for future DT versions. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
749db97dd5 Speed up export in HDR+SDR. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
84a1c1ddfe Use single channel gainmaps in SDR+HDR. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
3791b47914 Use lowercase labels to adjust to DT style. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
f6a1d1c20b Made the UltraHDR generation more robust.
- Appropriate color profiles are used when generating UltraHDR files. DT_COLORSPACE_DISPLAY_P3 is used for SDR, and DT_COLORSPACE_PQ_P3 is used for HDR, regardless of what was selected in the export module UI.
- Added correction for odd image dimensions in SDR + HDR mode.
- Added quality setting for JPEG compression
- SDR + HDR option can source from any DT image (JPEG-XL is generated on the fly).
- generation can abort on errors and display error messages.
2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
118bbad5cb Exposed sliders for crucial settings in a metadata file, removed file picker for metadata.cfg.
Temporary metadata file will be created during UltraHDR generation, using the values from the UI.
2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
44e442e7eb Support grouping images into stacks by different criteria (or forcing the selection to be interpreted as a single UltraHDR stack). 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
08726427aa Don't re-export JPEG files if their images are not altered. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
39f63cc8c5 Fallback to reading image's width/height, as sometimes final_width/height is 0. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
99c3548950 Copy only EXIF tags to UltraHDR. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
7e8340c526 Don't overwrite existing stack slots (that way the first matching image in a stack will be used, vs the last one). 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
2e95c4837b Added option to generate metadata file.
Fixed pref load / saving code defaults.
Metadata file is required in ENCODING_VARIANT_SDR_AUTO_GAINMAP mode.
2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
fe6d262d9b Display all error messages when checking configuration.
Changed config defaults to require less user input (use_original_directory=TRUE, import_to_darktable=TRUE).
Account for nil values when checking for file existence.
2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
794b12305c Fixed tooltip language. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
1a3a7f17ff Added SDR + auto gainmap generation encoding variant. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
496f8e704d Fixed doc. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
28f87566e1 Added better messaging. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
865d29fb40 Changed the UltraHDR JPEG quality to 95. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
1986f4e148 Major overhaul of the plugin. Added SDR + HDR (JPEG-XL) support. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
b963eaa38c Added encoding variant as an explicit UI setting (though only API-4 is supported now). 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
3b520d6291 Added UltraHDR export plugin to generate UltraHDR JPEG images. 2024-12-03 07:06:26 +01:00
Krzysztof Kotowicz
87ca8bde27 Fixed $(VERSION.IF_MULTI)
Variable substitution actually errored out when duplicates were present.
2024-12-02 23:45:12 +01:00
Krzysztof Kotowicz
d27df0c0ed Fixed $ROLL.NAME substitution
Accd to 57d3ad4bd3/src/common/variables.c (L660) it should be a basename of the file path.
2024-12-02 23:45:12 +01:00
Krzysztof Kotowicz
9bceb79a15 Fixed $(FILE.NAME) variable substitution
According to comments and https://docs.darktable.org/usermanual/4.6/en/special-topics/variables/ it should be a basename.
2024-12-02 23:45:12 +01:00
Bill Ferguson
ed9f2bb0d0 official/apply_camera_sytle - ensure style is only applied to raw
images.  Fixed comment.
2024-12-02 23:45:12 +01:00
Bill Ferguson
b5c93e55d1 lib/dtutils - added a gen_uuid() function to generate a UUID string
for use as a unique identifier.
2024-12-02 23:45:12 +01:00
Bill Ferguson
9bfda93b51 official/apply_camera_style - make the translatable strings
contrib/hif_group_leader      translation safe
contrib/jpg_group_leader
2024-12-02 23:45:12 +01:00
wpferguson
daa0877b4c Merge pull request #541 from koto/patch-1
Fixed variable substitutions
2024-12-02 11:22:02 -05:00
Krzysztof Kotowicz
da275c2a66 Fixed $(VERSION.IF_MULTI)
Variable substitution actually errored out when duplicates were present.
2024-12-02 10:11:23 +01:00
Krzysztof Kotowicz
3fa913d68a Fixed $ROLL.NAME substitution
Accd to 57d3ad4bd3/src/common/variables.c (L660) it should be a basename of the file path.
2024-12-02 09:56:45 +01:00
Krzysztof Kotowicz
e4e194b0ec Fixed $(FILE.NAME) variable substitution
According to comments and https://docs.darktable.org/usermanual/4.6/en/special-topics/variables/ it should be a basename.
2024-12-02 09:01:48 +01:00
wpferguson
c70ebf4297 Merge pull request #540 from wpferguson/fix_17914_apply_camera_style_to_raw
Ensure apply_camera_style is only applied to raw images
2024-12-01 12:50:23 -05:00
Bill Ferguson
7e3c6471ff official/apply_camera_sytle - ensure style is only applied to raw
images.  Fixed comment.
2024-12-01 12:27:16 -05:00
wpferguson
a39f6feba7 Merge pull request #536 from wpferguson/add_gen_uuid_to_dtutils_library
Add gen_uuid() function to dtutils library
2024-11-13 23:18:11 -05:00
wpferguson
ee7e92019a Merge pull request #537 from darktable-org/fix_collection_selection_strings_for_translation
Make strings translation safe
2024-11-13 23:17:51 -05:00
Bill Ferguson
96b7ba24bc official/apply_camera_style - make the translatable strings
contrib/hif_group_leader      translation safe
contrib/jpg_group_leader
2024-11-13 23:09:14 -05:00
Bill Ferguson
8581af29d2 lib/dtutils - added a gen_uuid() function to generate a UUID string
for use as a unique identifier.
2024-11-13 19:05:16 -05:00
wpferguson
ab532a724c Merge pull request #535 from Electro707/fix_file_path_sanitazation
Sanitization for file.mkdir and file.rmdir

Thanks
2024-11-03 13:25:13 -05:00
Electro707
b1e6bb8daa Added sanitization around path for mkdir and rmdir 2024-11-02 21:29:53 -04:00
wpferguson
26e797d5e5 Merge pull request #534 from wpferguson/autostyle_17731_EXIF_msg_fix
Fix contrib/autostyle confusing error message
2024-10-29 13:16:49 -04:00
wpferguson
3941c7ab52 Merge pull request #530 from wpferguson/fix_should_be_sanitized
fix string lib _should_be_sanitized
2024-10-29 13:16:35 -04:00
wpferguson
b7c8759af3 Merge pull request #523 from koto/sanitize_filename
Properly sanitize filenames in dtutils.file file_copy and file_move.

Thanks
2024-10-29 13:16:09 -04:00
Bill Ferguson
c5711880d3 contrib/autostyle - added check to make sure autostyle has been
configured so that it doesn't print out
                    a confusing error message.

                    Fixed preference to use translated script name,
                    (script_data.metadata.name).
2024-10-29 12:23:25 -04:00
Bill Ferguson
e7dbd6e369 lib/dtutils/string - fixed constant names to correctly define the
patterns as the unsafe filename characters.
2024-10-28 20:41:02 -04:00
Bill Ferguson
1b5cb1ae6e lib/dtutils/string - corrected constrant names in assignment 2024-10-28 20:18:22 -04:00
wpferguson
2953cf7e91 Merge pull request #533 from wpferguson/fix_rename_images
fix contrib/rename_images crash
2024-10-28 15:53:21 -04:00
Bill Ferguson
5e4ba9da5e contrib/rename_images - fixed call to sting library for building
the string substitution list
2024-10-28 15:49:32 -04:00
wpferguson
3a1f6bbc7a Merge pull request #531 from wpferguson/fix_17699_lua_translation
Lua Translation remaining tasks
2024-10-27 16:17:42 -04:00
Bill Ferguson
21ec2883fe Added translation to module name 2024-10-23 11:42:41 -04:00
Bill Ferguson
a0af01884d official/enfuse - fixed name and widget values to be translatable 2024-10-23 10:57:29 -04:00
Bill Ferguson
8e129d3825 tools/script_manager - added translated folder names.
cleaned up metadata handling (trimmed whitespace and comments)
		       fixed bug with folder names partially matching other folder names
2024-10-22 16:38:03 -04:00
Bill Ferguson
d123634679 Changed script names in metadata from filenames to names by
removing underscores, spelling out abbreviations, etc.
2024-10-22 00:13:30 -04:00
Bill Ferguson
13f210bec9 official/apply_camera_style - made name tranlatable and made it into
name string instead of the filename

tools/script_manager - change get_script_metadata to retreive a
                       script metadata block and store it as a
                       metadata block making the indiviual fields
                       accessible.

                       change the script buttons to use the translated
                       name if available and just the purpose for the
                       tooltip.
2024-10-21 22:52:11 -04:00
Bill Ferguson
8e4767c42a tools/script_manager - fixed translation of page %d of %d 2024-10-21 14:32:53 -04:00
Bill Ferguson
300bb9d443 lib/dtutils/string - fixed _should_be_sanitized with new patterns
to detect non safe filename characters
2024-10-19 22:04:56 -04:00
wpferguson
4f8df88fec Merge pull request #528 from wpferguson/fix_dgettext
fix message translation calls
2024-10-17 22:21:52 -04:00
Bill Ferguson
44da339202 alias gettext to darktable.gettext.gettext then change the call to gettext
to only pass the message to be translated
2024-10-17 22:17:38 -04:00
wpferguson
0e37a287ca Merge pull request #519 from koto/fix_gui_action
Fix types in examples/gui_action script.  Thanks
2024-10-16 21:21:03 -04:00
wpferguson
2af2530e45 Merge pull request #527 from wpferguson/fix_ret_val_return
fix string library missing end
2024-10-16 21:03:56 -04:00
Bill Ferguson
99eb595f4c lib/dtutils/string added end to if to ensure that ret_val has a value 2024-10-16 21:00:27 -04:00
wpferguson
31cdd3f24a Merge pull request #526 from wpferguson/substitution_library_updates
Substitution library updates
2024-10-16 20:50:15 -04:00
wpferguson
631d89e581 Merge pull request #518 from wpferguson/contrib_p_to_z
contrib/[p-z]*.lua - cleaned up translatable strings
2024-10-16 20:50:01 -04:00
wpferguson
526e97a4e1 Merge pull request #517 from wpferguson/contrib_g_to_o
contrib/[g-o]*.lua - clean up translatable strings
2024-10-16 20:49:46 -04:00
Bill Ferguson
a835ab89bc lib/dtutils/string - added new variable. Removed invalid variables.
Fixed build_substitute list call.  Fixed invalid
                     category return.
2024-10-16 00:42:08 -04:00
Bill Ferguson
da7674ca51 lib/dtutils/string - updated tooltip to use same translatable strings
as gui/gtkentry.c for consistency and eas of
                     translation
2024-10-14 12:54:13 -04:00
Bill Ferguson
0e535b850c Incorporated TurboGit's suggestions 2024-10-12 20:41:02 -04:00
Bill Ferguson
64840089e9 clean up a few issues with parentheses and missed strings. 2024-10-12 20:28:01 -04:00
Krzysztof Kotowicz
d754e37cf4 Properly sanitize filenames in dtutils.file file_copy and file_move. 2024-09-23 10:42:31 +02:00
Krzysztof Kotowicz
f6cb8091e7 Fix types in examples/gui_action script. 2024-09-20 15:07:37 +02:00
wpferguson
e359567620 Merge pull request #503 from wpferguson/apply_camera_styles
apply camera style
2024-09-17 18:33:55 -04:00
Bill Ferguson
36a6a54364 official/apply_camera_string - clean up translatable strings 2024-09-17 18:29:05 -04:00
Bill Ferguson
ecff920537 contrib/[p-z]*.lua - cleaned up translatable strings 2024-09-17 15:29:16 -04:00
Bill Ferguson
842f2fca66 contrib/[g-o]*.lua - clean up translatable strings 2024-09-16 21:16:34 -04:00
wpferguson
ee9384b9a7 Merge pull request #516 from wpferguson/contrib_a_to_f
contrib/[a-f]*.lua - fixed translatable strings to prepare for darktable translation
2024-09-16 20:06:38 -04:00
wpferguson
272c35499a Merge pull request #515 from wpferguson/tools_messages
updated tools/*.lua messages for translation
2024-09-16 20:06:18 -04:00
Bill Ferguson
4165d46b33 tools/script_manager - fixed capitalization 2024-09-16 20:04:29 -04:00
Bill Ferguson
5bed7c914c contrib/[a-f]*.lua - fixed translatable strings to prepare for darktable
translation
2024-09-13 19:47:44 -04:00
Bill Ferguson
684178b27e tools/script_manager - cleaned up translatable strings. Changed displayed
name to scripts.
2024-09-13 14:48:30 -04:00
Bill Ferguson
a72abe0ad0 tools/executable_manager - cleaned up translatable strings. Changed
displayed name to executables.
2024-09-13 14:47:37 -04:00
Bill Ferguson
8863f6ade7 tools/get*.lua - updated translable stirngs 2024-09-13 14:46:47 -04:00
wpferguson
e0463eba83 Merge pull request #512 from wpferguson/rename_images_variable_replacement
Rename images variable replacement
2024-09-13 14:14:36 -04:00
wpferguson
3a2ff7a7b9 Merge pull request #513 from wpferguson/example_messages
examples/*.lua - cleaned up translatable messages
2024-09-13 14:13:33 -04:00
Bill Ferguson
ce7ddfa472 examples/*.lua - cleaned up translatable messages 2024-09-10 21:19:37 -04:00
Bill Ferguson
3fb00586c3 contrib/rename_images - replaced pattern substitution code with the
better implementation in the string library.
2024-09-10 16:36:54 -04:00
Bill Ferguson
167620fadf lib/dtutils/string - Added get_substitution_tooltip() function to return
the substitution pattern tooltip so it only has to be
                     translated in one place.

                     Spelled substitution properly to that calls to
                     build_substitution_list succeed.
2024-09-10 16:34:36 -04:00
Bill Ferguson
f0bdc890c1 official/apply_camera_styles - updated message to specify the camera
styles are darktable camera styles
2024-09-09 22:50:49 -04:00
wpferguson
abdfc9de0b Merge pull request #510 from wpferguson/transllist
Fix string errors preventing translation
2024-09-08 23:51:05 -04:00
Bill Ferguson
c65e070a76 contrib/geoJSON - don't translate the module name 2024-09-08 23:43:39 -04:00
Bill Ferguson
05c57c0247 contrib/geoTooxbox - fix latitude and longitude labels 2024-09-08 23:42:45 -04:00
Bill Ferguson
5be3d6986e official/selection_to_pdf - dont translate internal module name 2024-09-08 23:24:33 -04:00
Bill Ferguson
f0e3627800 contrib/exportLUT - fixed file chooser labels for translation 2024-09-08 22:54:42 -04:00
Bill Ferguson
ea08557a0e tools/script_manager - removed translation of empty string 2024-09-08 22:49:50 -04:00
wpferguson
ac43afd8c9 Merge pull request #507 from darktable-org/fix_contrib_rate_group
contrib/rate_group - fixed formatting of tooltips
2024-09-03 19:16:19 -04:00
Bill Ferguson
ee98f96a4f contrib/rate_group - fixed formatting of tooltips 2024-09-03 19:14:31 -04:00
wpferguson
a33eeddbd6 Merge pull request #504 from darktable-org/darktable_translate_official
prepare official scripts for darktable translation
2024-08-31 21:44:41 -04:00
wpferguson
746c6a07c4 Merge pull request #505 from darktable-org/script_manager_running_script
tools/script_manager - restore script_manager_running_script
2024-08-31 21:43:55 -04:00
Bill Ferguson
96fee48ef2 tools/script_manager - restore script_manager_running_script to
"script_manager" after changing it to start
                       a script
2024-08-31 21:39:50 -04:00
Bill Ferguson
6c686128d2 official/*.lua - Removed bindtextdoamin so that darktable can handle
the translation
2024-08-31 16:48:36 -04:00
Bill Ferguson
6ca8f0034e official/apply_camera_style - apply a darktable camera style to an
image based on maker and model.  Styles
                              may be applied to selections, collections,
                              and on newly imported images.
2024-08-31 15:53:38 -04:00
wpferguson
3d1f12fe44 Merge pull request #500 from darktable-org/fix_create_tmp_file_windows
lib/dtutils/file - os.tmpname now works correctly on windows, removed
2024-08-13 17:50:23 -04:00
Bill Ferguson
a079860cd8 lib/dtutils/file - os.tmpname now works correctly on windows, removed
check and fix
2024-08-13 17:46:28 -04:00
wpferguson
b07c680332 Merge pull request #499 from wpferguson/update_3rd_party
README.md - updated 3rd party scripts
2024-08-10 23:48:24 -04:00
Bill Ferguson
200fc059c0 README.md - updated 3rd party scripts 2024-08-10 23:38:06 -04:00
wpferguson
aeb1f2226c Merge pull request #498 from darktable-org/fix_translatable_strings
fixed translatable strings for inclusion into darktable
2024-08-08 19:47:26 -04:00
Bill Ferguson
46e729b40e fixed translatable strings for inclusion into darktable 2024-08-08 19:43:33 -04:00
wpferguson
66b613dc29 Merge pull request #497 from wpferguson/remove_quote_windows_command
lib/dtutils/system - remove _quote_windows_command
2024-07-21 22:47:05 -04:00
Bill Ferguson
535ba78a06 lib/dtutils/system - remove _quote_windows_command 2024-07-21 22:43:59 -04:00
Bill Ferguson
cc11c1c3b8 tools/script_manager - set log level to warn instead of debug 2024-07-18 12:42:12 -04:00
wpferguson
fba639e98a Merge pull request #496 from wpferguson/desanitize_libs
Desanitize libs
2024-07-13 14:50:47 -04:00
Bill Ferguson
3e37c06b84 lib/dtutils/string - Added check to determine if string needs to be
sanitized.  Check looks for unprintable characters
                     and spaces.
2024-07-13 14:44:01 -04:00
Bill Ferguson
1b272be5f5 various scripts - reverted the calls to io_popen and os_execute back
to the respective lua calls.
2024-07-13 12:48:37 -04:00
Bill Ferguson
9f423eeef3 lib/dtutils/file - reverted io_popen and os_execute wrappers as
lib/dtutils/system   they don't work in this situation (no control
                     over the input strings)
2024-07-13 12:46:34 -04:00
wpferguson
dc81c0b1c5 Merge pull request #494 from wpferguson/add_preserve_metadata_to_RL_out_sharp
RL_out_sharp - preserve metadata
2024-07-10 15:22:35 -04:00
Bill Ferguson
e8a99c8396 contrib/RL_out_sharp - add function to preserve the exported images
metadata in the sharpened image using exiftool
2024-07-10 15:17:35 -04:00
wpferguson
7c93868bf0 Merge pull request #491 from wpferguson/fix_quote_windows_command_call
lib/dtutils/system - fixed typo in quote_windows_command call
2024-07-08 11:46:30 -04:00
Bill Ferguson
36023d8d4f lib/dtutils/system - fixed typo in quote_windows_command call 2024-07-08 11:43:42 -04:00
wpferguson
97aa4ce363 Merge pull request #490 from wpferguson/fix_email
fix email address
2024-06-30 12:46:51 -04:00
Bill Ferguson
316a89d6a8 contrib/auto_snapshot - fixed email address
contrib/dbmain
2024-06-30 12:44:02 -04:00
wpferguson
d4a479b025 Merge pull request #486 from wpferguson/ensure_renamed_image_visible
ensure renamed image is visible
2024-06-21 10:04:06 -04:00
wpferguson
dd22c947c6 Merge pull request #487 from wpferguson/fix_fujifilm_dynamic_range_duplicates
fujifilm_dynamic_range - fix duplicate processing
2024-06-21 10:03:45 -04:00
wpferguson
09f47b7b09 Merge pull request #488 from wpferguson/auto_snapshot
auto_snapshot
2024-06-21 10:03:30 -04:00
Bill Ferguson
ba94914c0e contrib/auto_snapshot - added Lua option to create always create a snapshot
when opening an image in darkroom, even if it is
                        altered
2024-06-20 18:09:10 -04:00
Bill Ferguson
3bb4e9c59a contrib/auto_snapshot - take a snapshot automatically when opening an image in darkroom 2024-06-20 17:46:54 -04:00
Bill Ferguson
f8c076f308 contrib/fujifilm_dynamic_range - added check for duplicates after an
image is processed.  If duplicates are
                                 found the exposure bias is applied to
                                 them.
2024-06-19 20:50:54 -04:00
Bill Ferguson
94f41db6fc contrib/rename_images - make sure the renamed image, or first renamed
image of a group is visible after renaming.
2024-06-19 11:41:54 -04:00
wpferguson
5727b2d251 Merge pull request #485 from wpferguson/script_manager_api_solution
script_manager api check solution
2024-06-18 00:34:30 -04:00
Bill Ferguson
c95f8a23b2 lib/dtutils/log - fix screen print check 2024-06-18 00:30:34 -04:00
Bill Ferguson
88e4ac1a64 tools/script_manager - changed API check from hard (crash) to soft
which allows script_manager to fix tthe problem
                       by checking out the correct version of the
                       scripts for the API version.
2024-06-18 00:29:27 -04:00
wpferguson
a3fe02bf95 Merge pull request #482 from wpferguson/fix_non_windows_command_sanitize
fix non windows external command sanitize
2024-06-14 12:37:16 -04:00
Bill Ferguson
ff20098175 lib/dtuils/system - removed ds.sanitize wrapped around non windows command. 2024-06-14 12:33:35 -04:00
wpferguson
cdf4b743dd Merge pull request #479 from wpferguson/script_mangaer_4_8
New script_manger UI for darktable 4.8
2024-06-09 17:36:52 -04:00
Bill Ferguson
3efc1805ca tools/script_manager - new user interface for darktable 4.8
wrappers added for io.popen and os.execute
                       to handle windows special characters and
                       spaces
2024-06-09 17:33:06 -04:00
wpferguson
0b46cf8abf Merge pull request #477 from darktable-org/revert-474-script_manager_new_ui
Revert "script_manager new UI"
2024-06-09 16:42:17 -04:00
wpferguson
28622e620e Revert "script_manager new UI" 2024-06-09 16:42:05 -04:00
wpferguson
f21a117d29 Merge pull request #474 from wpferguson/script_manager_new_ui
script_manager new UI
2024-06-09 16:25:50 -04:00
wpferguson
35cbff03dd Merge pull request #475 from wpferguson/doc_update
Update documentation
2024-06-08 22:33:57 -04:00
Bill Ferguson
5571e2f2dc ChangeLog - Updated with the latest repository changes
README - Updated the script additions
2024-06-08 21:51:37 -04:00
wpferguson
3c77f2e863 Merge branch 'master' into script_manager_new_ui 2024-06-07 19:31:25 -04:00
Bill Ferguson
4ff1111341 tools/script_manaager added sanitized io.popen and os.execute functions
for windows character and space issues.  Cleaned
                      up translatable strings to make future translation
                      easier.
2024-06-07 15:23:06 -04:00
wpferguson
abfa8e9878 Merge pull request #473 from wpferguson/fix_472_fujifilm_ratings
Fix fujifilm ratings
2024-06-06 13:02:29 -04:00
wpferguson
bbe9109fca Merge pull request #469 from wpferguson/win_sanitize
Sanitize windows command interactions
2024-06-06 13:01:55 -04:00
wpferguson
34d5df65b2 Merge pull request #468 from wpferguson/dbmaint
database maintenance script
2024-06-06 13:01:19 -04:00
Bill Ferguson
539f25517b contrib/fujifilm_ratings - added check to ensure the image is a
fujifilm file.
2024-06-05 22:16:40 -04:00
wpferguson
5b55a3116d Merge pull request #470 from wpferguson/windows_executuable_manager_fix
executable_manager - fix position not visible on windows
2024-06-05 14:51:10 -04:00
Bill Ferguson
3e032616a0 tools/executable_manager - fix position not visible on windows 2024-06-05 14:49:06 -04:00
Bill Ferguson
9f2dbef4f0 lib/dtutils/system added local helper function quote_windows_command() to
wrap a windows command in quotes.  Added a sanitize step
                   to windows_external_command() plus quote_windows_command()
                   to deal with all the windows username possibilities
2024-06-05 12:15:01 -04:00
Bill Ferguson
2abb83b485 tools/get_lib_manpages - more code cleanup 2024-06-05 00:09:18 -04:00
Bill Ferguson
32e966f8d9 tools/git_lib_manpages code cleanup 2024-06-05 00:01:47 -04:00
Bill Ferguson
67538a4de2 lib/dtutils/system code cleanup 2024-06-05 00:01:17 -04:00
Bill Ferguson
96471ae7e7 lib/dtutils - fixed documentation error 2024-06-05 00:00:43 -04:00
Bill Ferguson
038418b89f contrib/autostyle replaced io.popen functions with wrapper
contrib/color_profile_manager    to properly quote windows commands so
contrib/fujifilm_dynamic_range   that they are sanitized for special
contrib/fujifilm_ratings         characters and spaces
contrib/geoJSON_export
contrib/geoToolbox
contrib/image_stack
contrib/image_time
contrib/kml_export
official/enfuse
tools/executable_manager
tools/get_lib_manpages
tools/get_libdoc
2024-06-04 23:43:21 -04:00
Bill Ferguson
fe48d7498c lib/dtutils/file - replaced os.execute and io.popen with wrapper functions
to sanitize windows calls
2024-06-04 23:41:07 -04:00
Bill Ferguson
2f330ea9cc lib/dtutils/system - added wrapper functions io_popen and os_execute
to wrap io.popen and os.execute system calls
                     respectively.  These wrapper functions provide
                     the necessary quoting on windows to get handle
                     strings with spaces and special characters.
2024-06-04 23:16:19 -04:00
Bill Ferguson
81b0f1fb48 contrib/dbmaint - remove database records for missing film rolls and images. 2024-06-03 18:08:30 -04:00
Bill Ferguson
9088bc9144 tools/script_manager - make the constants <const> to ensure they
stay that way
2024-06-03 14:48:44 -04:00
wpferguson
c3ce8d532d Merge pull request #467 from koto/open_in_file_explorer_osx
Support selecting multiple files in MacOS in OpenInExplorer.
2024-05-30 13:36:47 -04:00
Krzysztof Kotowicz
f1d8ad7fce Fix quoting. 2024-05-27 18:26:35 +02:00
Krzysztof Kotowicz
a3b295112f Update OpenInExplorer.lua
In OpenInExplorer, use AppleScript instead of `open -R` for OSX.

That way multiple files can be selected.
2024-05-27 13:03:00 +02:00
wpferguson
c36618f5fb Merge pull request #466 from wpferguson/more_string_doc_updates
lib/dtutils/string - more embedded doc updates
2024-05-20 23:45:07 -04:00
Bill Ferguson
fecbb39347 lib/dtutils/string - more embedded doc updates 2024-05-20 23:43:47 -04:00
wpferguson
cbe2c5329a Merge pull request #412 from wpferguson/add_substitution_to_string_lib
Add substitution to string lib
2024-05-20 22:18:01 -04:00
Bill Ferguson
dcbe575e9c lib/dtutils/string - updated embedded documentation 2024-05-20 22:13:29 -04:00
Bill Ferguson
417c165d16 lib/dtutils/string - updated documentation 2024-05-20 18:18:46 -04:00
Bill Ferguson
232baab86b lib/dtutils/string - removed debugging statements 2024-05-20 10:07:13 -04:00
Bill Ferguson
3ed4219e6c lib/dtutils/string - added [] to sanitize_lua().
added 4.8 syntax to CATEGORY

                     added 4.8 SEQUENCE changes (syntax, start, width)
2024-05-20 00:56:01 -04:00
Bill Ferguson
97e33672ea lib/dtutils/string - fixed default formatting of sequence 2024-05-19 23:04:01 -04:00
Bill Ferguson
7b2018412a lib/dtutils/string - Cleaned up code to make it more readable.
Fixed VERSION_IF_MULTI.  Added safety check
                     in category to make sure we don't try and
                     read a tag field that doesn't exist.
2024-05-18 22:01:10 -04:00
Bill Ferguson
3e2afffed8 lib/dtutils/string - Added categories to substitution functionality.
This makes it feature complete.  Some substitutions
                         aren't implemented since the current use case for
                         this is creating export directories.  The results
                         from the not implemented substitutions wouldn't
                         work well in path/file names (such as comma
                         separated lists or newlines).
2024-05-18 21:59:11 -04:00
wpferguson
1399e8a4b4 Merge pull request #465 from wpferguson/fix_script_manager
Fix script_manager crash
2024-05-16 11:47:29 -04:00
Bill Ferguson
5c3b2777f0 tools/script_manager - fixed gettext.bindtextdomain 2024-05-16 11:44:35 -04:00
Bill Ferguson
bf138abeb2 tools/script_manager - removed debugging statement 2024-05-15 21:36:15 -04:00
Bill Ferguson
284c0f9714 tools/script_manager - fixed metadata decoding to get rid of spurious
commas
2024-05-15 21:33:29 -04:00
wpferguson
e41029d3f4 Merge pull request #464 from wpferguson/implement_script_metadata
Implement script metadata
2024-05-15 21:27:54 -04:00
Bill Ferguson
55e68f8cd0 Added metadata fields to scripts that script_manager can access and
display as a tooltip.

Added script_manager integration to those scripts that didn't have it.
2024-05-15 21:23:13 -04:00
wpferguson
ac945b9843 Merge pull request #455 from wpferguson/prep_translation
Prepare translatable strings, step 1
2024-05-15 15:18:11 -04:00
Bill Ferguson
f6916c3a15 tools/script_manager - lower cased mixed case buttons and headings 2024-05-15 14:51:14 -04:00
Bill Ferguson
cd3788f012 all scripts - added bindtextdomain back in because 4.8 isn't ready to
handle the translations yet.  In 5.0 this will be removed
              and darktable will handle translating the strings.
2024-05-14 22:39:22 -04:00
wpferguson
ebd2cd7bf7 Merge pull request #462 from menschmaschine/master
Cropping guide for German passport and ID card photos.
2024-05-11 20:09:45 -04:00
Christian Sueltrop
52b4508e08 Added LUA script "passport_guide_germany.lua", which implements a cropping guide for passport photos according to the standards for German passport and ID card photos. 2024-05-06 21:53:46 +02:00
Bill Ferguson
b1b3392b92 tools/script_manager removed color interface check button. Color can
be specified in the CSS using the tags that are
                     present if desired.

                    Cleaned up formatting of configuration items.

                    Added a few debugging messages.
2024-04-09 21:41:42 -04:00
wpferguson
19fdbc14c5 Merge pull request #461 from wpferguson/reimplement_ensure_lib_in_path
reimplemented ensure_lib_in_path with a windows aware path specification
2024-04-08 23:33:12 -04:00
Bill Ferguson
63d5aad465 tools/script_manager reimplemented ensure_lib_in_path with a windows
aware path specification
2024-04-08 23:30:30 -04:00
wpferguson
9d6ff85893 Merge pull request #458 from wpferguson/revert_ensure_lib_in_path
revert ensure_lib_in_path
2024-04-06 21:51:26 -04:00
Bill Ferguson
125af63bda tools/script_manager - revert ensure_lib_in_path because of windows problems. 2024-04-06 21:48:51 -04:00
Bill Ferguson
ddf0c89402 tools/script_manager - cleaned up layout of panels and added some
spacing so what is being operated on is more
                         appearent
2024-04-06 21:28:58 -04:00
Bill Ferguson
3b0ff3475a tools/script_manager added blank lines to improve code readability 2024-04-05 21:12:45 -04:00
Bill Ferguson
401509cfe4 tools/script_manager added parser for script_data.metadata blocks in
scripts.  Parsed data block is used as the tooltip.
                      Fallback is the comment block at the top of the
                      script.
2024-04-05 20:38:10 -04:00
Bill Ferguson
9c4e906033 data/icons - added 20px icons 2024-04-05 20:37:34 -04:00
wpferguson
65c22e475a Merge pull request #457 from wpferguson/script_manager_lib_search_path
script_manager - support libraries in "local" directories
2024-04-03 13:54:46 -04:00
Bill Ferguson
a11726889d tools/script_manager - add support for "local" libraries by adding
entries in the package.path search path if
                       required
2024-04-02 19:09:31 -04:00
Bill Ferguson
e78e718769 tools/script_manager - allow for inclusion of directory/package specific
libraries by adding "local" libraries to the search
                       path to ensure they are found when needed.
2024-04-02 17:54:10 -04:00
Bill Ferguson
86ee8adbce tools/script_manager - changed category/categories to folder/folders to
accurately refrect reality and to open the possibility
                       of actually categorizing scripts.
2024-04-01 18:26:41 -04:00
wpferguson
40949b3855 Merge pull request #456 from wpferguson/fix_NaN
examples/gui_action.lua - changed nan to NaN
2024-03-29 16:05:22 -04:00
Bill Ferguson
06ab263e74 examples/gui_action.lua - changed nan to NaN 2024-03-29 16:04:07 -04:00
wpferguson
bccc86c70a Merge pull request #362 from dterrahe/lua_action
simple module to call dt_action_process
2024-03-29 16:01:37 -04:00
Bill Ferguson
231e9b352b changed translatable strings to lower case 2024-03-29 14:17:19 -04:00
Bill Ferguson
e47ab34745 changed translatable strings to lower case 2024-03-29 13:10:41 -04:00
Bill Ferguson
1fd2ca20ab changed translatable strings to lower case 2024-03-29 12:55:08 -04:00
Bill Ferguson
05a73d8810 changed translatable strings to lower case 2024-03-29 12:45:28 -04:00
wpferguson
12640c7d29 Merge pull request #454 from mime01/script_manager
tools/script_manager - fixed crash
2024-01-28 12:40:44 -05:00
Michael Meister
febc3b1659 tools/script_manager - fixed crash
The script manager crashes if a LUA script was not copied to a
subfolder but directly into the LUA directory. The reason is that
the regular expression, which among other things extracts the
category of the script from its file path, does not match and thus
the category is null. To prevent this, a null check has been added.
2024-01-27 12:27:40 +01:00
wpferguson
9fdd69556c Merge pull request #453 from wpferguson/452_fix
don't set lib visibility unless we are in lighttable view
2024-01-24 13:18:59 -05:00
Bill Ferguson
4735be470a tools/script_manager - don't set lib visibility unless we are in
lighttable view
2024-01-24 13:16:42 -05:00
Bill Ferguson
66b33d6f48 updated contrib scripts to use darktable translation facilities 2024-01-20 20:22:32 -05:00
Bill Ferguson
37dba718a2 updated official scripts to use darktable translation facilities 2024-01-20 15:25:16 -05:00
Bill Ferguson
c11845cbf9 updated example scripts to use darktable translation facilities 2024-01-19 18:57:18 -05:00
Bill Ferguson
f9fe33f930 updated script_manager and executable_manager to use darktable
translation facilities.  Changed translatable messages with
arguments to use string.format for one complete string versus snippets.

Removed gen_i18n_mo since we will be using darktable's translation
facilities and there's no need to generate lua specific mo files.
2024-01-19 15:24:56 -05:00
wpferguson
3b8e802e42 Merge pull request #444 from MStraeten/patch-1
Update x-touch.lua with support for primaries slider
2024-01-15 11:11:47 -05:00
Martin Straeten
f54d449316 increase required api version
… to match darktable 4.6.x
2024-01-15 07:01:43 +01:00
wpferguson
1b0fe4d7b9 Merge pull request #449 from wpferguson/cycle_group_leader
cycle group leader
2024-01-14 22:33:13 -05:00
Bill Ferguson
cf1dca9e1a contrib/cycle_group_leader.lus - adds shortcut to change the group
leader to the next image in a group
                                 wrapping around when the end of the
                                 group is reached.
2024-01-14 22:29:27 -05:00
wpferguson
45d54ef4e8 Merge pull request #448 from darktable-org/revert-447-change_group_leader
Revert "Change group leader"
2024-01-14 22:14:03 -05:00
wpferguson
8bfab0325b Revert "Change group leader" 2024-01-14 22:13:38 -05:00
wpferguson
4b99d00ab5 Merge pull request #447 from wpferguson/change_group_leader
Change group leader
2024-01-14 21:25:00 -05:00
Bill Ferguson
a5961eb066 contrib/change_group_leader.lua - adds a shortcut to cycle through
the images in a group making the
                                  next on the new group leader.
                                  When the end of the group is reached
                                  the first image in the group is
                                  selected.
2024-01-14 21:19:09 -05:00
wpferguson
95e19ef163 Merge pull request #446 from wpferguson/hif_group_leader
Make hif image group leader for raw + hif pairs
2024-01-14 17:31:07 -05:00
wpferguson
d4eb6577bf Merge pull request #445 from wpferguson/jpg_group_leader
Make jpg group leader for raw + jpg pairs
2024-01-14 17:30:52 -05:00
Bill Ferguson
294b693905 contrib/hif_group_leader.lua - make the hif image the group leader
for raw + hif image pairs.  Works
                               on import, selection, and collection.
2024-01-14 17:15:28 -05:00
Bill Ferguson
23835edc1f contrib/jpg_group_leader.lua - New script to make jpg images the
group leader for raw + jpg image
                               combinations.
2024-01-14 17:10:43 -05:00
Martin Straeten
5f29211f79 Update x-touch.lua with support for primaries slider
maps knobs to the primaries sliders
requires darktable 4.6.x
2024-01-11 20:42:32 +01:00
wpferguson
025f4299ea Merge pull request #435 from ddittmar/feature/select_non_existing
select non-existing images
2023-11-10 18:42:01 -05:00
ddittmar
dc50d40886 select non-existing images 2023-10-28 11:14:51 +02:00
wpferguson
867c49b1b9 Merge pull request #433 from wpferguson/script_manager_quote_fix
tools/script_manager - fixed quote
2023-10-17 16:04:42 -04:00
Bill Ferguson
13f02c95ea tools/script_manager - fixed quote with a " instead of s 2023-10-17 16:02:27 -04:00
wpferguson
d55dae73f0 Merge pull request #431 from wpferguson/script_manager_username_space_fix
Fix script_manager doesn't start on windows when username has a space
2023-10-16 22:44:10 -04:00
Bill Ferguson
34b9831472 tools/script_manager.lua - wrapped the scipt_dir in quotes to handle
the space in username problem on windows.
2023-10-16 22:41:12 -04:00
wpferguson
014a0fc1c9 Merge pull request #430 from wpferguson/explicitly_set_false
Explicitly set non running scriopts to FALSE
2023-09-20 13:54:02 -04:00
Bill Ferguson
bf17dccd69 tools/script_manager.lua - Explicitly set non running scriopts to FALSE
instead of relying on no value being intrepreted
                           as false.
2023-09-20 13:48:18 -04:00
wpferguson
890168d0d0 Merge pull request #426 from wpferguson/425_fix_executable_manager_not_appearing
Change window position of executable_manager and script_manager
2023-08-18 12:27:28 -04:00
Bill Ferguson
191aecacdf tools - Moved script_manager to bottom of lower left panel and
moved executable_manager to middle of lower left panel
        to work around windows GTK window placement error.
2023-08-18 12:23:24 -04:00
wpferguson
44ec01b136 Merge pull request #424 from wpferguson/fix_check_for_updates_comment
official/check_for_updates - updated instructions for additional modules
2023-07-17 17:41:10 -04:00
Bill Ferguson
a177da2040 official/check_for_updates = updated instructions for additional modules
required
2023-07-17 17:39:24 -04:00
wpferguson
c899040688 Merge pull request #423 from wpferguson/update_flatpak_readme
README.md - updated (fixed typos) echo commands to build luarc file
2023-07-16 13:24:56 -04:00
Bill Ferguson
e8af665b3c README.md - updated (fixed typos) echo commands to build luarc file 2023-07-16 13:22:06 -04:00
wpferguson
875734d455 Merge pull request #422 from wpferguson/fix_script_data_show
Fix script data show
2023-07-16 13:08:05 -04:00
Bill Ferguson
14d5a79db2 Added script_data.show to script_data blocks 2023-07-16 13:04:00 -04:00
Bill Ferguson
e1b2715ee9 contrib/gpx_export - added show function to script_data to fix #418 and #419. 2023-07-16 12:50:28 -04:00
wpferguson
7ecd5ca55d Merge pull request #421 from wpferguson/script_manager_updates
Script manager updates
2023-07-15 20:00:24 -04:00
wpferguson
931e7a4d37 Merge pull request #416 from wpferguson/check_max_api_version
Add check for max api version
2023-07-15 19:58:57 -04:00
Bill Ferguson
1792410efe lib/dtutils.lua - corrected test 2023-07-15 19:52:39 -04:00
wpferguson
8cbd9224f1 Merge pull request #377 from spaceChRiS/filter_manager_tooltip
Added tooltip to filter manager to better match new import scheme.
2023-07-14 17:40:10 -04:00
Bill Ferguson
24b552d619 lib/dtutils.lua - fix typo from testing 2023-07-12 13:18:01 -04:00
Bill Ferguson
68ae9326bf tools/script_manager.lua - added translation to preference setting 2023-07-12 12:37:14 -04:00
Bill Ferguson
b4626f2787 lib/dtutils.lua - changed log message to error on fail to load. Added
printing of the returned error.
2023-07-04 15:57:12 -04:00
Bill Ferguson
2fc8ed78e4 tools/script_manager.lua - added check to ensure script_data.show() runction
was passed as part of the script_data table
                           before trying to use it. Fixes #418.
2023-07-03 23:44:13 -04:00
Bill Ferguson
236b25a235 tools/script_manager.lua - clean up formatting and documentation 2023-07-03 23:42:47 -04:00
Bill Ferguson
a4f6af73ec tools/script_manager.lua - enabled log levels in callback routines 2023-06-24 19:56:51 -04:00
Bill Ferguson
fad74d6438 tools/script_manager.lua - cleaned up deactivate comments 2023-06-23 19:09:57 -04:00
Bill Ferguson
3e2d4c956d tools/script_manager.lua - Documented more fields for the sm.scripts table
Removed extra declaration of check_update preference
2023-06-22 16:04:26 -04:00
wpferguson
cd1d623390 Merge pull request #409 from dterrahe/x_touch_mimic
example slider mimic script for x-touch mini
2023-05-30 18:38:48 -04:00
Bill Ferguson
9e0374d597 lib/dtutils.lua - fix typos 2023-05-06 14:56:58 -04:00
Bill Ferguson
e47672b495 lib/dtutils.lua - added delay in check_min_api_version to sllow display of the error
message before script_manager displays an error message.
2023-05-06 14:36:22 -04:00
Bill Ferguson
1905be8577 lib/dtutils.lua - added check_max_api_version to handle the case where part of
the API is removed as in the case of the darktable.gui.libs.fixter functions.
2023-05-06 14:31:15 -04:00
dterrahe
4726821e7d Fix 8th knob 2023-05-05 23:19:00 +01:00
dterrahe
7ac37ddc1a Probe individual mask sliders 2023-05-03 23:43:01 +01:00
Bill Ferguson
ad10542b30 lib/dtutils/string - Added variable substitution functions that
are equivalent to the darktable variable
                     substitution functions.
2023-03-26 14:55:40 -04:00
Bill Ferguson
5331a38f10 lib/dtutils/string - added % and + to sanitize_lua() to prevent
pattern matching problems
2023-03-25 17:05:11 -04:00
Bill Ferguson
c9943a2065 lib/dtutils/string - Added logging capability with the ability to
set library logging level from a user script
2023-03-25 17:02:48 -04:00
dterrahe
3889742e06 add x-touch mini script documentation 2023-03-25 18:49:55 +00:00
dterrahe
6bf3706455 add x-touch color calibration customisation 2023-03-25 18:14:19 +00:00
wpferguson
612ecaff6c Merge pull request #411 from wpferguson/doc_update
Updated documentation
2023-03-25 13:25:45 -04:00
Bill Ferguson
a85364ecff Updated documentation 2023-03-25 13:24:04 -04:00
wpferguson
c0af03c503 Merge pull request #408 from wpferguson/move_filename_string_functions_to_strings_library
Move filename/path/extension string functions to string library
2023-03-25 13:22:50 -04:00
wpferguson
9b61e4793b Merge pull request #410 from darktable-org/script_manager_running_script
script_manager darktable shortcut integration
2023-03-25 13:07:00 -04:00
wpferguson
75a19e74a0 Merge branch 'master' into script_manager_running_script 2023-03-25 13:03:55 -04:00
Bill Ferguson
21d7e72b0c tools/script_manager - resolved conflicts 2023-03-25 13:01:40 -04:00
Bill Ferguson
05d555eae5 tools/script_manager - let the shortcut system know that script_manager
widgets belong to script_manager
2023-03-25 12:46:59 -04:00
dterrahe
8e412c3eb3 example slider mimic script for x-touch mini 2023-03-25 10:59:19 -04:00
Bill Ferguson
80147a9ebc lib/dtugiles.file - Moved filename/path/extension string functions to string library. Left
the existing function calls in place for backward compatibility.  They
                      now call the new functions in the string library

lib/dtutils.string - Moved the filename/path/extension string functions to the string library
                     to prevent a circular library depnedency.  The file library includes the
                     string library.  If the string library needed to manipulate filename
                     related strings then the string library would need to include the
                     file library which would lead to a stack overflow.
2023-03-24 13:40:34 -04:00
Bill Ferguson
3f6a3e25f1 added global variable script+_manager_running_script to convey the script name to the darktable shortcut system 2023-03-16 20:59:10 -04:00
wpferguson
800cbeef9d Merge pull request #407 from wpferguson/script_manager_check_for_updates_pref
script_manager preference - check for updated scripts
2023-03-06 23:08:54 -05:00
Bill Ferguson
574f6a976f script_manager.lua - added a preference allowing the user to disable
automatic checking for updated scripts.
2023-03-06 22:56:55 -05:00
supertobi
030b360e57 Merge pull request #404 from darktable-org/macOS_HOME
Mac os home
2023-02-27 09:30:44 +01:00
supertobi
b883714192 fix HOME environment variable name for macOS 2023-02-27 09:29:16 +01:00
supertobi
d556f48168 fix HOME environment variable name for macOS 2023-02-27 09:27:25 +01:00
wpferguson
cd7cac0eec Merge pull request #403 from rds13/featureFixKML
fix HOME environment variable name
2023-02-25 12:21:41 -05:00
Romuald du Song
9b31f18470 fix HOME environment variable name 2023-02-25 17:41:45 +01:00
wpferguson
42a194b3d7 Merge pull request #400 from wpferguson/update_change_group_leader
Update contrib/change_group_leader
2022-10-16 14:03:16 -04:00
Bill Ferguson
6748a7125e README.md Added change_group_leader to contrib section
change_group_leader.lua  Updated copyright information

                         Added script_manager integration

                         Added i18n
2022-10-16 13:58:19 -04:00
wpferguson
c2b3f29f3b Merge pull request #399 from dexterlb/change_group_leader
Add group leader script
2022-10-15 13:02:49 -04:00
dexterlb
572a634d90 fix title 2022-10-10 21:39:38 +03:00
dexterlb
652606ffb0 fix copyright message 2022-10-10 21:38:30 +03:00
dexterlb
803537c63e add comments to change_group_leader 2022-10-09 12:00:29 +03:00
dexterlb
4648c2d9af add change_group_leader script 2022-10-09 11:54:02 +03:00
supertobi
edceb3e7e9 Merge pull request #396 from mpaglia0/master - Added Italian translation + improved label
Added Italian translation + improved label
2022-07-15 09:52:14 +02:00
Maurizio Paglia
da6bddcd77 Clear button now can be translated 2022-07-14 18:44:42 +02:00
Maurizio Paglia
b11f43e903 Added Italian translations 2022-07-14 18:43:02 +02:00
supertobi
ef218a4d2e Merge pull request #394 from manu-p/master
OpenInExplorer fr_FR translation
2022-06-28 10:02:45 +02:00
manu-p
b061f27e7a OpenInExplorer fr_FR translation 2022-06-27 17:36:47 +02:00
wpferguson
8e64d54ab1 Merge pull request #389 from wpferguson/fix_readme_links
[README.md] fix links to documentation
2022-03-16 13:12:59 -04:00
Bill Ferguson
56b40a80ac [README.md] fix links to documentation 2022-03-16 13:10:06 -04:00
supertobi
d359d8ecb4 Merge pull request #383 from dtorop/fuji-dr-load-only-with-exiftool
fujifilm_dynamic_range: only load if exiftool present
2022-02-14 09:58:13 +01:00
Dan Torop
2bc55d00bb fujifilm_dynamic_range: only load if exiftool present
Fail to load if exiftool binary is not present. This may be better
than silently (in UI) failing to read dyanmic range data.
2022-02-13 22:14:57 -05:00
wpferguson
d3cf564b71 Merge pull request #379 from wpferguson/cleanup_changelog
fix changelog formatting
2022-01-12 14:59:04 -05:00
Bill Ferguson
4fb8b97084 fix changelog formatting 2022-01-12 14:57:57 -05:00
wpferguson
32c5cceb1d Merge pull request #378 from wpferguson/update_docs
Updated documentation
2022-01-12 14:54:30 -05:00
Bill Ferguson
f38c14d6b5 Updated documentation 2022-01-12 14:53:02 -05:00
Christian Mandel
3070ca0bc4 Added tooltip to filter manager to better match new import scheme. 2022-01-09 15:46:29 +01:00
wpferguson
0122b3f717 Merge pull request #374 from wpferguson/which_deprecation_369
Fix dtutils/file.lua deprecation warning
2021-12-28 20:50:21 -05:00
Bill Ferguson
79678fd82f [lib/dtutils/file.lua] replaced deprecated "which" call with recommended
"command -v" call to check the existence of a
                       program
2021-12-28 20:45:50 -05:00
wpferguson
034ddfbafb Merge pull request #373 from wpferguson/deprecate_rename_tags
Deprecate rename-tags.lua
2021-12-28 11:22:25 -05:00
Bill Ferguson
aebd26d03a [lib/dtutils.lua] - Added deprecated function to use when deprecating
scripts

[contrib/rename-tags.lua] - Added deprecation warning
2021-12-27 19:36:15 -05:00
wpferguson
d609823491 Merge pull request #368 from wpferguson/fix_rename_sequence_leading_zeros
Fix rename_images sequence substitution
2021-10-22 11:15:19 -04:00
Bill Ferguson
8f414f783a [Changelog] Updated with latest changes 2021-10-22 11:12:24 -04:00
Bill Ferguson
2e521553bf [rename_images] Added changed suggested by Volker Bödker to make sure
sequence was 4 digits with leading zeros.
2021-10-22 11:09:01 -04:00
wpferguson
e93f5fc812 Merge pull request #365 from MarcusGama/devel
Update pt_BR translation
2021-10-04 13:48:37 -04:00
Marcus Gama
3dbbb7dfd5 Update pt_BR translation 2021-10-02 05:52:20 -03:00
supertobi
fbb92e1023 Initial pt_BR translation - Merge pull request #364 from MarcusGama/devel
Initial pt_BR translation
2021-09-29 09:54:15 +02:00
Marcus Gama
ea4c6373f9 Initial pt_BR translation 2021-09-28 20:08:30 -03:00
supertobi
40b2569a21 Merge pull request #363 from lbschenkel - Fix URL of Finnish police document
Fix URL of Finnish police document
2021-09-14 09:49:15 +02:00
Leonardo Brondani Schenkel
ef6e4d8f0b Fix URL of Finnish police document
The old URL returns a 404, this is the current replacement.
2021-09-13 17:23:10 +02:00
Diederik ter Rahe
28ae2ea501 simple module to call dt_action_process 2021-09-12 18:16:09 +02:00
wpferguson
657407c7a0 Merge pull request #361 from chrisaga/master
Minor errors in dtutils_log.libdoc.Example : error levels are log.xxxx
2021-09-02 14:40:09 -04:00
chrisaga
b254577bc8 Merge branch 'master' of github.com:chrisaga/lua-scripts 2021-09-02 11:26:57 +02:00
chrisaga
63763bedc8 Minor errors in dtutils_log.libdoc.Example : error levels are log.xxxx 2021-09-02 11:23:36 +02:00
wpferguson
3d50d0fdb4 Merge pull request #360 from wpferguson/fix_AutoGroup_style_hide
Remove styles hiding from AutoGrouper.lua
2021-08-31 12:32:10 -04:00
Bill Ferguson
1ca6b18f5e Remove styles hiding from AutoGrouper.lua 2021-08-31 12:31:04 -04:00
wpferguson
b82ffc2af3 Merge pull request #359 from johnny-bit/dt3139_moar_guidez
add new script harmonic armature guide
2021-08-15 17:09:59 -04:00
Hubert Kowalski
d142151055 fix lines and contrib require 2021-08-15 22:43:13 +02:00
wpferguson
91b78529fe Merge pull request #341 from wpferguson/color_profile_manager
Add new script color_profile_manager
2021-08-15 16:35:19 -04:00
wpferguson
7aec6884f4 Merge pull request #351 from wpferguson/add_rename_script
[contrib/rename] Add rename_images script
2021-08-15 16:34:41 -04:00
Hubert Kowalski
7f140828bb add harmonic armature guide 2021-08-14 13:01:00 +02:00
supertobi
4f13a56814 Merge pull request #358 from chrisaga/master
Add french translation for photils.lua
2021-08-13 10:36:54 +02:00
chrisaga
27d3ea253d Add simple file header 2021-08-13 10:15:38 +02:00
chrisaga
5209b9899d Add french translation for photils 2021-08-13 10:06:58 +02:00
wpferguson
6a40c836c0 Merge pull request #355 from wpferguson/fix_geoToolbox
geoToolbox 5.4 compatibility
2021-08-05 18:55:08 -04:00
Bill Ferguson
c4df81bdef [contrib/geoToolbox] changed atan2 call to atan for lua 5.4 compatibility 2021-08-05 18:53:05 -04:00
wpferguson
e99827d237 Merge pull request #354 from wpferguson/fix_quicktag_entry
Fix quicktag tag entry
2021-08-04 11:30:44 -04:00
Bill Ferguson
a0cbe8efd5 [contrib/quicktag] changed is_password to false on entry so user can
see what they typed.
2021-08-04 11:28:12 -04:00
Bill Ferguson
b4ee97a768 got register_lib arguments in the correct order 2021-08-02 23:44:05 -04:00
Bill Ferguson
4bdaaaf1ce renamed rename to rename_images to better reflect the purpose 2021-08-02 23:26:22 -04:00
Bill Ferguson
3cf0fea092 [contrib/rename] Rename files including moving them into new or other
film rolls.
2021-07-28 01:18:51 -04:00
wpferguson
97e1451dc6 Merge pull request #348 from wpferguson/fix_script_manager_register_event
[script_manager] updated register_event syntax to API 7.0.0
2021-07-14 11:45:54 -04:00
Bill Ferguson
4cbb7724f2 [script_manager] updated register_event syntax to API 7.0.0 2021-07-14 11:44:27 -04:00
wpferguson
8f6c2c82d3 Merge pull request #345 from wpferguson/sm_git_branch_pattern_matching
Solution to pattern matching current git directory
2021-07-06 00:49:04 -04:00
Bill Ferguson
a6d5001e84 [script_manager] set logging to error 2021-07-06 00:46:21 -04:00
Bill Ferguson
6af180a313 [script_manager] after numerous attempts to solve this with just pattern
matching I realized the lack of conditionals made it
                 impossible to solve in that manner, so I resorted to
                 splitting the output into lines and testing each line.
2021-07-06 00:42:55 -04:00
wpferguson
86cc22d943 Merge pull request #344 from wpferguson/sm_fix_current_branch_not_detected
[script_manager] fix current branch not detected
2021-07-05 23:25:00 -04:00
Bill Ferguson
c1fbfd80d4 [script_manager] fix current branch not detected 2021-07-05 23:24:19 -04:00
wpferguson
040a83fb17 Merge pull request #343 from wpferguson/sm_i18n_git_fix
script_manager: fix i18n git integration
2021-07-05 23:05:46 -04:00
Bill Ferguson
2bc23a1446 [script_manager] fixed log message and reset log level for production 2021-07-05 23:01:30 -04:00
Bill Ferguson
97f4c911ed [script_manager] modified dirty repo test 2021-07-05 22:55:30 -04:00
Bill Ferguson
53d9a42a1a [script_manager] modified git interface to not rely on locale 2021-07-05 22:49:39 -04:00
wpferguson
c96c5234c4 Merge pull request #342 from wpferguson/sm_fix_no_current_branch
Script Manager crash on no current branch
2021-07-05 15:15:25 -04:00
Bill Ferguson
9a3eb7bc3e [script_manager] added check for nil current branch and dumped repo_data 2021-07-05 15:13:56 -04:00
Bill Ferguson
53f15ba8b8 [color_profile_manager] created color_profile_manager to manage the
darktable input and output color profiles
2021-07-02 21:51:20 -04:00
wpferguson
ecdc74b5a6 Merge pull request #340 from wpferguson/script_manager_final_bug_fix
Script manager final bug fix
2021-07-02 21:35:16 -04:00
Bill Ferguson
422fdbe2cf [script_manager] make sure we have branches before comparing 2021-07-02 21:33:50 -04:00
Bill Ferguson
887bc03f32 bug 2021-07-02 21:29:36 -04:00
Bill Ferguson
e32c0c70a8 bug 2021-07-02 21:28:26 -04:00
Bill Ferguson
440dfcadfd bug 2021-07-02 21:26:45 -04:00
Bill Ferguson
93cc0adb39 bug 2021-07-02 21:25:36 -04:00
Bill Ferguson
f8ec85ddae bug 2021-07-02 21:22:43 -04:00
wpferguson
688333f756 Merge pull request #339 from wpferguson/script_manager_no_branch_bugfix
[script_manager] handle the case where no branches are detected
2021-07-02 21:14:50 -04:00
Bill Ferguson
8f314059e4 [script_manager] handle the case where no branches are detected 2021-07-02 21:13:33 -04:00
wpferguson
9386a08af0 Merge pull request #338 from wpferguson/script_manager_noise
Stop script_manager "noise"
2021-07-02 20:30:32 -04:00
Bill Ferguson
19cd118f8f [script_manager] converted dt.print_log statements to log.msg with the appropriate level 2021-07-02 20:28:48 -04:00
Bill Ferguson
c196f98bc6 [ChangeLog.md] fixed formatting 2021-07-01 21:51:26 -04:00
Bill Ferguson
56ec258cc7 [script_manager] Added API awareness so that the correct version of
scripts that match the API version of darktable are
                 used.

[Changelog.md]   Updated the change log with the latest changes.
2021-07-01 21:45:38 -04:00
Bill Ferguson
5da64a7da0 [API 7.0.0 compatibility] Made changes to take advantage of the latest API changes
including the ability to start and stop most scripts.
2021-06-19 23:34:14 -04:00
wpferguson
f272aeb9fe Merge pull request #335 from wpferguson/revert-dt35-api-changes
Revert API 6.1+ compatibility changes.  Partially fixes #334
2021-06-19 16:38:36 -04:00
wpferguson
cf26b82d87 Merge pull request #336 from wpferguson/312_image_path_in_ui
Fix 312 - change case of image_path_in_ui module label
2021-06-19 14:01:46 -04:00
Bill Ferguson
2041fb34c9 [image_path_in_ui] changed case of module title to respect darktable
UI.
2021-06-19 13:57:39 -04:00
Bill Ferguson
4b63240ab9 Reverted register_event calls back to API 6.1.0 2021-06-11 21:44:38 -04:00
Bill Ferguson
9d59479049 Revert changes to accomadate API changes greater than 6.1 2021-06-11 19:47:43 -04:00
wpferguson
350cdfa436 Merge pull request #333 from wpferguson/fix_quicktag
Fix contrib/quicktag
2021-06-02 23:44:26 -04:00
Bill Ferguson
15de64dcf5 [contrib/quicktag] changed new entry field is_password setting to false
so that the user can see what they are typing.
2021-06-02 23:41:02 -04:00
wpferguson
d9c2519a83 Merge pull request #331 from wpferguson/fix_HDRmerge
Fix HDRmerge
2021-03-21 23:34:14 -04:00
wpferguson
9885e34f82 [Changelog] Added latest changes 2021-03-20 00:01:44 -04:00
wpferguson
ed0adfbae1 [Changelog] Added latest changes 2021-03-20 00:01:25 -04:00
wpferguson
beafb6c21b [HDRmerge] fixed crash resulting users renaming images from
camera default.

           Minor code cleanup
2021-03-19 23:52:28 -04:00
supertobi
7810791991 Merge pull request #330 from scheckmedia/master
photils plugin
2021-03-15 13:36:04 +01:00
Tobias Scheck
1d10d5234f refactore print method 2021-03-15 11:41:52 +01:00
Tobias Scheck
9900f46be4 add option to apply selected tags from a single image to multiple images (close #3); add setting parameter to enable/disable the export of an image before tag suggestion (close #5) 2021-03-15 11:36:37 +01:00
wpferguson
0d2c4dfb3a Merge pull request #329 from wpferguson/gimp_detached
GIMP run detached
2021-02-25 21:07:05 -05:00
wpferguson
752e27d97f Added detached mode to Edit with GIMP so that GIMP can keep running and accepting new images 2021-02-25 21:04:59 -05:00
wpferguson
33523fbe36 Merge pull request #328 from wpferguson/doc_updates
Update ChangeLog
2021-02-24 20:18:56 -05:00
wpferguson
db47dd5110 Update for Mark64/ext_editor_darkroom 2021-02-24 20:11:30 -05:00
wpferguson
a71097a8c9 Merge pull request #327 from Mark-64/ext_editor_darkroom
External editors: make gui visible in darkroom
2021-02-24 20:02:30 -05:00
U-DESKTOP-HQME86J\marco
931e448ebd more compact code 2021-02-24 19:21:32 +01:00
U-DESKTOP-HQME86J\marco
abd8bf4a60 option to display module in darkroom 2021-02-24 14:14:38 +01:00
U-DESKTOP-HQME86J\marco
aee1f82d04 restore current module registration 2021-02-23 07:40:30 +01:00
U-DESKTOP-HQME86J\marco
8112472df5 restore initialization line deleted by mistake 2021-02-22 08:17:46 +01:00
U-DESKTOP-HQME86J\marco
c9fa13b97b revert MAX_EDITORS to 9 2021-02-21 20:59:30 +01:00
U-DESKTOP-HQME86J\marco
73cd301ff4 ext_editor visible in darkroom 2021-02-21 20:55:23 +01:00
wpferguson
aa33ae0706 Merge pull request #325 from wpferguson/doc_updates
Update documentation
2021-02-19 17:30:13 -05:00
wpferguson
4e9c45c162 Updated README.md with links to the lua documentation. Added fujifilm_dynamic_range script to contrib. Added ChangeLog.md to keep track of recent changes. 2021-02-19 17:17:53 -05:00
wpferguson
f35cea75d3 Merge pull request #324 from wpferguson/API_6_2_3_register_action_changes
API 6.2.3 compatibility
2021-02-17 22:30:35 -05:00
wpferguson
4053ceb9e5 [API 6.2.3] Added changes for API 6.2.3 compatibility 2021-02-17 22:24:02 -05:00
wpferguson
448da35327 Merge pull request #322 from wpferguson/bugfix_select_untagged
fix select_untagged
2021-02-10 14:53:43 -05:00
wpferguson
6d9c4c90ba Used image table returned to callback, and returned selection table to caller so that it could do the selection. 2021-02-10 14:52:03 -05:00
wpferguson
5b8282e933 Merge pull request #321 from wpferguson/fix_6_2_1
Fix API 6.2.1 transition
2021-02-10 00:21:20 -05:00
wpferguson
b1498aa664 inline if didn't work. Added intermediate register_event function in transition library 2021-02-10 00:18:48 -05:00
wpferguson
2b28f021ee Merge pull request #320 from wpferguson/fix_6_2_2
fix API 6.2.2 compatibility
2021-02-09 23:38:56 -05:00
wpferguson
dc4938c377 inline if didn't work. Replaced with full if/else 2021-02-09 23:36:54 -05:00
wpferguson
69b846a856 Merge pull request #319 from wpferguson/api_6_2_2_register_selection
API 6.2.2 compatibility
2021-02-04 23:07:56 -05:00
wpferguson
1460396d4f [contrib/select_untagged] Added check for API 6.2.2 and added name
field to register_selection if it is
2021-02-04 23:04:21 -05:00
wpferguson
b9804d9d48 Merge pull request #318 from wpferguson/api_6_2_1_lua_event_changes
Added compatibility for lua events API change 6.2.1.
2021-02-01 18:31:19 -05:00
wpferguson
ade7008127 Added compatibility for lua events API change 6.2.1. 2021-02-01 18:27:20 -05:00
wpferguson
da0235ab27 Merge pull request #317 from wpferguson/correct_api_version
[dtutils] fixed api version check
2021-01-21 21:36:36 -05:00
wpferguson
c17e832572 [dtutils] fixed api version check 2021-01-21 21:34:43 -05:00
wpferguson
c12d6f01e7 Merge pull request #316 from wpferguson/add_database_get_image_to_find_by_image_id
add database.get_image() to dutils.find_image_by_id()
2021-01-21 21:26:08 -05:00
wpferguson
778ad2ce20 [dtutils] added database.get_image() to find_image_by_id() for users with lua API 6.2.0 or greater 2021-01-21 21:20:17 -05:00
wpferguson
33ef58ac97 Merge pull request #315 from schwerdf/master
New utility function for random image access by ID.
2021-01-19 17:37:23 -05:00
wpferguson
8091ba9398 Merge pull request #313 from chrisaga/master
copy_attach_detachtags.lua localization proposal
2021-01-19 14:20:09 -05:00
August Schwerdfeger
8e0bf9e991 Corrected names in documentation of 'find_image_by_id'. 2021-01-19 01:34:36 -06:00
August Schwerdfeger
daee82aa6a Added a new utility function to look up an image in the database by ID. 2021-01-19 01:05:50 -06:00
chrisaga
359a1fa3a9 As discussed, localize module name in GUI 2021-01-10 19:54:10 +01:00
wpferguson
021b32c1d4 Merge pull request #314 from dtorop/fujifilm-dynamic-range
Fujifilm dynamic range
2021-01-07 23:38:11 -05:00
Dan Torop
1d1eb6a768 fujifilm-dynamic-range: remove translations, use full exiftool path
Suggestions as per @wpferguson:

"We came to a decision a while ago to not translate debug
messages(i.e. print_log() and print_error()) because the author might
not be able to read the output if it was a language they weren't
familiar with. So the only thing we translate are labels, tooltips,
and dt.print() messages."

"df.check_if_bin_exists() returns the full path to the
executable. Using the returned value would let the script run on
windows and macos too."
2021-01-07 22:55:55 -05:00
Dan Torop
a9fd0718b0 fujifilm-dynamic-range: skip non-Fuji non-raws and clean-ups
Don't bother to pull EXIF data unless the imported image is a Fujifilm
raw.

Cleanup conditionals for error handling by immediately returning on
failure, avoiding deep nested conditionals.

Cleanup log/error output with clearer messages.
2021-01-06 11:21:05 -05:00
Dan Torop
6341a0a459 fujifilm-dynamic-range: better logging and error handling
Use dt.print_log() for log messages. Print error output if no results
or results not parseable from exiftool.

Also update the date, it's 2021.
2021-01-06 10:28:52 -05:00
Dan Torop
952b8b2eb2 fujifilm-dynamic-range: better exiftool parsing & comments
Get tab-delimited output from exiftool without rounding.  Add comments
to explain the choice of tags being read and tool to read them.
2021-01-06 10:11:59 -05:00
Dan Torop
b08d7f27d2 fujifilm_dynamic_range : first draft
Read RawExposureBias and adjust "EXIF Exposure Bias" based upon this.
2021-01-05 22:38:27 -05:00
chrisaga
a71889021f add copy_attach_detachtags.po header 2021-01-03 21:02:25 +01:00
chrisaga
367631af99 copy_attach_detachtags.lua localization 2021-01-03 20:55:45 +01:00
wpferguson
62753d1a50 Merge pull request #309 from chrisaga/master
script_manager.lua function clear_button reset tooltip
2020-12-29 11:12:26 -05:00
chrisaga
dfe589e843 script_manager.lua function clear_button must reset tooltip too 2020-12-28 19:18:35 +01:00
wpferguson
d09574bb17 Merge pull request #308 from chrisaga/master
script_manager.lua localization proposal (including minor changes in …
2020-12-28 12:50:14 -05:00
chrisaga
2be12e5b37 script_manager.lua localization proposal (including minor changes in the script) 2020-12-28 10:42:15 +01:00
wpferguson
d2086b6480 Merge pull request #307 from chrisaga/master
More clear_GPS.lua localization
2020-12-27 20:40:09 -05:00
chrisaga
132668d04c More clear_GPS.lua localization 2020-12-27 18:22:19 +01:00
wpferguson
0a4aa95965 Merge pull request #306 from chrisaga/localize-copy_paste_metadata.lua
Localize copy paste metadata.lua
2020-12-26 17:18:21 -05:00
wpferguson
af1e774d1f Merge pull request #305 from chrisaga/patch-1
Update clear_GPS.lua
2020-12-26 17:16:45 -05:00
chrisaga
e5271d79a0 Localize copy_paste_metadata.lua 2020-12-26 13:27:53 +01:00
chrisaga
dfd714540e fr po-file for copy_paste_metadata 2020-12-26 13:21:00 +01:00
chrisaga
a0fd22be19 Update clear_GPS.lua
Changed first line of header which was referring to another plugin (gimp.lua)
2020-12-26 12:08:38 +01:00
wpferguson
c0dc55b18e Merge pull request #303 from wpferguson/script_manager_3.4
Merry Christmas aka new script manager
2020-12-24 09:56:22 -05:00
wpferguson
258def1cf8 Merge pull request #304 from wpferguson/logging_cleanup
Reduce the amount of trace information in log messages.
2020-12-24 09:55:24 -05:00
wpferguson
b2095fd947 Merge pull request #299 from wpferguson/fix_check_if_bin_exists_and_executable_paths
Fix check if bin exists and executable paths
2020-12-24 09:54:52 -05:00
wpferguson
e51278f76e Merge branch 'master' into fix_check_if_bin_exists_and_executable_paths 2020-12-24 09:54:29 -05:00
wpferguson
9af60063d8 [dtutils.log] changed the amount of trace information based on log level.
script, caller, line number, msg were printed for all log
              levels, but changed to return less info except in log.debug
              log.error, and log.critical messages.  All messages print
              the script name except for log.screen.
2020-12-23 22:52:46 -05:00
wpferguson
37b523f989 [script_manager] rewrite of script_manager for a better fit with
darktable 3.4 and the new scripts_installer. Changed
                 interface to paged instead of scrolled so that less
                 screen space is required.  Added capability to
                 install/update external repositories and seamlessly
                 integrate with script_manager.
2020-12-23 19:54:16 -05:00
wpferguson
96ba075e86 Removed debugging statement 2020-12-22 22:00:41 -05:00
Bill Ferguson
e86a3a3236 [file.lua] removed debugging statement 2020-12-18 11:08:12 -05:00
wpferguson
622a9ebab4 Merge pull request #301 from pitbuster/master
Sanitize filename in fujifilm_ratings.lua to handle spaces.
2020-12-14 00:07:28 -05:00
Felipe Contreras
b26ec58f9f Sanitize filename in fujifilm_ratings.lua to handle spaces. 2020-12-13 22:00:39 -03:00
Bill Ferguson
b41b2a1566 [file.lua] Added create_tmp_file() back in. 2020-11-30 21:51:55 -05:00
Bill Ferguson
b893383353 [file.lua] Added comments for local functions. Added more API
documentation for check_if_bin_exists.  Added save
           executable path preference to _search_for_nix_bin()
           so that we can save a little time on subsequent runs
           once an executable is found.
2020-11-30 21:06:57 -05:00
Bill Ferguson
ddcf3ed3f4 [file.lua] fixed line trimming in macos search for bin 2020-11-29 18:41:32 -05:00
Bill Ferguson
da05748393 [file.lua] combined the is_ functions into file_test() which allows
testing to see if a path exists, is a dir, is a file, or
	   is executable.  Added case insensitive search to the
           windows search for bin.
2020-11-29 18:00:47 -05:00
wpferguson
976ad4ab17 Merge pull request #297 from wpferguson/remove_yield
Remove official/yield.lua
2020-11-26 19:08:57 -05:00
wpferguson
8dcf19834c Merge pull request #298 from wpferguson/add_sanitize_decimals_to_enfuseAdvanced
Add sanitize_decimals() to enfuseAdvanced
2020-11-25 19:42:25 -05:00
Bill Ferguson
43315bb9cc [enfuseAdvanced] added a sanitize_decimals function to sanitize the command lines. 2020-11-25 19:39:49 -05:00
Bill Ferguson
4ab20d8088 Removed official/yield.lua since it was only required for lua API 3.x and less (darktable 2.0 and before). Removed require from scripts that had included it. 2020-11-21 18:33:26 -05:00
wpferguson
485de32bb4 Merge pull request #294 from wpferguson/fix_enfuseAdvanced_decimal_separator
fix enfuseAdvanced crash on comma decimal separator
2020-11-19 00:38:06 -05:00
Bill Ferguson
536b9726b2 [enfuseAdvanced] Added check for comma decimal separator. Replace with period if found. 2020-11-19 00:35:17 -05:00
wpferguson
41ae43e741 Merge pull request #293 from wpferguson/fix_multi_os_crash
Fix multi_os crash
2020-11-17 19:05:23 -05:00
Bill Ferguson
b5b49245fa Needlessly creating the executable path preference for the ufraw-batch executable on linux caused the value to be saved as the startup directory, which in turn caused a crash when trying to extract the embedded jpg. 2020-11-17 18:53:54 -05:00
wpferguson
d172ac7049 Merge pull request #290 from wpferguson/get_enfusedAdvanced_running
Fix translation in enfuseAdvanced
2020-09-16 00:10:23 -04:00
Bill Ferguson
8808306a5f [contrib/enfusedAdvanced.lua] _ was declared globally in a subroutine, thus negating translation once the subroutine was called. 2020-09-16 00:05:53 -04:00
wpferguson
00dac577f6 Merge pull request #289 from wpferguson/fix_enfuseAdvanced_print_error
fix print errors in enfuseAdvanced - this takes care of the current last comment in #186
2020-09-14 20:56:10 -04:00
Bill Ferguson
85c218b350 [contrib/enfuseAdvanced] fixed translations in for loops by changing the unused variable _ to x so that the translation function _() doesn't get replaced with the value of _. 2020-09-14 20:47:29 -04:00
supertobi
6f71ef4d6b Merge pull request #288 from homer3018/patch-1
Typo
2020-09-11 16:04:19 +02:00
homer3018
394cbdb454 Typo 2020-09-11 00:05:22 +02:00
supertobi
62e2a7969d Merge pull request #287 from darktable-org/supertobi-patch-1
README - suggested update #286 by heviiguy
2020-09-06 20:13:28 +02:00
supertobi
d9c284b54d Update README.md
README - suggested update #286
2020-09-06 20:01:34 +02:00
wpferguson
bd2bc3659c Merge pull request #284 from wpferguson/update_install_instructions
Update README.md
2020-08-23 00:40:49 -04:00
Bill Ferguson
f76fa01240 Updated install instructions adding flatpak information and updating preferred way to enable and disable scripts. 2020-08-18 12:08:23 -04:00
wpferguson
45d62f418c Merge pull request #283 from wpferguson/script_manager_collapsible
script_manager resizes smaller
2020-08-16 15:59:06 -04:00
Bill Ferguson
650325257b made button a local variable 2020-08-16 15:57:41 -04:00
Bill Ferguson
a0a8a61d56 Enabled latest dev changes in lua API so that script_manager responds better to panel resizing 2020-08-16 15:52:57 -04:00
wpferguson
998732287b Merge pull request #282 from wpferguson/change_name_to_id
Fix script_manager not starting (and any other register_lib module)
2020-08-16 13:21:48 -04:00
Bill Ferguson
509c7da384 changed darktable.current_view().name to darktable.current_view().id for view check because name is translated and id is not. 2020-08-16 13:18:27 -04:00
wpferguson
771e03ce76 Merge pull request #279 from wpferguson/278_fix_register_lib_hang
278 fix register lib hang
2020-08-14 20:23:54 -04:00
supertobi
7d9b8dbdda Update video_ffmpeg.lua
added more framerate options
2020-08-10 15:21:25 +02:00
Bill Ferguson
912ae93d10 Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-09 01:56:48 -04:00
Bill Ferguson
b613cc266a Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-09 01:56:38 -04:00
Bill Ferguson
dfb8d4e7c6 Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-09 01:48:36 -04:00
Bill Ferguson
b8e3ec4302 Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-09 01:43:31 -04:00
Bill Ferguson
d4e21b7877 Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-09 01:43:20 -04:00
Bill Ferguson
d10cf968f1 Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-09 01:33:09 -04:00
Bill Ferguson
880ec7fc58 Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-09 01:26:45 -04:00
Bill Ferguson
432b6b5dd7 Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-09 01:21:17 -04:00
Bill Ferguson
5f5ad426bf Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-09 01:01:33 -04:00
Bill Ferguson
52acdb9036 Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-09 00:45:27 -04:00
Bill Ferguson
138b23674a Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-09 00:36:43 -04:00
Bill Ferguson
8a710798f7 Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-09 00:17:34 -04:00
Bill Ferguson
be5557080b Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-08 23:38:48 -04:00
Bill Ferguson
994b9c6472 Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-08 23:28:50 -04:00
Bill Ferguson
d05536bed4 Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-08 23:21:54 -04:00
Bill Ferguson
cc4f1d7251 Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-08 23:11:33 -04:00
Bill Ferguson
2ddd0965cd Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-08 22:40:54 -04:00
Bill Ferguson
4e68e420cc removed debugging print statemant 2020-08-08 22:40:40 -04:00
Bill Ferguson
50be8a9240 Added check to ensure we are in lighttable view prior to callling darktable.register_lib. If darktable was invoked in single image (darkroom) mode, then an event handler is registered to detect the change from darkroom mode to lighttable mode so that we can then call darktable.register_lib. 2020-08-08 22:11:29 -04:00
Bill Ferguson
d1e330eee0 Added check to ensure we are in lighttable view prior to callling
darktable.register_lib.  If darktable was invoked in single
image (darkroom) mode, then an event handler is registered to
detect the change from darkroom mode to lighttable mode so that
we can then call darktable.register_lib.
2020-08-08 22:01:58 -04:00
supertobi
6aa5893b5f Merge pull request #277 from wpferguson/update_readme
Update README.md
2020-08-04 21:32:43 +02:00
Bill Ferguson
797d668ebb Fixed typo 2020-08-04 11:11:41 -04:00
Bill Ferguson
b23595ff54 Added latest scripts 2020-08-03 18:52:28 -04:00
Bill Ferguson
7790c9700b Separated check_if_bin_exists() into 2 functions, one to check the returned
executable_path variable and another to search for the binary if it
wasn't detected.  All results are checked to ensure they exist, are
a file, and are executable.  This fixes the situation where a directory
gets stored as an executable path. Search functions are operating system
specific.  Executable paths are saved for MacOS and Windows to make for
shorter searches in the future.
2020-08-02 18:33:49 -04:00
wpferguson
6903f8385b Merge pull request #267 from wpferguson/image_time
Image time
2020-08-02 17:36:24 -04:00
wpferguson
e8205c6435 Merge pull request #276 from wpferguson/executable_manager_feedback
executable_manager provide feedback
2020-08-02 17:35:03 -04:00
Bill Ferguson
1d5192a39c removed duplpicate copies of the is_ functions 2020-07-21 20:40:22 -04:00
Bill Ferguson
04525e1258 Added functions is_file(path), is_dir(path, and is_executable(path) to
ensure a path is a file, directory, or executable respectively.  Replaced
code in check_if_bin_exists with these functions to reduce the lines of code
and make it more understandable.
2020-07-21 16:39:34 -04:00
wpferguson
c114856699 Merge pull request #275 from camjc/patch-1
Typo in README
2020-07-19 15:39:58 -04:00
Bill Ferguson
57a9a8495c made newly added strings translatable 2020-07-19 15:38:08 -04:00
Bill Ferguson
53bb95e6fd Added entry widget to display the current setting, or a placeholder specifying what would or should happen depending on operating system to provide visual feedback. 2020-07-19 13:13:24 -04:00
Cameron Chamberlain
a40fe3099d Typo in README 2020-07-19 10:54:48 +10:00
wpferguson
8d38ea0cf2 Merge pull request #270 from Mark-64/RL_output_sharpen_doc
add doc comments to RL_output_sharpen
2020-07-05 20:51:14 -04:00
wpferguson
ac81c95f7e Merge pull request #271 from Mark-64/ext_editor_add_doc
add documentation comments to ext_editor
2020-07-05 20:50:14 -04:00
wpferguson
48b915b0b2 Merge pull request #247 from noahwc/exportlut
Add an exporthaldclut lighttable module
2020-07-05 20:48:22 -04:00
Noah
593917db9a Fix gettext implementation 2020-07-04 23:20:30 -07:00
U-DESKTOP-HQME86J\marco
2d49b49bec add doc comments to ext_editor 2020-07-04 10:45:59 +02:00
U-DESKTOP-HQME86J\marco
323c8b6845 add doc comments 2020-07-04 10:27:06 +02:00
Bill Ferguson
e5ab30006b Added reset function. Changed namespace to img_time. 2020-06-24 21:51:40 -04:00
Bill Ferguson
14b97cdbd9 Created image_time.lua to adjust non-destructively adjust image time. 2020-06-21 17:14:36 -04:00
wpferguson
8f0f0a5298 Merge pull request #265 from wpferguson/correct_OpenInExplorer_shortcut
Fix OpenInExplorer shortcut function call
2020-06-21 16:37:27 -04:00
Bill Ferguson
497dbc8eaa Fixed function call arguments in shortcut. 2020-06-21 16:32:14 -04:00
wpferguson
11baf14280 Merge pull request #263 from wpferguson/preklov_OpenInExplorer_use_links
OpenInExplorer links option - This is @preklov's PR and he deserves the credit for the changes.  I just wasn't git ninja enough to figure out how to fix the problems, so I pulled it into a local branch and fixed it.
2020-06-20 15:02:42 -04:00
Bill Ferguson
948e8690dd Pulled preklov's branch, resolved conflicts, then merged into new branch with only 1 commit, essentially squashing the delete and replace file commits. 2020-06-20 14:49:31 -04:00
Noah
802c17d590 Added translated text 2020-06-16 01:59:43 -07:00
Noah
71e72b688f Exported luts now have folder hierarchy 2020-06-16 01:50:59 -07:00
supertobi
877b56ad67 Merge pull request #261 from scheckmedia/master
move function to create temp files to dtutils/file.lua
2020-06-15 14:08:03 +02:00
Tobias Scheck
87502fb17f move function to create temp files to dtutils/file.lua 2020-06-15 11:16:14 +02:00
supertobi
ed3e141601 Merge pull request #259 from GLLM/patch-1
Add the possibility to define a shortcut for OpenInExplorer LUA script
2020-06-15 10:33:30 +02:00
supertobi
f66d3ed3aa Merge pull request #236 from Mark-64/ext_editor_v4
Ext editor v4
2020-06-15 10:32:13 +02:00
supertobi
5488e45c78 Merge pull request #256 from scheckmedia/master
add photils plugin
2020-06-15 10:27:38 +02:00
Tobias Scheck
72bd66d3f5 add option to display confidence value, add notice that windows version is not available yet 2020-06-14 08:57:17 +02:00
Tobias Scheck
1378441dfa change labels to lower case to fit darktable style 2020-06-14 07:47:28 +02:00
GLLM
26d97b8cdf Update OpenInExplorer.lua
Add the possibility to define a shortcut for this LUA script.
2020-06-11 22:06:00 +02:00
Tobias Scheck
2e27b812d6 fix spelling 2020-06-10 14:48:27 +02:00
Tobias Scheck
fd97ac18da add comments for clarification; formatting 2020-06-10 14:48:18 +02:00
wpferguson
b9d14a2711 Merge pull request #257 from wpferguson/script_manager_sanitize
Bug Fix: script_manager can't process paths with lua special characters
2020-06-09 20:30:04 -04:00
Bill Ferguson
1c9042c496 Added a sanitize_lua function to the string library for sanitizing
strings of lua "magic" characters before using the string in a string
function that involves matching.

script_manager needs the path to the lua directory sanitized of lua
"magic" characters to prevent failure to extract the category and script
names.
2020-06-09 20:22:02 -04:00
Tobias Scheck
60fa4b9ee0 update description 2020-06-09 08:50:26 +02:00
Bill Ferguson
4c536b41bc checkpoint 2020-06-08 12:45:49 -04:00
Tobias Scheck
33f91af1af add photils plugin 2020-06-06 12:39:26 +02:00
wpferguson
05d86e89da Merge pull request #255 from wpferguson/update_README.md
Update README.md
2020-05-30 20:18:21 -04:00
Bill Ferguson
a02176fc63 Added instructions for using script_manager.lua as the luarc file. 2020-05-30 20:12:39 -04:00
wpferguson
55ced3ecc7 Merge pull request #251 from wpferguson/fix_script_manager_scrolling
Make script manager scrollable.
2020-05-23 17:01:52 -04:00
Bill Ferguson
4a81b560f9 Changed position of script manager to the center section of the left
panel at the bottom of the section.  This takes care of the problem
of darktable exceeding the vertical screen size and not being
scrollable.
2020-05-23 16:54:24 -04:00
wpferguson
6a7cd31ab4 Merge pull request #249 from wpferguson/fix_moduleExample
Update examples/moduleExample.lua
2020-05-23 16:18:07 -04:00
wpferguson
2515db31d8 Merge pull request #250 from sbolten/enhance_face_recognition
face_recognition.lua: Added "People" category to tag routine
2020-05-09 23:13:38 -04:00
Stephan Bolten
54a66f9ab2 Category Tag default & no_person_found
1 - empty by default
2 - not added when no_person_found
2020-05-09 19:58:57 +02:00
Bill Ferguson
0856858e73 Updated comments to reflect current usage practices. Added/updated links to the online manual for each of the widgets. Added translation. Removed reference to api_major_version 6 2020-05-08 00:15:31 -04:00
Noah Clarke
23131a301b Fix include path 2020-05-07 12:15:31 -07:00
Noah
aef7363bee make 8bit not 16bit luts (extra depth uneeded) 2020-05-06 13:19:12 -07:00
Stephan Bolten
d579b257a8 Added "People" category to tag routine
Added field in GUI to provide "People" category


Changed label of tag category


Changed Tooltip
2020-05-06 18:57:50 +02:00
Noah
4455347930 Exporting luts now creates a job 2020-05-06 01:14:34 -07:00
Noah
5709cfebd4 Remove unneeded API check 2020-05-05 00:02:47 -07:00
Noah
01184bee72 Updated API version check and forced PNG to 16 bits 2020-05-04 23:58:52 -07:00
wpferguson
8a8f6338c5 Merge pull request #243 from piterdias/master
Fixes face_recognition.lua failing to run in a fresh installation of darktable and adds some more logs
2020-04-27 15:05:14 -04:00
Piter Dias
71207e8f57 1 - face_recognition.lua fails to run in a fresh installation of darktable. It is due to pull request #221 where reset_preferences() and save_preferences() are called before being defined. This is actually a expected behavior because compiles script is one pass instead of two pass (like some other languages, like C). Moving a small piece of preferences setting code to the end of file solves the issue, because all required objects and functions are defined at that point.
2 - Add some more logs
2020-04-25 19:57:14 -03:00
supertobi
749f5b8e8f Merge pull request #240 from preklov/patch-2
German translation of OpenInExplorer.lua
2020-04-21 13:15:34 +02:00
wpferguson
88c1be09c2 Merge pull request #239 from preklov/master
Enabled macOS Finder in OpenInExplorer.lua
2020-04-20 13:55:51 -04:00
preklov
c1b59256be Add files via upload
The translation of the finished version of OpenInExplorer.lua
2020-04-20 16:14:32 +02:00
preklov
a3f57665a9 Delete OpenInExplorer.po 2020-04-20 16:13:05 +02:00
preklov
b8d29ca831 Add files via upload
The new and I hope the finished version for now.
2020-04-20 16:06:38 +02:00
preklov
90880ff4d1 Delete OpenInExplorer.lua 2020-04-20 16:03:25 +02:00
Noah
286ef77663 Some error checking and warnings 2020-04-19 00:36:47 -07:00
wpferguson
0bb8b72183 Merge pull request #241 from piterdias/face_recognition
Solve stability and performance issues on face_recognition.lua
2020-04-17 15:31:05 -04:00
Noah
28b9073010 Code and UI cleanup 2020-04-16 23:42:51 -07:00
Noah
fe97e29654 Working? version 2020-04-16 22:59:33 -07:00
Noah
792e782e8c basic frontend 2020-04-16 22:27:57 -07:00
Noah
33b99a97e4 initial module minus style picker 2020-04-16 17:51:09 -07:00
preklov
91ab85c825 Update OpenInExplorer.lua 2020-04-16 14:07:41 +02:00
Piter Dias
8c75b9316d Rollback some indentation changes 2020-04-16 01:46:45 -03:00
Piter Dias
9870ddbe86 face_recognition.lua script face some stability and performance issues on an i5-6600, 32 GB and GTX 1060 6GB:
1. Taking to much time – almost a day for 3000 images
    2. Crashing due to lines malformation in facerecognition.txt – some times face_recognition Python script concatenates two output lines in just once, what is not expected by face_recognition.lua script
    3. Crashing the whole system in Linux – I keep receiving “bash: fork: resource temporarily unavailable” trying to process a too big (starting from some hundreds) image list. Some other applications starts to crash at this point. It seems related to the attach tag call because commenting this instruction (for debugging purposes) eliminates the crashes.
After debugging the Lua script and checking Lua and SQL darktable out logs, I decided to make the following changes:
    1. Remove an inner loop in the processing results step – helps preventing issue 1
    2. Remove a loop in the export step – helps preventing issue 1
    3. Remove duplicate tags (when there are more more than a reference face for each person) while facerecognition.txt is read – helps preventing issue 1 and 3
    4. Make a sanity check with processing images, skip any malformation data – helps preventing issue 2
    5. Reduces the sqlite access by caching tags that where already created for a previous image – helps preventing issue 3

Those changes allowed may thousands (more than 30K) of images to be processed in half a day instead of several days.
2020-04-15 14:03:58 -03:00
supertobi
c7eb101920 Updated the "USAGE" section in the header of enfuseAdvanced.lua 2020-04-15 17:42:42 +02:00
preklov
2b171aef7c German translation of OpenInExplorer.lua 2020-04-14 19:33:54 +02:00
preklov
ec0fe0b047 Rename OpenInExplorer.lua to contrib/OpenInExplorer.lua 2020-04-14 16:15:45 +02:00
preklov
bbfa81f051 Add files via upload 2020-04-14 15:46:41 +02:00
preklov
bd5bef279c Delete OpenInExplorer.lua 2020-04-14 15:36:48 +02:00
preklov
afa95d5d34 Update OpenInExplorer.lua 2020-04-14 15:26:28 +02:00
preklov
fb331710e1 Add files via upload 2020-04-14 15:07:22 +02:00
preklov
224dce1b76 Delete OpenInExplorer.lua 2020-04-14 15:04:31 +02:00
wpferguson
a582f0229f Merge pull request #231 from Mark-64/RL_out_sharp
Add RL output sharpening script
2020-03-22 14:53:26 -04:00
U-DESKTOP-HQME86J\marco
a8e5a9b453 default no. of editors 2020-03-22 17:55:15 +01:00
U-DESKTOP-HQME86J\marco
2d69536489 fixes and code cleaning 2020-03-22 17:50:51 +01:00
U-DESKTOP-HQME86J\marco
ebd33c4c16 changed default sigma 2020-03-22 17:21:30 +01:00
wpferguson
3f5cf06bd9 Merge pull request #230 from Mark-64/fix_lib
Sanitize filepath before checking for its existance in Windows (fix #229)
2020-03-21 20:58:49 -04:00
wpferguson
1ec9cfb772 Merge pull request #234 from schwerdf/master
New script: 'transfer_hierarchy'.
2020-03-16 11:10:06 -04:00
August Schwerdfeger
050175802f Repositioned the 'transfer hierarchy' module below 'select' and 'selected image[s]'; added a translatability layer for strings; corrected behavior in the case of images with multiple versions. 2020-03-15 22:39:07 -05:00
August Schwerdfeger
19a1be1f74 Corrected a variable name. 2020-03-14 00:28:53 -05:00
August Schwerdfeger
093593dcef New script: 'transfer_hierarchy'. 2020-03-13 23:49:24 -05:00
U-DESKTOP-HQME86J\marco
51f28a386b requested modifications 2020-03-11 16:53:55 +01:00
U-DESKTOP-HQME86J\marco
4065bd5e11 test for GMIc executable 2020-03-10 21:21:41 +01:00
U-DESKTOP-HQME86J\marco
3e1746fc6e changed min API version 2020-03-10 20:34:13 +01:00
U-DESKTOP-HQME86J\marco
3b6dd856aa Add RL output sharpening script 2020-03-10 12:54:53 +01:00
U-DESKTOP-HQME86J\marco
635ea3f231 fix #229 2020-03-07 08:57:03 +01:00
wpferguson
48d1c62fed Merge pull request #227 from j3ffrw/master
enfuse output filename and blend colorspace
2020-03-02 11:55:27 -05:00
jefffermo@gmail.com
e97f2f3fc6 * make enfuse output file unique(fairly)
* add option --blend-colorspace of situation like this https://monochrome.sutic.nu/2019/06/18/enblend-4.2-color-space-blending-bug.html
2020-02-27 13:26:37 +08:00
supertobi
19b016a3dd Merge pull request #225 from Mark-64/ext_editor_v3
allow more than 9 editors
2020-02-09 20:14:25 +01:00
Marco
576e160372 Merge branch 'master' into ext_editor_v3 2020-02-07 21:26:47 +01:00
U-DESKTOP-HQME86J\marco
e586e0479d allow more that 9 editors 2020-02-07 21:13:19 +01:00
supertobi
0b5c866df6 Merge pull request #223 from wpferguson/remove_include_all
Remove include_all.lua
2020-01-29 09:23:17 +01:00
wpferguson
9828fb3934 Merge pull request #224 from wpferguson/readme_update
Update README.md
2020-01-28 14:16:52 -05:00
Bill Ferguson
430f443916 Added Stefan Klinger's darktable lua scripts repository 2020-01-28 14:14:47 -05:00
Bill Ferguson
d32e0eb5ab Removed include_all.lua since we now run cross platform and not all scripts run on all operating systems. 2020-01-28 12:11:33 -05:00
wpferguson
f72750576f Merge pull request #221 from piterdias/face_recognition_no_persons_found
Add "no persons found" entry and other enhancements
2020-01-27 17:51:52 -05:00
Piter Dias
e96b78b175 Add reset callback to face recognition widget and show the default values in the GUI. 2020-01-27 17:44:49 -03:00
Piter Dias
4708110804 1. Add "no persons found" entry for the situations that no persons are
detected in the photos
2. Check if the tags to applied are non empty and skip otherwise. It
applies to empty entries in the GUI ("unknown person tag" and "no
persons found"), when the user types something and then deletes it
3. Change the string "togs of images to ignore" to "tags of images to
ignore"
2020-01-23 21:12:49 -03:00
wpferguson
2725b82543 Merge pull request #220 from wpferguson/face_recognition_fix
Fix face_recognition crash
2020-01-22 13:18:01 -05:00
Bill Ferguson
1eafae6c6f Add check for WARNING lines complaining about files with no faces in the faces directory 2020-01-22 13:15:14 -05:00
wpferguson
11e25a21fa Merge pull request #218 from schwerdf/master
Correct argument escaping in 'dtutils_string.sanitize'.
2020-01-22 12:27:20 -05:00
August Schwerdfeger
51eda4e755 Made Windows- and POSIX-specific sanitization functions local; moved the 'sanitize' functions after the 'is_not_sanitized' functions that they call. 2020-01-21 22:17:12 -06:00
August Schwerdfeger
847c39749d Corrected escaping of command-line arguments in the 'sanitize' and 'is_not_sanitized' functions. 2020-01-21 00:29:18 -06:00
wpferguson
cb0975fa69 Merge pull request #217 from wpferguson/library_issues
Fix embedded quotes in strings not sanitized
2020-01-19 23:21:44 -05:00
Bill Ferguson
5b977733b3 Rewrote sanitize and is_not_sanitized to handle strings with embedded operatings system quotes. Fixes #216. 2020-01-19 23:11:41 -05:00
supertobi
c3d13a9890 Merge pull request #215 from Mark-64/error_fix
New version of ext-editor
2020-01-19 20:40:07 +01:00
U-DESKTOP-HQME86J\marco
bc4c04f795 error fix 2020-01-18 12:45:58 +01:00
wpferguson
32d5240e5d Merge pull request #214 from wpferguson/enfuse_bin_check
enfuse official - added binary found check
2020-01-05 16:57:24 -05:00
Bill Ferguson
64f423f3d1 Added a check to ensure the enfuse executable is found. If the executable isn't found, throw an error, print messgaes, and refuse to load. 2020-01-05 15:33:53 -05:00
supertobi
18d0e974e4 Merge pull request #211 from Yvan-56/patch-1
Update face_recognition for tolerance and locales
2020-01-04 19:51:15 +01:00
supertobi
c259f2dc72 Merge pull request #207 from Mark-64/ext_editor_v2
contrib/ext_editor version 2
2020-01-04 19:45:17 +01:00
Yvan-56
5223fdf4ae Update face_recognition for tolerance and locales
When locales use comma for numeric decimal separator, tolerance argument is not passed correctly.
I propose to switch temporally to "C" locales before converting float tolerance to string to get a period decimal separator.
2020-01-04 16:18:46 +01:00
Marco
a4132bd9bc Merge branch 'master' into ext_editor_v2 2020-01-04 12:22:24 +01:00
U-DESKTOP-HQME86J\marco
bf8d147ca5 requeste changes 2020-01-02 19:09:19 +01:00
U-DESKTOP-HQME86J\marco
5116d645db further improvements 2020-01-01 19:27:41 +01:00
U-DESKTOP-HQME86J\marco
a2850cac6b contrib/ext_editor v2 2019-12-30 14:07:42 +01:00
supertobi
ffed4efdec Merge pull request #204 from Mark-64/ext_editor
Add ext_editor.lua to contrib
2019-12-25 22:07:45 +01:00
U-DESKTOP-HQME86J\marco
cfa71927de requested updates 2019-12-25 16:16:44 +01:00
U-DESKTOP-HQME86J\marco
5d7a60206e requested updates 2019-12-25 16:02:53 +01:00
wpferguson
3556fef5ed Merge pull request #205 from wpferguson/dt3.0_readme_updates
Updated README.md to reflect latest changes
2019-12-24 11:54:37 -05:00
Bill Ferguson
252965a5d9 Updated README.md to reflect latest changes 2019-12-24 11:52:56 -05:00
Bill Ferguson
a7a25c0798 Merge branch 'wpferguson-remove_video_mencoder' 2019-12-24 11:43:39 -05:00
Bill Ferguson
944087649f removed deprecated contrib/video_mencoder.lua 2019-12-24 11:43:01 -05:00
wpferguson
69c9db6dda Merge pull request #203 from wpferguson/dt30examples
DT 3.0 lua API change demonstration
2019-12-24 11:37:28 -05:00
wpferguson
f5e86a8d25 Merge pull request #147 from simon04/delete-mo
Delete compiled .mo files
2019-12-24 11:37:02 -05:00
U-DESKTOP-HQME86J\marco
6a89357b54 compatibility with Linux 2019-12-23 11:34:01 +01:00
U-DESKTOP-HQME86J\marco
64c8f8fc3e added darkroom mode 2019-12-22 21:08:32 +01:00
U-DESKTOP-HQME86J\marco
54ff56b021 added copy and edit button + code cleaning 2019-12-21 21:12:46 +01:00
U-DESKTOP-HQME86J\marco
3d3ad89fba Add ext_editor.lua to contrib 2019-12-20 23:00:57 +01:00
Bill Ferguson
7ee140c8c8 created 3 demonstration scripts of the dt3.0 lua API additions 2019-12-19 13:38:25 -05:00
wpferguson
8afd6ccee4 Merge pull request #202 from wpferguson/fix_libraries
fix libraries
2019-12-16 22:45:59 -05:00
Bill Ferguson
e427294ec1 fix library problems found during unit testing 2019-12-16 22:42:32 -05:00
wpferguson
18283ccbc6 Merge pull request #201 from darktable-org/revert-199-library_fixes
Revert "Library fixes"
2019-12-16 22:31:40 -05:00
wpferguson
b7857c8462 Revert "Library fixes" 2019-12-16 22:30:50 -05:00
wpferguson
2d231806d2 Merge pull request #199 from wpferguson/library_fixes
Library fixes
2019-12-16 21:46:14 -05:00
wpferguson
36b58333ca Merge pull request #200 from wpferguson/README_update
Update README.md
2019-12-16 21:40:26 -05:00
Bill Ferguson
fc77af598d Another update 2019-12-16 20:39:10 -05:00
Bill Ferguson
602295ae89 Updated contributed scripts 2019-12-16 20:27:20 -05:00
Bill Ferguson
1c295a88ac Fixed bugs found during unit testing with testing framework 2019-12-11 22:55:44 -05:00
wpferguson
232535faf9 Merge pull request #197 from wpferguson/update_face_recognition
Update face recognition
2019-12-09 20:19:24 -05:00
Bill Ferguson
10b5dee40f Added windows compatibility 2019-12-09 20:08:11 -05:00
Bill Ferguson
be48459092 Converted face_recognition to a module and updated it to use newer library functions. Added tolerance adjustment to settings to fine tune the face detection. 2019-12-08 20:18:07 -05:00
supertobi
cb6199c1a8 Merge pull request #100 from GHswitt/master
Storage plugin for face_recognition
2019-12-07 21:34:38 +01:00
supertobi
c9eb087ade Update README.md
The ' is not not needed in the windows cmd
2019-12-04 13:01:58 +01:00
supertobi
87e223a854 Update README.md
Added: If you don't have %LOCALAPPDATA%\darktable you have to start dartable at least once, because the directory is created at the first start of darktable.
2019-12-04 12:52:44 +01:00
wpferguson
7c7118dfad Merge pull request #193 from simon04/patch-1
README: list various third-party projects
2019-11-10 00:33:39 -05:00
Simon Legner
fdcd6c6dfe README: list various third-party projects 2019-11-04 21:42:15 +01:00
Bill Ferguson
205cbcf05d Checkpoint save 2019-07-03 12:41:58 -04:00
wpferguson
c9ccbb2750 Merge pull request #189 from wpferguson/remove_plugin_manager_symlink
Removed symlink for plugin_manager development
2019-06-19 11:25:32 -04:00
Bill Ferguson
eacfc4b623 Removed symlink for plugin_manager development 2019-06-19 11:23:11 -04:00
supertobi
d3dafd4ce1 Merge pull request #179 from BzKevin/BzKevin-enfuseAdvanced-refactor
Refactored enfuseAdvanced
2019-05-07 15:56:06 +02:00
supertobi
8004b96c41 Merge branch 'master' into BzKevin-enfuseAdvanced-refactor 2019-05-07 15:54:12 +02:00
supertobi
7cc58d9fac Merge pull request #164 from BzKevin/BzKevin-HDRMerge
Add HDRMerge
2019-05-07 13:00:40 +02:00
BzKevin
f82ae6c091 Change 'Create Unique Filename' to default 2019-05-06 21:35:41 -04:00
wpferguson
6ab029e692 Merge pull request #178 from BzKevin/BzKevin-AutoGrouper
Add AutoGrouper
2019-05-06 15:38:10 -04:00
BzKevin
2c3536afc9 Changes requestd via PR
1) mod changed to MOD
2) autogroup changed to autogrouper
3) prints "please select at least 2 images" if user attempts to run with fewer than 2 images selected
4) change visible module name to "auto group" (lower case)
5) changed soft max on slider to 60s
         - I also increase the hard max up to a full day, I saw no reason not to
2019-05-06 10:49:30 -04:00
supertobi
0fe95e91d5 Merge pull request #185 from darktable-org/file.lua
file.lua copy for windows
2019-04-16 11:00:19 +02:00
supertobi
cadd98dc59 dtutils_file.file_copy: use the result 2019-04-16 10:58:32 +02:00
wpferguson
92f99c3780 Merge pull request #184 from darktable-org/dt_utils_system
On Windows we don't need anything to open a file
2019-04-16 00:03:12 -04:00
supertobi
f1d397f908 OpenInExplorer
Changed from nautilus to org.freedesktop.FileManager1, so it works with all file manager that support this dbus API.
2019-04-15 23:09:01 +02:00
supertobi
eeaa6b478b Merge pull request #171 from darktable-org/supertobi-patch-1
make kml_export multi OS
2019-04-15 21:35:03 +02:00
supertobi
53d6b54de8 Merge branch 'master' into supertobi-patch-1 2019-04-15 21:34:44 +02:00
supertobi
ffd6abbe95 Fixed bugs after Linux testing 2019-04-15 21:28:48 +02:00
supertobi
f08421a48c Update kml_export.lua
Fixed Windows problem
2019-04-15 15:55:22 +02:00
supertobi
a383d1ebf8 Update kml_export.lua
Works with Windows
2019-04-15 15:48:31 +02:00
supertobi
d355095e16 file.lua copy for windows 2019-04-15 15:27:53 +02:00
supertobi
a81d992552 On Windows we don't need anything to open a file
On Windows we don't need any command to open a file. 
And "start" has problems with spaces in the filename, even if we put quoter around them:
https://stackoverflow.com/questions/13691827/opening-file-with-spaces-in-windows-via-command-prompt
2019-04-15 14:27:17 +02:00
wpferguson
eb13518b96 Merge pull request #183 from wpferguson/executable_manager_fix
executable manager windows string spllit bug
2019-03-28 20:17:57 -04:00
Bill Ferguson
bf6e180291 Fixed bug that caused the lua executale path to not split correctly on windows. Preferences are stored internally with forward slashes, not O/S specific path separators. 2019-03-28 20:13:08 -04:00
BzKevin
fcad7a5733 Makte Translatable + others
Made text translatable except for line 499 which kept giving me problems
   Making L499 translatable would throw the following error   lua:499: attempt to call a nil value (upvalue '_')
   Troubleshooting steps taken and results:
        1) Changed the translation function from _() to translate() - this worked, no errors but ugly
        2) Reverted the changes from 1, then changed all "for _, var in table do" to be "for ignore, var in table do" - this did not help

Moved a chunk of code due to anomalous behavior, I suspect previous code was attempting to change the value in the stack widget before it was fully created. Adding in a print statement before trying to change the stack.active would cause things to work fine. Moving it behind the register call also helped.
2019-03-22 12:01:56 -04:00
BzKevin
7ffdf1631c Make text translatable 2019-03-22 09:05:11 -04:00
BzKevin
a5ad5e67f3 Remove executable preferences
The executable choosers have been moved to a box which is now element 4 in the GUI stack. Once the user configures these and presses update they are confirmed good or bad and the GUI changed to normal view if all works out.
2019-03-12 13:04:21 -04:00
BzKevin
4b3b1f7786 Fix bug when updating exe preference
Move the preference.write() call inside the for loop
2019-03-12 12:42:37 -04:00
BzKevin
844e89a652 Use file chooser to set executable path preference
previous commit failed to actually utilize the newly created file chooser to set the path preference
2019-03-12 12:25:37 -04:00
BzKevin
d88af9ffd9 Minor tweaks to last commit 2019-03-12 11:20:04 -04:00
BzKevin
7a3a9ba559 Removed preferences for exe
The GUI is now made of a stack which has two boxes in it. One box contains all the normal GUI elements, the other contains a file chooser button and a normal button to call an update routine. This box is only displayed if an issue is found. I decided to track the install status via a preference boolean, rather than calling df_check_if_bin_exists at startup every time. I do this because on my windows PC I was starting to get slow startups with too many scripts installed and many many flashing CMD windows at startup as well, which was a nuisance.
2019-03-12 11:19:22 -04:00
BzKevin
5d3910da49 Tab to Space 2019-03-05 09:14:28 -05:00
BzKevin
f740d34f1f Tab to Space 2019-03-05 09:12:54 -05:00
BzKevin
58ca70c511 Tab to Space 2019-03-05 09:11:28 -05:00
BzKevin
ee59540648 Refactored
I was having issue wit this script periodically. The original version of this was real a hack-job of Holger Klemms original. This new version utilizes tables in a manner that I hope will make the code easier to follow and understand, but also allows for certain functions to be re-used throughout (and potentially in different scripts as well). In general:

Each program (align image stack, enfuse, exiftool) how has a table that contains information about that program, this includes a sub-table that contains argument data for the program.
There is a GUI table which contains all gui elements. Those elements are split into sub-tables within GUI based on what aspect of the scrpt behavior they relate to (AIS, ENF, Target File, Presets, etc...)
These two structures (and the similarities between them) have allows me to create loops which populate the arguments from the GUI and vice-versa, this is all done through an intermediary preference, the "active" preference. 
Whenever a change to a GUI element occurs the associated member of hte active preference is updated. then when it becomes time to build an argument string for a program command the active preference is read from and the value contained within is used. This works fine for all GUI elements that have a "changed" or "clicked" callback, as they can remain up-to-date real time. Sliders and Entry boxes do not have this, so at a certain point withing the script the GUI values are read directly for these elements and written to the associated active preference field.

As you will see about 50% of this code is simply building all the GUI elements and making sure that the initialization value for that element is valid (via the InRange() function). The actual heart of the program and it's functions really only takes up about 300 lines (starting at 180 and going through 476). That is broken down into multiple fairly concise functions. Hopefully this makes maintenance, feature enhancement, and troubleshooting much easier in the future.

I also made a few UI tweaks. This script use to create such a massive list of GUI elements that it was a nuisance when actually using it. They are now grouped into three containers for AIS options, Enfuse options, and target options. Only one of these options containers is displayed at a time. Additionally, I removed all the registered preferences I had before, so now I only register 3 options to enable user to point towards the program binaries.
2019-03-04 13:13:49 -05:00
BzKevin
9e97b8f5a1 Added comments, made the gap inclusive
Added comments throughout
Change the gap comparison to be inclusive ( from '<' to '<=')
2019-03-04 12:47:52 -05:00
BzKevin
95968c3d95 Add AutoGrouper
Adds AutoGrouper script which allows the user to select multiple images (or an entire collection) and automatically group them based on timestamp. The separation between groups is user defined via a slider.
2019-03-04 12:20:55 -05:00
BzKevin
85c242ff0e Comments added, minor updates
I have added comments throughout, mainly to the functions
I improved the performance of the CleanSpaces() function
Improved communication to user via dt.print()
2019-03-04 09:45:05 -05:00
supertobi
18783e7ea5 kml_export fixed typo 2019-03-04 15:12:04 +01:00
BzKevin
7bc4846c0a Refactored
After experiencing some issues after upgrading to dt2.6 I decided it would be worthwhile to refactor the code for more reliable performance. Specifically the script would crash dt when attempting to apply a style on import and sometimes just fail to run. I have refactored this in a manor that should make it more logical for future users to add/maintain as applicable. 

Refactored script has only been tested on Windows 10 w/ dt2.6. Hopefullt all cross-platform aspects have been maintained.
2019-03-03 15:48:08 -05:00
supertobi
49c4406bb4 Update video_mencoder.lua
fix linebrakes
2019-03-03 17:41:04 +01:00
supertobi
fedf2229a7 Merge pull request #176 from darktable-org/supertobi-patch-OpenInExplorer
OpenInExplorer
2019-03-01 23:32:53 +01:00
supertobi
2e5e2e9f0d OpenInExplorer added Nautilus support 2019-03-01 23:30:58 +01:00
supertobi
fa25ec4a26 OpenInExplorer Tap to Space 2019-03-01 23:27:26 +01:00
supertobi
0ef9f5fc6c kml_export df.mkdir(df.sanitize_filename())
df.mkdir(df.sanitize_filename(xportDirectory..PS..imageFoldername))
2019-03-01 14:22:35 +01:00
supertobi
3df9040cfb Merge pull request #175 from BzKevin/patch-2
gettext incorrectly pointed to "gimp"
2019-02-28 22:21:36 +01:00
BzKevin
bd3a74954c gettext incorrectly pointed to "gimp" 2019-02-28 15:08:57 -05:00
supertobi
69b9a1fa5c Merge pull request #173 from darktable-org/supertobi-patch-video_ffmpeg
video_ffmpeg add df.sanitize_filename()
2019-02-28 13:23:30 +01:00
supertobi
287d9e94cf video_ffmpeg
I forgot the argument
2019-02-28 13:22:10 +01:00
supertobi
24862a26f2 viedeo_ffmpeg df.sanitize_filename()
viedeo_ffmpeg df.sanitize_filename() for mkdir and rmdir
2019-02-28 11:41:56 +01:00
wpferguson
a319428489 Merge pull request #174 from wpferguson/fix_mkdir_rmdir_sanitize
make rmdir and mkdir path handling consistent with other dtutils.file routines
2019-02-27 13:31:47 -05:00
Bill Ferguson
11881b3b73 removed sanitize_filename wrapper from path argument 2019-02-27 13:29:29 -05:00
supertobi
5a6ee174af kml_export sanitize_filename()
dsys.launch_default_app(df.sanitize_filename(path))
2019-02-27 10:05:59 +01:00
supertobi
9183beeed4 video_ffmpeg add df.sanitize_filename()
I'm not 100% sure, but I think we need the df.sanitize_filename() here.
2019-02-27 09:57:36 +01:00
wpferguson
e5537fdff0 Merge pull request #162 from BzKevin/BzKevin-CollectHelper
Add CollectHelper
2019-02-26 17:02:13 -05:00
BzKevin
9e0490d371 Add gettext, check for color label
Add translate-ability. Also adds a check that the selected image has an active color label and displays a message if it does not
2019-02-26 14:30:11 -05:00
wpferguson
2b2a09e36d Merge pull request #172 from wpferguson/fix_open_default_app
fix lib/dtutils/system/open_default_app()
2019-02-26 12:06:21 -05:00
Bill Ferguson
5ff36fe2ec Added a space after the commands and removed quotes in the command invocation. 2019-02-26 12:03:04 -05:00
supertobi
9440085169 kml_export: use more utility functions
kml_export: use more utility functions as suggested by @wpferguson
2019-02-26 14:02:16 +01:00
supertobi
5c24077a30 kml_export
the command "convert" is deprecated and replaced by "magick"
2019-02-25 17:06:34 +01:00
supertobi
68a8eabbbb kml_export added preference for path to convert
kml_export added preference for path to convert as windows programs are not by default in the PATH
2019-02-25 16:31:22 +01:00
supertobi
a038333cce make kml_export multi OS
replaced mkdir, xdg-open, xdg-user-dir
2019-02-25 10:37:16 +01:00
supertobi
a5304fe74c First step to make kml_export.lua windows friendly
Replaced "/" with PS like in other scripts
2019-02-25 09:48:50 +01:00
wpferguson
aaf564b35c Merge pull request #168 from wpferguson/compatibility_updates
Compatibility updates
2019-02-24 17:28:56 -05:00
Bill Ferguson
de087f743f Fixed compatibility issues. Added new version check to scripts. Renamed lib/dtutils/file/rm() to lib/dtutils/file/rmdir since removing a file in windows with rmdir /q/s results in an error. Fixed os.tmpname() issued in enfuse. Under windows os.tmpname() doesn't put the file in a temporary directory, so fixed it to use darktable.configuration.tmp_dir. Cleaned up documentation in lib/dtutils/system.lua. 2019-02-24 15:19:37 -05:00
supertobi
21a8e441d2 Merge pull request #167 from wpferguson/deprecate_video_mencoder
deprecate video_mencoder
2019-02-22 09:42:06 +01:00
Bill Ferguson
32fc4556b1 Merge remote-tracking branch 'upstream/master' 2019-02-21 23:51:20 -05:00
wpferguson
238856ed89 Merge pull request #153 from cigno5/master
enfuse: convert raws to tiff automatically
2019-02-21 23:50:40 -05:00
Bill Ferguson
8f6a236eb6 Updated files 2019-02-21 23:49:52 -05:00
wpferguson
d9ce826b9d Merge pull request #157 from theres/dm_timelapse
Timelapse plugin based on ffmpeg
2019-02-21 11:57:03 -05:00
Bill Ferguson
76cc1d47f6 Added messages to video_mencoder.lua to notify users of it's deprecation and pending removal. 2019-02-21 11:53:56 -05:00
wpferguson
a3d0983d33 Merge pull request #166 from wpferguson/check_min_api_version
check_min_api_version
2019-02-20 11:50:36 -05:00
Bill Ferguson
245a7b59c4 Incorporated supertobi's comment about spacing. 2019-02-20 11:48:37 -05:00
Bill Ferguson
8b714edb67 Changed check_min_api_version() to print error messages and throw an error if the minimum api is not satisfied. Updated the scripts to reflect the changed check_min_api_version(). 2019-02-20 00:22:05 -05:00
Dominik Markiewicz
2a3d532881 video ffmpeg: fix default macos video location; replace missing path separator by const 2019-02-19 11:36:42 +01:00
Dominik Markiewicz
5555ee278e file lib: mkdir - handle existing directory case on Windows 2019-02-19 11:35:02 +01:00
Bill Ferguson
451c7fb956 Added check_min_api_function to dtutils.lua to check the minimum version of the lua API required for a script to run. This is intended to replace the API check done with darktable.configuration.check_version(), which requires changing each time the API version changes. check_min_api_version should work for all API version changes unless backward compatibility is broken. All the scripts using darktable.configuration.check_version() were changed to use check_min_api_version(). 2019-02-18 19:46:11 -05:00
wpferguson
391b3b9e4f Merge pull request #165 from BzKevin/patch-1
Update OpenInExplorer
2019-02-16 20:28:34 -05:00
BzKevin
130a8edcef Cancel script if not windows
added return to cancel installation of the script if not windows, after displaying a message to user
2019-02-15 20:23:07 -05:00
BzKevin
5fd3a56a31 Remove extraneous widgets in preferences
I now understand how preferences work better and have removed the extraneous widgets which were doing nothing
2019-02-15 14:24:51 -05:00
BzKevin
b682284a2a Update with 'local' variable designation
Updated variable definitions with 'local' designation. Doing so slightly broke the script so I modified the function calls a tad to pass variables in and out as needed for "CollectOnAll" function to work.
2019-02-15 14:08:04 -05:00
BzKevin
d1676ac2e0 Update OpenInExplorer
Added:
1) Check if no image selected or more than 15 images selected
2) Popup error message if not a windows OS detected
3) Fixed a typo
2019-02-15 13:40:03 -05:00
BzKevin
2cb3397d75 Update HDRMerge
Now only checks for binary proper install once the functionality of the program is actually utilized. This avoids to many external command calls at dt startup just to check if certain things are installed.
2019-02-15 13:22:49 -05:00
supertobi
936f4fe254 Merge pull request #163 from BzKevin/BzKevin-OpenInExplorer
Add OpenInExplorer
2019-02-14 09:45:59 +01:00
BzKevin
f611213662 Update OpenInExplorer
instead of being it's own lib this is now added to the selected image's module and the button text has been updated to match dt's style
2019-02-13 13:46:22 -05:00
BzKevin
ff0352cfe6 Updated version of Collect Helper
Reworded the button text to better match with the rest of darktable's buttons
2019-02-13 13:42:54 -05:00
BzKevin
4d6dfea3a5 Add CollectHelper 2019-02-13 12:23:34 -05:00
BzKevin
be386e1172 Add OpenInExplorer 2019-02-13 12:22:42 -05:00
BzKevin
2a2fbd18cd Add HDRMerge 2019-02-13 12:21:57 -05:00
theres
56159e91ce video_ffmpg: fix executable path widget for ffmpeg; try to get default location for files
- logic for craeting vidget for specifing ffmpeg location was invalid
- now default export location should be set to default system
Video/Movie directory
2019-02-04 08:41:54 +01:00
theres
3675f4d7cd video ffmpeg - post review fixes
- rename OS_PATH_SEPARATOR -> PS and use in all needed places
- change function name from `open_file` to `launch_default_app`
- move `mkdir`, `rm` and `launch_default_app` helper functions to libs
- add executable_path_widget to export module if needed, not to the
preferences
- add show_status
- remove support_format
- change function name `format` to `format_string`, add comments
- replace apostrophes by quote marks
2019-01-27 22:43:47 +01:00
theres
3a129d3c4f Timelapse plugin based on ffmpeg 2019-01-21 01:21:56 +01:00
wpferguson
cc4e7197ba Merge pull request #156 from wpferguson/readme_update
Update README.md
2019-01-14 23:56:00 -05:00
Bill Ferguson
fc5677e7b5 Added enfusedAdvanced and gen_i18n_mo descriptions 2019-01-14 23:53:26 -05:00
wpferguson
19542c1640 Merge pull request #148 from wpferguson/translation_tool
Translation tool
2019-01-14 23:33:52 -05:00
Bill Ferguson
68b5acc154 Updated comments to reflect name change 2019-01-12 22:27:06 -05:00
Bill Ferguson
5c2c9e2a8f Changed name to gen_18n_mo to further clarify what the program does. 2019-01-12 22:21:48 -05:00
wpferguson
0376e11544 Merge pull request #130 from BzKevin/master
Add enfuseAdvanced
2019-01-12 22:05:12 -05:00
supertobi
6d910ffb60 Merge pull request #154 from Hofer-Julian/patch-1
Typo
2019-01-11 15:17:25 +01:00
luca
32f6310947 Used DT internal conversion (in place of darktable-cli os call)
Now a TIFF exporter is instanced at the beginning and used for all
selected raws

No system call to darktable-cli anymore
2019-01-08 21:15:18 +01:00
luca
f464a52ea4 dt.print made properly with string.format
All print call have been replaced with string.format (when needed) and
call to dt.gettext, in a future opening to translation
2019-01-08 20:46:32 +01:00
Hofer-Julian
e3d755fb9a Typo 2019-01-07 13:10:06 +01:00
luca
e05e05d866 enfuse: convert raws to tiff automatically
it uses darktable-cli (if installed) to convert to a temporary file the
raw files that enfuse is not able to process.
2019-01-06 21:42:49 +01:00
wpferguson
b7ff1cd579 Merge pull request #151 from wpferguson/fix_script_manager_activate_script
Fix script manager script activation bug
2018-11-21 21:31:34 -05:00
Bill Ferguson
0550f4e28a Fixed bug where the wrong script could be activated, because the script to activate was found by string matching. Replaced string match with value of category selector and script name to avoid any ambiguity. 2018-11-21 21:24:28 -05:00
wpferguson
3456dc90d8 Merge pull request #150 from wpferguson/hugin_windows_fix
Hugin windows fix
2018-11-19 16:28:27 -05:00
Bill Ferguson
8e006cf853 Changed windows path quoting to double quotes instead of single. Changed dt.control.execute to dtsys.external_command to handle the windows quoted arguments. 2018-11-19 15:56:24 -05:00
supertobi
0e36af38d8 Merge pull request #146 from simon04/i18n-update
Update German translation of hugin and kml_export
2018-11-07 09:52:36 +01:00
supertobi
e10f3e2285 Merge pull request #149 from schwerdf/master
'LabelsToTags' is standalone.
2018-11-03 10:48:26 +01:00
August Schwerdfeger
31f1614679 'LabelsToTags' is standalone. 2018-11-02 20:47:09 -05:00
Bill Ferguson
80e7eca064 Added tool to compile source translation files and place the results in the correct locale directory 2018-09-26 23:59:42 -04:00
BzKevin
adb85e349a Update enfuseAdvanced.lua
Fixing accidental "invalid escape" at line 133
2018-09-18 11:54:24 -04:00
BzKevin
52a241c1ec Delete enfuse_pro_2
enfuse_pro_2 is now enfuseAdvanced
2018-09-18 10:55:23 -04:00
BzKevin
d092016729 Add enfuseAdvanced
enfuseAdvanced replaces what was previously known as enfuse_pro_2. This incorporates changes requested by wpferguson on previous versions.
2018-09-18 10:54:16 -04:00
Simon Legner
11607e7e7d Delete compiled .mo files 2018-09-18 10:26:40 +02:00
Simon Legner
2d01f801bc Update German translation of hugin and kml_export 2018-09-18 10:25:34 +02:00
wpferguson
6e15373ce9 Merge pull request #145 from wpferguson/rename_tags_speed_up
rename-tags speed up
2018-09-13 10:55:04 -04:00
Bill Ferguson
e95ed5ad2b Found a way to access only the images tagged with the old tag instead of searching through all the images in the database. This results in a huge decrease in execution speed, depending on the size of the database. 2018-09-12 16:41:42 -04:00
wpferguson
dc9324f322 Merge pull request #144 from wpferguson/script_manager_dash_bug
script manager dash bug
2018-08-26 00:44:03 -04:00
Bill Ferguson
e7adf8cfb2 string.match on a filename with a - resulted in a failed match. Added a check for the dash and escaped it. 2018-08-26 00:39:58 -04:00
wpferguson
5f7c49ca85 Merge pull request #143 from wpferguson/script_manager_win_bug
fixed buy on windows where preferences were not getting saved
2018-08-23 13:10:58 -04:00
Bill Ferguson
f724335b91 fixed buy on windows where preferences wee not getting saved 2018-08-23 12:50:50 -04:00
wpferguson
3a5dfbc842 Merge pull request #135 from wpferguson/image_stack
Image Stacking
2018-08-23 11:45:16 -04:00
Bill Ferguson
380a1b66e6 Added path separator constant and used it where necessary. Added comment to attribute copy 2018-08-22 19:33:11 -04:00
wpferguson
c6cccf2d93 Merge pull request #141 from wpferguson/revert_script_manager_and
reverted change from nested if statements to a multiple and statement
2018-08-20 23:50:36 -04:00
Bill Ferguson
0858a19138 reverted change from nested if statements to a multiple and statement because it didn't work 2018-08-20 23:47:30 -04:00
wpferguson
f42199aec0 Merge pull request #140 from wpferguson/script_manager_typo
fixed typo in preferences
2018-08-20 23:28:04 -04:00
Bill Ferguson
8d746427a6 fixed typo in preferences 2018-08-20 23:24:30 -04:00
wpferguson
3c9b2b90d4 Merge pull request #139 from wpferguson/script_manager
darktable script management interface
2018-08-20 21:29:32 -04:00
Bill Ferguson
abc959a814 enabled link to lua-scripts version 2018-08-20 21:28:54 -04:00
wpferguson
c71c289547 Merge pull request #138 from wpferguson/executable_manager
Manage external executables used by the lua scripts
2018-08-20 21:22:47 -04:00
Bill Ferguson
02bb942abd Cleaned up the code and incorporated Tobias Jakob's comments 2018-08-20 21:12:07 -04:00
Bill Ferguson
a37c33ec36 Fixed enable preference not saved 2018-08-19 12:30:45 -04:00
Bill Ferguson
0e4926426f Added error feedback when script doesn't load 2018-08-19 01:11:54 -04:00
Bill Ferguson
a309db8739 Created tools/script_manager.lua to provide an interface from darktable for managing the lua scripts. Updated README.md to reflect the added script. 2018-08-18 15:04:43 -04:00
Bill Ferguson
1a998581ef Created tools/executable_manager.lua for managing external executables used by the lua scripts. Updated the README to reflect the new script. 2018-08-17 19:30:43 -04:00
wpferguson
f49b951331 Merge pull request #137 from wpferguson/enfuse_version_aware
Alter enfuse arguments based on version
2018-08-15 11:25:05 -04:00
Bill Ferguson
26e16ffeda Added a version check to modify the arguments based on the version of enfuse. Enfuse 4.2 no longer accepts the exposure-mu argument. The closest function is exposure-optimum. For versions of enfuse less than 4.2 exposure-mu is used. For versions of enfuse greater than 4.2, exposure-optimum is used. 2018-08-15 00:30:18 -04:00
Bill Ferguson
9e4a72e098 Creeated image_stack.lua based on Pat David's blog entry, https://patdavid.net/2013/05/noise-removal-in-photos-with-median_6.html. Updated README.md to reflect the new script. 2018-08-08 22:41:25 -04:00
wpferguson
a7d053648a Merge pull request #134 from wpferguson/multi_os_example
Multiple OS Example
2018-08-08 21:24:23 -04:00
Bill Ferguson
61a55f71f5 Created a cross platform script that calls an external executable. It also performs a service that some users might find useful, extracting the embedded jpeg image from a raw file, then importing and grouping it with the raw. Updated README.md to reflect the new file 2018-08-07 22:08:09 -04:00
wpferguson
9979d4abda Merge pull request #132 from wpferguson/windows_work_arounds
Cross platform external command capability
2018-08-07 11:02:04 -04:00
Bill Ferguson
5a2af47eda Removed unneeded require for yield, since it now in lib/dtutils.system 2018-08-07 11:00:16 -04:00
wpferguson
eab6b99155 Merge pull request #133 from sjjh/patch-1
corrected "dt" to "darktable" in line 63 of cr2hdr
2018-08-03 22:28:31 -04:00
sjjh
4acba4d48a corrected "dt" to "darktable" in line 63 of cr2hdr
object "darktable" is defined in line 35; usage of "dt" was probably a typo or left over from a refactoring.
2018-08-04 01:43:38 +02:00
Bill Ferguson
8b5a43e435 Added require statement for official/yield.lua so that darktable.control.execute() would have all of it's requirements met without the user having to remember to add it somewhere else 2018-07-12 13:23:33 -04:00
Bill Ferguson
26fce03d0f Removed leftover unused code 2018-07-11 11:49:01 -04:00
Bill Ferguson
1a22bfbcef Added system library to handle running external commands on different operating systems in a transparent manner. Added file and path quoting that is cross platform compatible. Changed gimp.lua to use the new utilities. 2018-07-11 11:32:48 -04:00
BzKevin
050783fc8b enfuse_pro_2 modified per wpferguson
1) Moved check_if_bin installed to run only once, when script first loaded (rather than every time it is called)
2) Changed executable path preferences per Bill's suggestions 
   dt.preferences.register("executable_paths", "align_image_stack",
   dt.preferences.register("executable_paths", "enfuse",
   dt.preferences.register("executable_paths", "exiftool",
3) Replaced custom block of code with df.create_unique_filename
4) Quoted paths in run commands for linux and MacOS (I still experience failures if I quote anything in the run command aside from the .exe path on windows)
5) Changed LUA API compatability check for 5.0.0 only

Tested on Windows and MacOS
2018-07-07 11:40:01 -04:00
wpferguson
d96d8fb4fc Merge pull request #131 from wpferguson/macos_command_fixes
MacOS Command Fixes
2018-07-07 11:08:23 -04:00
Bill Ferguson
4b32c34ebd Removed 'open -W -a' for mac commands from check_if_bin_exists since it only appears to be needed for GUIs. Added 'open -W -a' for macs using GIMP in gimp.lua 2018-07-06 23:04:44 -04:00
BzKevin
927bf12243 Add enfuse_pro_2
Enhanced version of Holger Klemm's enfuse_pro that adds features and X-platform compatibility.
2018-07-01 19:54:15 -04:00
BzKevin
a867791165 Delete enfuse_pro_2.lua 2018-07-01 19:52:47 -04:00
BzKevin
67232094c9 Delete OpenInPS.lua 2018-07-01 19:51:39 -04:00
BzKevin
b5e79abf08 Delete HDRMerge.lua 2018-07-01 19:51:26 -04:00
BzKevin
84c0fd7414 Add 3 new Pulg-Ins
HDRMerge: Add easy access to HDRMerge from within dt
enfuse_pro_2: Updated version of Holger Klemm's popular enfuse plug-in. Adds some features and cross-platform compatability
OpenInPS: add ability to open or export selected file with Photoshop
2018-06-30 14:58:50 -04:00
supertobi
850a7d8676 Merge pull request #126 from jbvoelker/gpx_tracks
gpx_export.lua: Create a separate <trk> for each source folder
2018-06-24 22:37:12 +02:00
Jannis_V
ded24e8037 gpx_export.lua: Create a separate <trk> for each source folder 2018-06-24 18:47:33 +02:00
Tobias Ellinghaus
71fbf5705c Use print_log in import_filter_manager 2018-05-23 10:23:48 +02:00
Tobias Ellinghaus
87b78717f3 Fix formatting of README.md 2018-05-23 10:22:37 +02:00
wpferguson
1cd9a34761 Merge pull request #123 from wpferguson/README.md_snap_update
Add snap information to README.md
2018-05-22 12:13:25 -04:00
Bill Ferguson
b9072cccba Updated README.md to reflect change to snap packaging enabling lua and included instructions on how to use the scripts with the snap 2018-05-22 12:11:55 -04:00
Tobias Ellinghaus
18fb3a68fd Re-fix README.md 2018-05-21 11:23:19 +02:00
wpferguson
c0b89e51d7 Merge pull request #122 from wpferguson/update_README.md_for_snaps
Updated README.md to include snap, flatpak, and appimage information
2018-05-20 15:10:32 -04:00
wpferguson
f2ac2595f9 Merge branch 'master' into update_README.md_for_snaps 2018-05-20 15:09:35 -04:00
Bill Ferguson
b241007d4f Updated README.md to include snap, flatpak, and appimage information 2018-05-20 15:02:37 -04:00
Tobias Ellinghaus
2b1af40bd1 Some fixes for the README 2018-05-20 16:11:02 +02:00
wpferguson
66f85a1f35 Merge pull request #121 from wpferguson/update_README.md
Update README.md
2018-05-19 23:17:15 -04:00
Bill Ferguson
22633d6130 Updated README.md to better present what the lua-scripts are and how to use them. Provided tables of scripts, whether they are standalone, and cross platform compatibility. Provided instructions for install on Linux, MacOS, and Windows as well as instructions for updating the scripts. 2018-05-18 22:28:33 -04:00
wpferguson
8ed4d838ee Merge pull request #120 from wpferguson/hugin_space_problem
hugin fails on images with spaces in the filenames
2018-05-16 11:15:37 -04:00
wpferguson
9175916771 Merge pull request #119 from wpferguson/fix_print_log_plaeceholder
Replace placeholder for dt.print_log with dt.print_log
2018-05-15 11:38:56 -04:00
Bill Ferguson
7acf2b9cac Fixed bug where log_level() always returned log.success instead of the correct log level 2018-05-15 01:22:09 -04:00
Bill Ferguson
965d8791d8 single quoted filename arguments to the hugin commands for the supplied image files. Single quoted any filenames derived from the supplied image files in case they contained spaces. Added logging at various levels so that the next time I have to work on this I can figure it out quicker. Normal logging level is log.error which only prints error information. Changing log level to log.info provides much more insight about what is occurring. Fixed gui not returning generated file to film strip. 2018-05-15 01:05:34 -04:00
Bill Ferguson
f961e6aa6b Replaced dt_print_log = dt.print_error with dt.print_log now that the function exists 2018-05-14 20:30:09 -04:00
wpferguson
b8182cfde5 Merge pull request #117 from marco44/fix_autostyle
Fix autostyle
2018-05-09 14:48:55 -04:00
marco44
78f0e367dc Change logging 2018-05-09 17:54:26 +02:00
marco44
aca0224263 Fix autostyle, checkIfBinExists doesn't seem to exist in latest releases anymore 2018-05-05 16:37:27 +02:00
supertobi
c74636e2c0 Fixed typo in README 2018-04-09 16:54:12 +02:00
supertobi
f113bc5b8a Added links to the README
Added links to the documentation.
2018-04-09 13:23:11 +02:00
supertobi
befae8b191 Improved README.md
I've added some information anarcat suggested on pixls.us:
https://discuss.pixls.us/t/don-t-forget-the-lua-scripts/1598/8
2018-04-09 11:59:52 +02:00
supertobi
1767e8f074 Merge pull request #111 from achienbsi/hugin_plugin_improvements
hugin plugin improvements
2018-03-19 22:32:19 +01:00
Andy Chien
44081b772f fixed version requirement due to updates to darktable.configuration.running_os 2018-03-19 06:51:30 -07:00
supertobi
3051eddd2e Merge pull request #115 from wpferguson/dtutils_file_fix
check_if_[bin|file]_exist fixes
2018-03-17 10:24:24 +01:00
Bill Ferguson
5266aa7547 Used a less aggressive quoting strategy that works with check_if_bin_exists, check_if_file_exists, and io.popen(). 2018-03-16 12:16:45 -04:00
supertobi
7e57f61947 Merge pull request #114 from wpferguson/check_if_bin_exists_fixes
Fix macOS returned path  and add wine awareness to check_if_bin_exists()
2018-03-11 16:49:53 +01:00
Bill Ferguson
1c587d3726 Changed wine test to check for .exe"$ or .EXE"$ because of quoting string paths 2018-03-10 13:45:04 -05:00
Bill Ferguson
b4ea97ce37 Fixed accidently wiped out check for macos 2018-03-10 13:38:17 -05:00
Bill Ferguson
83c1a5789a Changed wine check to operating system isn't windows 2018-03-10 13:07:19 -05:00
Bill Ferguson
841026661a Removed debugging statement 2018-03-10 12:56:18 -05:00
Bill Ferguson
692441e1d5 Added wine awareness for unix, linux, and macos. Added open -a -W to the macos path so that the path returned by the finder will work correctly. 2018-03-10 12:52:22 -05:00
Andy Chien
46ba555a20 * updated to work with new dtutils_file
* added checkbox to allow user to launch hugin in gui mode
* changed the logic so hugin will write temp files to tmp directory and then move the final result to the directory of original source files. this improves speed when original source files are on network mapped drive
* added some additional error messages
2018-03-05 09:48:30 -08:00
supertobi
de18432a7d Merge pull request #112 from wpferguson/os_path_fix
Windows and macOS external executable compatibility
2018-03-05 14:13:29 +01:00
supertobi
497b6cb59c Merge pull request #113 from wpferguson/check_os
Check operating system compatability
2018-03-04 22:27:08 +01:00
Bill Ferguson
c073ecf0dd Added check_os to lib/dtutils.lua so that scripts can check compatibility with the current operating system 2018-03-03 20:22:47 -05:00
Bill Ferguson
2ea4db8e38 Added windows and macOS external executable compatibility. Added functions set_executable_path_preference(), get_executable_path_preference(), and executable_path_widget() to lib/dtutils/file.lua to get, set and retrieve the location of executables on windows and macOS systems. Modified check_if_bin_exists to use the path preferences so executables can be found on windows and macOS systems as well as linux. Modified contrib/gimp.lua to use the new functions, thus making it usable on windows and macOS too. 2018-03-02 14:07:29 -05:00
Andy Chien
fe942100a4 hugin plugin improvements
* added preference requiring user to specify the paths for hugin, hugin_executor and pto_gen needed for this plguin
* added preference to allow user to choose to launch hugin in GUI mode
* minor fix to the way files are handled; due to some versions of hugin_executor not writing out to the path specified in --prefix, assume we are working in the tmp directory and then move the file afterwards
2018-02-26 07:29:41 -08:00
supertobi
79eb1428b0 Merge pull request #108 from achienbsi/file_fixes_for_windows
fixed a couple dtutils_file functions for windows platform
2018-02-26 15:57:11 +01:00
Andy Chien
467365dcbb platform dependent implementation of check_if_bin_exists and check_if_file_exists 2018-02-23 18:14:24 -08:00
supertobi
33a323fe85 Merge pull request #109 from achienbsi/hugin_improvements
improved a few aspects of the hugin script
2018-02-23 09:41:32 +01:00
Andy Chien
4ad9e77a7e improved a few aspects of the hugin script:
* handle stiching all from hugin_executor without the gui
* automatically create the panorama file name based on first selected file plus _pano
* automatically detects if output file exists, if so use an unique name
* delete temporarily exported file
2018-02-22 16:07:28 -08:00
Andy Chien
5d57347730 fixed a couple dtutils_file functions for windows platform 2018-02-22 16:01:54 -08:00
Tobias Ellinghaus
54572de8d9 Fix LabelsToTags for Lua 5.3
Fixes #106
2018-01-23 11:28:45 +01:00
supertobi
0e57a0804a Merge pull request #105 from elman22/master
Updated KML/KMZ export script
2018-01-20 14:27:04 +01:00
Tobias Ellinghaus
95077f639b New script to delete unused tags on startup 2018-01-17 10:42:44 +01:00
Tobias Ellinghaus
493dcc7ef7 Don't delete tags while iterating 2018-01-17 10:41:55 +01:00
Elman
f86b16735b Formatted code to follow project settings 2018-01-15 22:54:22 +01:00
Elman
0c1de20a1a Code formatting 2018-01-15 17:56:02 +01:00
Elman
e9d0f706ed Correct handling of duplicates 2018-01-15 17:41:26 +01:00
Elman
d297718358 Path is now sorted by exif_datetime_taken 2018-01-15 17:40:50 +01:00
Elman
b406b36cda Added all Slovak and Czech accents 2018-01-15 17:31:19 +01:00
supertobi
570732a9b2 Merge pull request #104 from schwerdf/master
New script: "Labels to Tags"
2018-01-08 11:33:25 +01:00
August Schwerdfeger
92b5507e0e Added 'Labels to Tags' script. 2018-01-07 00:37:41 -06:00
supertobi
73897b8ee7 Merge pull request #103 from jbvoelker/gpx-export
GPX export script
2018-01-03 22:27:46 +01:00
Jannis Völker
2d9cdc5a24 GPX export script which generates a GPX track from all selected images containing geo information 2018-01-03 20:51:35 +01:00
supertobi
234e5bc5fc Merge pull request #102 from wpferguson/api_5_0_0
Updated remaining scripts to api 5.0.0
2018-01-03 10:08:22 +01:00
Bill Ferguson
664496b430 Updated to api 5.0.0 and tested. include_all.lua changed to load official/yield and ignore the lib and tools directories. 2018-01-02 19:51:14 -05:00
supertobi
67d92bd070 Update selection_to_pdf.lua
added {5,0,0} to the check_version
2018-01-02 11:37:10 +01:00
supertobi
d6e53cc005 Update save_selection.lua
added {5,0,0} to the check_version
2018-01-02 11:35:57 +01:00
supertobi
2c77712ab4 Update image_path_in_ui.lua
added {5,0,0} to the check_version
2018-01-02 11:34:41 +01:00
supertobi
10c1eff1b6 Update generate_image_txt.lua
added {5,0,0} to the check_version
2018-01-02 11:33:40 +01:00
supertobi
4c26465dde Update enfuse.lua
added {5,0,0} to the check_version
2018-01-02 11:30:08 +01:00
supertobi
d29e5f49f4 Update delete_long_tags.lua
added {5,0,0} to the check_version
2018-01-02 11:28:44 +01:00
supertobi
0191558d26 Update copy_paste_metadata.lua
added {5,0,0} to the check_version
2018-01-02 11:24:42 +01:00
supertobi
d3692bcc09 check_for_updates.lua: added {5,0,0} to the check_version 2018-01-02 11:22:43 +01:00
supertobi
befa83bee8 added {5,0,0} to the check_version 2018-01-02 11:10:56 +01:00
supertobi
b4347e5701 added {5,0,0} to the check_version 2018-01-02 11:10:31 +01:00
supertobi
c4ed6c2b97 added {5,0,0} to the check_version 2018-01-02 11:09:42 +01:00
supertobi
6b5f650aac added {5,0,0} to the check_version 2018-01-02 11:08:49 +01:00
supertobi
63b38c1f53 added {5,0,0} to the check_version 2018-01-02 11:08:07 +01:00
supertobi
33b6f0d72e added {5,0,0} to the check_version 2018-01-02 11:07:20 +01:00
supertobi
a6f8070f65 Delete LICENSE 2017-12-12 16:36:38 +01:00
supertobi
29aaaf55cf Merge pull request #101 from darktable-org/add-license-1
Create LICENSE
2017-12-12 15:19:01 +01:00
supertobi
b47da137c1 Create LICENSE 2017-12-12 15:18:40 +01:00
GHswitt
8e6552ee9c Added ignore tag and unknown tag, verbose output 2017-12-11 17:43:53 +01:00
GHswitt
024e016df2 Storage plugin for face_recognition 2017-12-11 14:27:36 +01:00
211 changed files with 42703 additions and 1604 deletions

184
ChangeLog.md Normal file
View File

@@ -0,0 +1,184 @@
## Changes from most recent to oldest
**06 Jun 2024 - wpferguson**
* fix fujifilm_ratings running on all images
* added string library functions to sanitize windows io.popen and os.execute functions
* added database maintenance script
**05 Jun 2024 - wpferguson**
* added fix for executable_manager not being visible on windows
**30 May 2024 - kkotowicz**
* open in explorer now uses applescript on macos to open multiple files
**20 May 2024 - wpferguson**
* added string variable substitution to the string library
**16 May 2024 - wpferguson**
* fix crash in script_manager
**15 May 2024 - wpferguson**
* added metadata to scripts (name, author, purpose, help url)
**06 May 2024 - christian.sueltrop**
* added passport_guide_germany script
**08 Apr 2024 - wpferguson**
* made script_manager aware of library modules in other directories besides lib
**29 Mar 2024 - wpferguson**
* updated examples/gui_action to use NaN instead of nan
**29 Mar 2024 - dterrahe**
* add lua action script example
**28 Jan 2024 - wpferguson**
* fix script_manager crash when script existed in top level lua directory
**24 Jan 2024 - wpferguson**
* don't set lib visibility unless we are in lighttable mode
**15 Jan 2024 - MStraeten**
* update x-touch.lua with support for primaries slider
**14 Jan 2024 - wpferguson**
* added cycle_group_leader script
* added hif_group_leader script
* added jpg_group_leader script
**28 Oct 2023 - ddittmar**
* Added select non existing image script
**17 Oct 2023 - wpferguson**
* script_manager wrap username in quotes to handle spaces in username
**20 Sep 2023 - wpferguson**
* script_manager explicitly set stopped scripts to false
**18 Aug 2023 - wpferguson**
* swap the position of executable_manager and script_manager due to windows gtk bug
**17 Jul 2023 - wpferguson**
* update check for update instructions
* update flatpak readme
**16 Jul 2023 - wpferguson**
* added script_data.show function to contrib/gpx_export
**15 Jul 2023 - wpferguson**
* script_manager updates
* added check_max_api_version for the case where the API no longer supports the required
functions
**14 Jul 2023 - spaceChRis**
* add tooltip to filter manager
**25 Mar 2023 - wpferguson**
* Added script_manager darktable shortcut integration
* Moved filename/path/extension string functions to string library
**06 Mar 2023 - wpferguson - Added option to disable script_manager update check**
**12 Jan 2022 - wpferguson - Documented contrib/rename_images.lua**
**28 Dec 2021 - wpferguson - Replaced deprecated _which_ command with _command -v_ in lib/dtutils/file.lua**
**12 Dec 2021 - wpferguson**
* Added deprecated function to library
* Added deprecation warning to contrib/rename-tags.lua
**22 Oct 2021 - wpferguson for Volker Bödker - make sure sequence is 4 digits in rename_images.lua**
**31 Aug 2021 - wpferguson - remove styles hiding from AutoGrouper.lua**
**02 Jul 2021 - wpferguson - merged API-7.0.0-dev branch to master**
* API-7.0.0 is darktable 3.6
* breaking changes
* register_event argments changed
* register_action arguments changed
* register_selection arguments changed
* register_event arguments changed
* scripts updated to API-7.0.0 compatibility
* script_manger updated to be API aware and check out the proper branch
based on darktable API version
**01 Jul 2021 - wpferguson - created branch for API-6.1.0 - darktable 3.4**
**20 Jun 2021 - wpferguson - created branches for older API versions**
* API-6.0.0 - darktable 3.2.1
* API-5.0.2 - darktable 3.0
* API-5.0.1 - darktable 2.6.1
* API-5.0.0 - darktable 2.4
* API-4.0.0 - darktable 2.2
* API-3.0.0 - darktable 2.0
**19 Jun 2021 - wpferguson - fix issue 312, image_path_in_ui**
**02 Jun 2021 - wpferguson - fix contrib/quicktag**
* set new entry field is_password to false so entry
is visible to user while typing.
**19 Mar 2021 - wpferguson - fixed crash in contrib/HDRmerge.lua**
* Made generated filename routine gracefully handle names that
are not in the expected format.
**15 Mar 2021 - scheckmedia - updated contrib/photils.lua**
* refactor print method
* add option to apply selected tags from a single image to multiple images
* add setting parameter to enable/disable the export of an image before tag suggestion
**25 Feb 2021 - wpferguson - added detached mode to contrib/gimp.lua**
* Added run_detached checkbox to the exporter GUI. Selecting run_detached
let's GIMP keep running and accepting additional images. It does not return
the edited images to darktable.
**24 Feb 2021 - Mark64 - make ext_editor lib visible in darkroom view**
**17 Feb 2021 - wpferguson - API 6.2.3 register_action changes**
* Added check for API version and supplied a name argument if the
API version was greater than or equal to 6.2.3
**10 Feb 2021 - wpferguson - bugfix select_untagged**
* Fixed callback to return a list of images as expected instead of
doing the selection in the callback
**10 Feb 2021 - wpferguson - bugfix API 6.2.1 compatibility**
* The inline check for API version didn't handle argument return
correctly so added a transition library with a register_event function
override to check the API version and process the arguments correctly.
**9 Feb 2021 - wpferguson - bugfix API 6.2.2 compatibility**
* The inline check for API version didn't handle argument return
correctly so changed it to a full if/else block
**4 Reb 2021 - wpferguson - API 6.2.2 compatibililty**
* Added check for API version and supplied a name argument to register_selection
if the API version was greater than or eqal to 6.2.2
**1 Feb 2021 - wpferguson - API 6.2.1 compatibility**
* Added check for API version and supplied a name argument to register_event
if the API version was greater than or eqal to 6.2.1
**21 Jan 2021 - wpferguson - Modified dtutils function find_image_by_id**
* For users with API 6.2.0 or greater - Enabled use of new API function
darktable.database_get_image() in find_image_by_id().
**19 Jan 2021 - schwerdf - Added dtutils library function find_image_by_id()**
* Added new library function to retrieve an image from the library based on it's ID instead
of it's row number in the database
**10 Jan 2021 - chrisaga - copy_attach_detach_tags localization**
**7 Jan 2021 - dtorop - add contrib/fujifilm_dynamic_range**
* add a new contrib script, fujifilm_dynamic_range to adjust exposure
based on the exposure bias camera setting

280
README.md
View File

@@ -1,10 +1,278 @@
lua-scripts
===========
# Lua scripts
The Lua scripts in this repository are meant to be used together with darktable. Either copy them individually to `~/.config/darktable/lua` (Linux/Unix) or `%LOCALAPPDATA%\darktable\lua` (Windows) (you might have to create that folder) or just copy/symlink the whole repository there. That allows to update all your scripts with a simple call to `git pull`.
## Description
To enable one of the scripts you have to add a line like `require "examples/hello_world"` to your: `~/.config/darktable/luarc` (Linux/Unix) or `%LOCALAPPDATA%\darktable\luarc` (Windows) file which will enable the example script in `examples/hello_world.lua` (note the lack of the `.lua` suffix).
darktable can be customized and extended using the Lua programming language. This repository contains the collected
efforts of the darktable developers, maintainers, contributors and community. The following sections list the scripts
contained in the repository, whether they can be run by themselves (Standalone - Yes) or depend on other
scripts (Standalone - No), what operating systems they are known to work on (L - Linux, M - MacOS, W - Windows), and their purpose.
Each script includes its own documentation and usage in its header, please refer to them.
For the latest changes, see the [ChangeLog](ChangeLog.md)
In order to have your own scripts added here they have to be under a free license (GPL2+ will definitely work, others can be discussed). Scripts in the `official/` subfolder are maintained by the darktable community, those under `contrib/` are meant to have an "owner" who maintains them.
### Official Scripts
These scripts are written primarily by the darktable developers and maintained by the authors and/or repository maintainers. They are located in the official/ directory.
Name|Standalone|OS |Purpose
----|:--------:|:---:|-------
[check_for_updates](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/check_for_updates)|Yes|LMW|Check for updates to darktable
[copy_paste_metadata](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/copy_paste_metadata)|Yes|LMW|Copy and paste metadata, tags, ratings, and color labels between images
[delete_long_tags](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/delete_long_tags)|Yes|LMW|Delete all tags longer than a specified length
[delete_unused_tags](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/delete_unused_tags)|Yes|LMW|Delete tags that have no associated images
[enfuse](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/enfuse)|No|L|Exposure blend several images (HDR)
[generate_image_txt](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/generate_image_txt)|No|L|Generate txt sidecar files to be overlaid on zoomed images
[image_path_in_ui](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/image_path_in_ui)|Yes|LMW|Plugin to display selected image path
[import_filter_manager](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/import_filter_manager)|Yes|LMW|Manager for import filters
[import_filters](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/import_filters)|No|LMW|Two import filters for use with import_filter_manager
[save_selection](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/save_selection)|Yes|LMW|Provide save and restore from multiple selection buffers
[selection_to_pdf](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/selection_to_pdf)|No|L|Generate a PDF file from the selected images
### Contributed Scripts
These scripts are contributed by users. They are meant to have an "owner", i.e. the author, who maintains them. Over time the community has helped maintain these scripts, as well as the authors. They are located in the contrib/ directory.
Name|Standalone|OS |Purpose
----|:--------:|:---:|-------
[AutoGrouper](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/autogrouper)|Yes|LMW|Group images together by time
[autostyle](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/autostyle)|Yes|LMW|Automatically apply styles on import
[auto_tag_modified](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/auto_tag_modified)|Yes|LMW|Automatically tag images which have been manually modified in the darkroom
change_group_leader|Yes|LMW|Change which image leads group
[clear_GPS](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/clear_gps)|Yes|LMW|Reset GPS information for selected images
[CollectHelper](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/collecthelper)|Yes|LMW|Add buttons to selected images module to manipulate the collection
color_profile_manager|Yes|LMW|Manage darktable input and output color profiles
[copy_attach_detach_tags](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/copy_attach_detach_tags)|Yes|LMW|Copy and paste tags from/to images
[cr2hdr](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/cr2hdr)|Yes|L|Process image created with Magic Lantern Dual ISO
cycle_group_leader|Yes|LMW|cycle through images of a group making each the group leader in turn
dbmaint|Yes|LMW|find and remove database entries for missing film rolls and images
[enfuseAdvanced](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/enfuseadvanced)|No|LMW|Merge multiple images into Dynamic Range Increase (DRI) or Depth From Focus (DFF) images
[exportLUT](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/exportlut)|Yes|LMW|Create a LUT from a style and export it
[ext_editor](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/ext_editor)|No|LW|Export pictures to collection and edit them with up to nine user-defined external editors
[face_recognition](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/face_recognition)|No|LM|Identify and tag images using facial recognition
[fujifilm_dynamic_range](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/fujifilm_dynamic_range)|No|LMW|Correct fujifilm exposure based on exposure bias camera setting
[fujifilm_ratings](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/fujifilm_ratings)|No|LM|Support importing Fujifilm ratings
[geoJSON_export](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/geojson_export)|No|L|Create a geo JSON script with thumbnails for use in ...
[geoToolbox](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/geotoolbox)|No|LMW|A toolbox of geo functions
[gimp](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/gimp)|No|LMW|Open an image in GIMP for editing and return the result
[gpx_export](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/gpx_export)|No|LMW|Export a GPX track file from selected images GPS data
harmonic_armature|Yes|LMW|provide a harmonic armature guide
hif_group_leader|Yes|LMW|change the group leader in a raw+heif image pair to the heif image
[HDRMerge](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/hdrmerge)|No|LMW|Combine the selected images into an HDR DNG and return the result
[hugin](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/hugin)|No|LMW|Combine selected images into a panorama and return the result
[image_stack](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/image_stack)|No|LMW|Combine a stack of images to remove noise or transient objects
[image_time](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/image_time)|Yes|LMW|Adjust the EXIF image time
jpg_group_leader|Yes|LMW|change the group leader for a raw+jpg pair to the jpg image
[kml_export](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/kml_export)|No|L|Export photos with a KML file for usage in Google Earth
[LabelsToTags](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/labelstotags)|Yes|LMW|Apply tags based on color labels and ratings
[OpenInExplorer](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/openinexplorer)|No|LMW|Open the selected images in the system file manager
[passport_guide](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/passport_guide)|Yes|LMW|Add passport cropping guide to darkroom crop tool
passport_guide_germany|Yes|LMW|Add passport cropping guide for German passports to darkroom crop tool
[pdf_slideshow](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/pdf_slideshow)|No|LM|Export images to a PDF slideshow
[photils](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/photils)|No|LM|Automatic tag suggestions for your images
[quicktag](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/quicktag)|Yes|LMW|Create shortcuts for quickly applying tags
[rate_group](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/rate_group)|Yes|LMW|Apply or remove a star rating from grouped images
[rename_images](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/rename_images)|Yes|LMW|Rename single or multiple images
[rename-tags](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/rename-tags)|Yes|LMW|Change a tag name
[RL_out_sharp](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/rl_out_sharp)|No|LW|Output sharpening using GMic (Richardson-Lucy algorithm)
[select_non_existing](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/select_non_existing)|Yes|LMW|Enable selection of non-existing images in the the currently worked on images
[select_untagged](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/select_untagged)|Yes|LMW|Enable selection of untagged images
[slideshowMusic](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/slideshowMusic)|No|L|Play music during a slideshow
[transfer_hierarchy](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/transfer_hierarchy)|Yes|LMW|Image move/copy preserving directory hierarchy
[video_ffmpeg](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/video_ffmpeg)|No|LMW|Export video from darktable
website_gallery_export|No|LMW|Export a website gallery for selected images
### Example Scripts
These scripts provide examples of how to use specific portions of the API. They run, but are meant for demonstration purposes only. They are located in the examples/ directory.
Name|Standalone|OS |Purpose
----|:--------:|:---:|-------
[api_version](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/api_version)|Yes|LMW|Print the current API version
[darkroom_demo](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/darkroom_demo)|Yes|LMW|Demonstrate changing images in darkoom
[gettextExample](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/gettextexample)|Yes|LM|How to use translation
gui_actions|Yes|LMW|demonstrate controlling the GUI using darktable.gui.action calls
[hello_world](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/hello_world)|Yes|LMW|Prints hello world when darktable starts
[lighttable_demo](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/lighttable_demo)|Yes|LMW|Demonstrate controlling lighttable mode, zoom, sorting and filtering
[moduleExample](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/moduleexample)|Yes|LMW|How to create a lighttable module
[multi_os](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/multi_os)|No|LMW|How to create a cross platform script that calls an external executable
[panels_demo](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/panels_demo)|Yes|LMW|Demonstrate hiding and showing darktable panels
[preferenceExamples](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/preferenceexamples)|Yes|LMW|How to use preferences in a script
[printExamples](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/printexamples)|Yes|LMW|How to use various print functions from a script
[running_os](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/running_os)|Yes|LMW|Print out the running operating system
x-touch|Yes|LMW|demonstrate how to use an x-touch mini MIDI controller to control the darktable GUI
### Tools
Tool scripts perform functions relating to the repository, such as generating documentation. They are located in the tools/ directory.
Name|Standalone|OS |Purpose
----|:--------:|:---:|-------
[executable_manager](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/tools/executable_manager)|Yes|LMW|Manage the external executables used by the lua scripts
[gen_i18n_mo](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/tools/gen_i18n_mo)|No|LMW|Generate compiled translation files (.mo) from source files (.po)
[get_lib_manpages](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/tools/get_lib_manpages)|No|LM|Retrieve the library documentation and output it in man page and PDF format
[get_libdoc](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/tools/get_libdoc)|No|LMW|Retrieve the library documentation and output it as text
[script_manager](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/tools/script_manager)|No|LMW|Manage (install, update, enable, disable) the lua scripts
### Related third-party projects
The following third-party projects are listed for information only. Think of this collection as an `awesome-darktable-lua-scripts` list. Use at your own risk!
* [trougnouf/dtMediaWiki](https://github.com/trougnouf/dtMediaWiki) – Wikimedia Commons export
* [wpferguson/extra-dt-lua-scripts](https://github.com/wpferguson/extra-dt-lua-scripts)
* [xxv/darktable-git-annex](https://github.com/xxv/darktable-git-annex) – git-annex integration
* [theres/dt_backup](https://github.com/theres/dt_backup) – automatic backup on exit
* [Sitwon/dt_fujifilm_ratings](https://github.com/Sitwon/dt_fujifilm_ratings) – Fujifilm Ratings import
* [progo/leica-q-autocrop](https://github.com/progo/leica-q-autocrop) – crop in 35 mm or 50 mm equivalent
* [BzKevin/OpenInPS-Darktable-PlugIn](https://github.com/BzKevin/OpenInPS-Darktable-PlugIn) – open in Adobe Photoshop
* [johnnyrun/darktable_lua_gimp](https://github.com/johnnyrun/darktable_lua_gimp) – GIMP export
* [arru/darktable-scripts](https://github.com/arru/darktable-scripts)
* [nbremond77/darktable](https://github.com/nbremond77/darktable/tree/master/scripts)
* [s5k6/dtscripts](https://github.com/s5k6/dtscripts)
* [ChristianBirzer/darktable_extra_scripts](https://github.com/ChristianBirzer/darktable_extra_scripts)
* [fjb2020/darktable-scripts](https://github.com//fjb2020/darktable-scripts)
* [bastibe/Darktable-Film-Simulation-Panel](https://github.com/bastibe/Darktable-Film-Simulation-Panel)
## Download and Install
The recommended method of installation is using git to clone the repository. This ensures that all dependencies on other scripts
are met as well as providing an easy update path. Single scripts listed as standalone may be downloaded and installed by themselves.
### snap packages
The snap version of darktable comes with lua included starting with version 2.4.3snap2.
Ensure git is installed on your system. If it isn't, use the package manager to install it. Then open a terminal and:
cd ~/snap/darktable/current
git clone https://github.com/darktable-org/lua-scripts.git lua
### flatpak packages
Flatpak packages now use the internal lua interpreter.
Ensure git is installed on your system. If it isn't, use the package manager to install it. Then open a terminal and:
cd ~/.var/app/org.darktable.Darktable/config/darktable
git clone https://github.com/darktable-org/lua-scripts.git lua
### appimage packages
These packages run in their own environment and don't have access to a lua interpreter, therefore the scripts can't run. The packagers could enable the internal interpreter, or allow the package to link the interpreter from the operating system, or bundle a copy of lua with the package. If you use one of these packages and wish to use the lua scripts, please contact the package maintainer and suggest the above fixes.
### Linux and MacOS
Ensure git is installed on your system. If it isn't, use the package manager to install it. Then open a terminal and:
cd ~/.config/darktable/
git clone https://github.com/darktable-org/lua-scripts.git lua
### Windows
Ensure git is installed on your system. Git can be obtained from https://gitforwindows.org/, as well as other places. If you use the gitforwindows.org distribution, install the Git Bash Shell also as it will aid in debugging the scripts if necessary. Then open a command prompt and run:
cd %LOCALAPPDATA%\darktable
git clone https://github.com/darktable-org/lua-scripts.git lua
If you don't have %LOCALAPPDATA%\darktable you have to start dartable at least once, because the directory is created at the first start of darktable.
## Enabling
When darktable starts it looks for a file name `~/.config/darktable/luarc` (`%LOCALAPPDATA%\darktable\luarc` for windows) and reads it to see which scripts to include. The file is a plain text file with entries of the form `require "<directory>/<name>"` where directory is the directory containing the scripts, from the above list, and name is the name from the above list. To include GIMP the line would be `require "contrib/gimp"`.
The recommended way to enable and disable specific scripts is using the [script manager](https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/tools/script_manager/) module. To use script manager do the following:
### Linux or MacOS
echo 'require "tools/script_manager"' > ~/.config/darktable/luarc
### Windows
echo require "tools/script_manager" > %LOCALAPPDATA%\darktable\luarc
### Snap
echo 'require "tools/script_manager"' > ~/snap/darktable/current/luarc
### Flatpak
echo 'require "tools/script_manager"' > ~/.var/app/org.darktable.Darktable/config/darktable/luarc
You can also create or add lines to the luarc file from the command line:
`echo 'require "contrib/gimp"' > ~/.config/darktable/luarc` to create the file with a gimp entry\
or `echo 'require "contrib/hugin"' >> ~/.config/darktable/luarc` to add an entry for hugin.
On windows from a command prompt:
`echo require "contrib/gimp" > %LOCALAPPDATA%\darktable\luarc` to create the file with a gimp entry\
or `echo require "contrib/hugin" >> %LOCALAPPDATA%\darktable\luarc` to add an entry for hugin.
## Disabling
To disable a script open the luarc file in your text editor and insert `--` at the start of the line containing the script you wish to disable, then save the file.
## Updating
To update the script repository, open a terminal or command prompt and do the following:
### Snap
cd ~/snap/darktable/current/lua
git pull
### Flatpak
cd ~/.var/app/org.darktable.Darktable/config/darktable/lua
git pull
### Linux and MacOS
cd ~/.config/darktable/lua/
git pull
### Windows
cd %LOCALAPPDATA%\darktable\lua
git pull
## Documentation
The [Lua Scripts Manual](https://docs.darktable.org/lua/stable/lua.scripts.manual/) provides documentation
for the scripts transcribed from the header comments. Each script also contains comments and usage instructions
in the header comments.
The [Lua Scripts Library API Manual](https://docs.darktable.org/lua/stable/lua.scripts.api.manual/) provides
documentation of the libraries and functions. Lua-script libraries documentation may also be generated using
the tools in the tools/ directory.
More information about the scripting with Lua can be found in the darktable user manual:
[Scripting with Lua](https://darktable.org.github.io/dtdocs/lua/)
The [Lua API Manual](https://docs.darktable.org/lua/stable/lua.api.manual/) provides docuemntation of the
darktable Lua API.
## Troubleshooting
Running darktable with Lua debugging enabled provides more information about what is occurring within the scripts.
### Snap
Open a terminal and start darktable with the command `snap run darktable -d lua`. This provides debugging information to give you insight into what is happening.
### Linux
Open a terminal and start darktable with the command `darktable -d lua`. This provides debugging information to give you insight into what is happening.
### MacOS
Open a terminal and start darktable with the command `/Applications/darktable.app/Contents/MacOS/darktable -d lua`. This provides debugging information to give you insight into what is happening.
### Windows
Open a command prompt. Start darktable with the command "C:\Program Files\darktable\bin\darktable" -d lua > log.txt. This provides debugging information to give you insight into what is happening.
## Contributing
In order to have your own scripts added here they have to be under a free license (GPL2+ will definitely work, others can be discussed).

225
contrib/AutoGrouper.lua Normal file
View File

@@ -0,0 +1,225 @@
--[[AutoGrouper plugin for darktable
copyright (c) 2019 Kevin Ertel
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/>.
]]
--[[About this Plugin
This plugin adds the module "Auto Group" to darktable's lighttable view
----REQUIRED SOFTWARE----
None
----USAGE----
Install: (see here for more detail: https://github.com/darktable-org/lua-scripts )
1) Copy this file in to your "lua/contrib" folder where all other scripts reside.
2) Require this file in your luarc file, as with any other dt plug-in
Set a gap amount in second which will be used to determine when images should no
longer be added to a group. If an image is more then the specified amount of time
from the last image in the group it will not be added. Images without timestamps
in exif data will be ignored.
There are two buttons. One allows the grouping to be performed only on the currently
selected images, the other button performs grouping on the entire active collection
]]
local dt = require "darktable"
local du = require "lib/dtutils"
du.check_min_api_version("7.0.0", "AutoGrouper")
local MOD = 'autogrouper'
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("auto group"),
purpose = _("automatically group images by time interval"),
author = "Kevin Ertel",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/AutoGrouper/"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local Ag = {}
Ag.module_installed = false
Ag.event_registered = false
local GUI = {
gap = {},
selected = {},
collection = {}
}
local function InRange(test, low, high) --tests if test value is within range of low and high (inclusive)
if test >= low and test <= high then
return true
else
return false
end
end
local function CompTime(first, second) --compares the timestamps and returns true if first was taken before second
first_time = first.exif_datetime_taken
if string.match(first_time, '[0-9]') == nil then first_time = '9999:99:99 99:99:99' end
first_time = tonumber(string.gsub(first_time, '[^0-9]*',''))
second_time = second.exif_datetime_taken
if string.match(second_time, '[0-9]') == nil then second_time = '9999:99:99 99:99:99' end
second_time = tonumber(string.gsub(second_time, '[^0-9]*',''))
return first_time < second_time
end
local function SeperateTime(str) --seperates the timestamp into individual components for used with OS.time operations
local cleaned = string.gsub(str, '[^%d]',':')
cleaned = string.gsub(cleaned, '::*',':') --YYYY:MM:DD:hh:mm:ss
local year = string.sub(cleaned,1,4)
local month = string.sub(cleaned,6,7)
local day = string.sub(cleaned,9,10)
local hour = string.sub(cleaned,12,13)
local min = string.sub(cleaned,15,16)
local sec = string.sub(cleaned,18,19)
return {year = year, month = month, day = day, hour = hour, min = min, sec = sec}
end
local function GetTimeDiff(curr_image, prev_image) --returns the time difference (in sec.) from current image and the previous image
local curr_time = SeperateTime(curr_image.exif_datetime_taken)
local prev_time = SeperateTime(prev_image.exif_datetime_taken)
return os.time(curr_time)-os.time(prev_time)
end
local function main(on_collection)
local images = {}
if on_collection then
local col_images = dt.collection
for i,image in ipairs(col_images) do --copy images to a standard table, table.sort barfs on type dt_lua_singleton_image_collection
table.insert(images,i,image)
end
else
images = dt.gui.selection()
end
dt.preferences.write(MOD, 'active_gap', 'integer', GUI.gap.value)
if #images < 2 then
dt.print('please select at least 2 images')
return
end
table.sort(images, function(first, second) return CompTime(first,second) end) --sort images by timestamp
for i, image in ipairs(images) do
if i == 1 then
prev_image = image
image:make_group_leader()
elseif string.match(image.exif_datetime_taken, '[%d]') ~= nil then --make sure current image has a timestamp, if so check if it is within the user specified gap value and add to group
local curr_image = image
if GetTimeDiff(curr_image, prev_image) <= GUI.gap.value then
images[i]:group_with(images[i-1].group_leader)
end
prev_image = curr_image
end
end
end
local function install_module()
if not Ag.module_installed then
dt.print_log("installing module")
dt.register_lib(
MOD, -- Module name
_('auto group'), -- name
true, -- expandable
true, -- resetable
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 99}}, -- containers
dt.new_widget("box"){
orientation = "vertical",
GUI.gap,
GUI.selected,
GUI.collection
}
)
Ag.module_installed = true
dt.print_log("module installed")
dt.print_log("styles module visibility is " .. tostring(dt.gui.libs["styles"].visible))
end
end
local function destroy()
dt.gui.libs[MOD].visible = false
end
local function restart()
dt.gui.libs[MOD].visible = true
end
-- GUI --
temp = dt.preferences.read(MOD, 'active_gap', 'integer')
if not InRange(temp, 1, 86400) then temp = 3 end
GUI.gap = dt.new_widget('slider'){
label = _('group gap [sec.]'),
tooltip = _('minimum gap, in seconds, between groups'),
soft_min = 1,
soft_max = 60,
hard_min = 1,
hard_max = 86400,
step = 1,
digits = 0,
value = temp,
reset_callback = function(self)
self.value = 3
end
}
GUI.selected = dt.new_widget("button"){
label = _('auto group: selected'),
tooltip =_('auto group selected images'),
clicked_callback = function() main(false) end
}
GUI.collection = dt.new_widget("button"){
label = _('auto group: collection'),
tooltip =_('auto group the entire collection'),
clicked_callback = function() main(true) end
}
if dt.gui.current_view().id == "lighttable" then
install_module()
else
if not Ag.event_registered then
dt.register_event(
"AutoGrouper", "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
Ag.event_registered = true
end
end
script_data.destroy = destroy
script_data.destroy_method = "hide"
script_data.restart = restart
script_data.show = restart
return script_data

258
contrib/CollectHelper.lua Normal file
View File

@@ -0,0 +1,258 @@
--[[Collect Helper plugin for darktable
copyright (c) 2019 Kevin Ertel
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/>.
]]
--[[About this plugin
This plugin adds the button(s) to the "Selected Images" module:
1) Return to Previous Collection
2) Collect on image's Folder
3) Collect on image's Color Label(s)
4) Collect on All (AND)
It also adds 3 preferences to the lua options dialog box which allow the user to activate/deactivate the 3 "Collect on" buttons.
Button Behavior:
1) Return to Previous Collection - Will reset the collect parameters to the previously active settings
2) Collect on image's Folder - Will change the collect parameters to be "Folder" with a value of the selected image's folder location
3) Collect on image's Color Label(s) - Will change the collect parameter to be "Color" with a value of the selected images color labels, will apply multiple parameters with AND logic if multiple exist
4) Collect on All (AND) - Will collect on all parameters activated by the preferences dialog, as such this button is redundant if you only have one of the two other options enabled
----REQUIRED SOFTWARE----
NA
----USAGE----
Install: (see here for more detail: https://github.com/darktable-org/lua-scripts )
1) Copy this file in to your "lua/contrib" folder where all other scripts reside.
2) Require this file in your luarc file, as with any other dt plug-in
Select the photo you wish to change you collection based on.
In the "Selected Images" module click on "Collect on this Image"
----KNOWN ISSUES----
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local gettext = dt.gettext.gettext
local previous = nil
local all_active = false
du.check_min_api_version("7.0.0", "CollectHelper")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("collection helper"),
purpose = _("add collection helper buttons"),
author = "Kevin Ertel",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/CollectHelper/"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- FUNCTION --
local function CheckSingleImage(selection)
if #selection ~= 1 then
dt.print(_("please select a single image"))
return true
end
return false
end
local function CheckHasColorLabel(selection)
local ret = false
for _,image in pairs(selection) do
if image.red then ret = true end
if image.blue then ret = true end
if image.green then ret = true end
if image.yellow then ret = true end
if image.purple then ret = true end
end
return ret
end
local function PreviousCollection()
if previous ~= nil then
previous = dt.gui.libs.collect.filter(previous)
end
end
local function CollectOnFolder(all_rules, all_active)
local images = dt.gui.selection()
if CheckSingleImage(images) then
return
end
local rules = {}
local rule = dt.gui.libs.collect.new_rule()
rule.mode = "DT_LIB_COLLECT_MODE_AND"
rule.data = images[1].path
rule.item = "DT_COLLECTION_PROP_FOLDERS"
table.insert(rules, rule)
if all_active then
for _,active_rule in pairs(rules) do
table.insert(all_rules, active_rule)
end
return all_rules
else
previous = dt.gui.libs.collect.filter(rules)
end
end
local function CollectOnColors(all_rules, all_active)
local images = dt.gui.selection()
if CheckSingleImage(images) then
return
end
if not CheckHasColorLabel(images) then
dt.print(_('select an image with an active color label'))
return
end
for _,image in pairs(images) do
local rules = {}
if image.red then
local red_rule = dt.gui.libs.collect.new_rule()
red_rule.mode = "DT_LIB_COLLECT_MODE_AND"
red_rule.data = "red"
red_rule.item = "DT_COLLECTION_PROP_COLORLABEL"
table.insert(rules, red_rule)
end
if image.blue then
local blue_rule = dt.gui.libs.collect.new_rule()
blue_rule.mode = "DT_LIB_COLLECT_MODE_AND"
blue_rule.data = "blue"
blue_rule.item = "DT_COLLECTION_PROP_COLORLABEL"
table.insert(rules, blue_rule)
end
if image.green then
local green_rule = dt.gui.libs.collect.new_rule()
green_rule.mode = "DT_LIB_COLLECT_MODE_AND"
green_rule.data = "green"
green_rule.item = "DT_COLLECTION_PROP_COLORLABEL"
table.insert(rules, green_rule)
end
if image.yellow then
local yellow_rule = dt.gui.libs.collect.new_rule()
yellow_rule.mode = "DT_LIB_COLLECT_MODE_AND"
yellow_rule.data = "yellow"
yellow_rule.item = "DT_COLLECTION_PROP_COLORLABEL"
table.insert(rules, yellow_rule)
end
if image.purple then
local purple_rule = dt.gui.libs.collect.new_rule()
purple_rule.mode = "DT_LIB_COLLECT_MODE_AND"
purple_rule.data = "purple"
purple_rule.item = "DT_COLLECTION_PROP_COLORLABEL"
table.insert(rules, purple_rule)
end
if all_active then
for _,active_rule in pairs(rules) do
table.insert(all_rules, active_rule)
end
return all_rules
else
previous = dt.gui.libs.collect.filter(rules)
end
end
end
local function CollectOnAll_AND()
local images = dt.gui.selection()
if CheckSingleImage(images) then
return
end
local rules = {}
if dt.preferences.read('module_CollectHelper','folder','bool') then
rules = CollectOnFolder(rules, true)
end
if dt.preferences.read('module_CollectHelper','colors','bool') then
rules = CollectOnColors(rules, true)
end
previous = dt.gui.libs.collect.filter(rules)
end
local function destroy()
dt.gui.libs.image.destroy_action("CollectHelper_prev")
if dt.preferences.read('module_CollectHelper','folder','bool') then
dt.gui.libs.image.destroy_action("CollectHelper_folder")
end
if dt.preferences.read('module_CollectHelper','colors','bool') then
dt.gui.libs.image.destroy_action("CollectHelper_labels")
end
if dt.preferences.read('module_CollectHelper','all_and','bool') then
dt.gui.libs.image.destroy_action("CollectHelper_and")
end
end
-- GUI --
dt.gui.libs.image.register_action(
"CollectHelper_prev", _("collect: previous"),
function() PreviousCollection() end,
_("sets the collect parameters to be the previously active parameters")
)
if dt.preferences.read('module_CollectHelper','folder','bool') then
dt.gui.libs.image.register_action(
"CollectHelper_folder", _("collect: folder"),
function() CollectOnFolder(_ , false) end,
_("sets the collect parameters to be the selected images's folder")
)
end
if dt.preferences.read('module_CollectHelper','colors','bool') then
dt.gui.libs.image.register_action(
"CollectHelper_labels", _("collect: color label(s)"),
function() CollectOnColors(_ , false) end,
_("sets the collect parameters to be the selected images's color label(s)")
)
end
if dt.preferences.read('module_CollectHelper','all_and','bool') then
dt.gui.libs.image.register_action(
"CollectHelper_and", _("collect: all (AND)"),
function() CollectOnAll_AND() end,
_("sets the collect parameters based on all activated CollectHelper options")
)
end
-- PREFERENCES --
dt.preferences.register("module_CollectHelper", "all_and", -- name
"bool", -- type
_('CollectHelper: all'), -- label
_('creates a collect parameter set that utilizes all enabled CollectHelper types (and)'), -- tooltip
true -- default
)
dt.preferences.register("module_CollectHelper", "colors", -- name
"bool", -- type
_('CollectHelper: color label(s)'), -- label
_('enable the button that allows you to swap to a collection based on selected image\'s color label(s)'), -- tooltip
true -- default
)
dt.preferences.register("module_CollectHelper", "folder", -- name
"bool", -- type
_('CollectHelper: folder'), -- label
_('enable the button that allows you to swap to a collection based on selected image\'s folder location'), -- tooltip
true -- default
)
script_data.destroy = destroy
return script_data

486
contrib/HDRMerge.lua Normal file
View File

@@ -0,0 +1,486 @@
--[[HDRMerge plugin for darktable
copyright (c) 2018 Kevin Ertel
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/>.
]]
--[[About this Plugin
This plugin adds the module 'HDRMerge' to darktable's lighttable view
----REQUIRED SOFTWARE----
HDRMerge ver. 4.5 or greater
----USAGE----
Install: (see here for more detail: https://github.com/darktable-org/lua-scripts )
1) Copy this file in to your 'lua/contrib' folder where all other scripts reside.
2) Require this file in your luarc file, as with any other dt plug-in
On the initial startup go to darktable settings > lua options and set your executable paths and other preferences, then restart darktable
Select bracketed images and press the Run HDRMerge button. The resulting DNG will be auto-imported into darktable.
Additional tags or style can be applied on auto import as well, if you desire.
Base Options:
Select your desired BPS (bits per sample and Embedded Preview Size.
Batch Options:
Select if you want to run in batch mode or not
Select the gap, in seconds, between images for auto grouping in batch mode
See HDRMerge manual for further detail: http://jcelaya.github.io/hdrmerge/documentation/2014/07/11/user-manual.html
Auto-import Options:
Select a style, whether you want tags to be copied from the original, and any additional tags you desire added when the new image is auto-imported
]]
local dt = require 'darktable'
local du = require "lib/dtutils"
local df = require 'lib/dtutils.file'
local dsys = require 'lib/dtutils.system'
du.check_min_api_version("7.0.0", "HDRmerge")
-- Tell gettext where to find the .mo file translating messages for a particular domain
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("HDR merge"),
purpose = _("merge bracketed images into an HDR DNG image"),
author = "Kevin Ertel",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/HDRmerge"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local mod = 'module_HDRMerge'
local os_path_seperator = '/'
if dt.configuration.running_os == 'windows' then os_path_seperator = '\\' end
local CURR_API_STRING = dt.configuration.api_version_string
local temp
local HDRM = { --HDRMerge Program Table
name = 'HDRMerge',
bin = '',
first_run = true,
install_error = false,
arg_string = '',
images_string = '',
args = {
bps = {text = '-b ', style = 'integer'},
size = {text = '-p ', style = 'string'},
batch = {text = '-B ', style = 'bool'},
gap = {text = '-g ', style = 'integer'}
}
}
local GUI = { --GUI Elements Table
HDR = {
bps ={},
size ={},
batch ={},
gap ={}
},
Target = {
style ={},
copy_tags ={},
add_tags ={}
},
run = {},
stack = {},
options = {},
exes = {
HDRMerge = {},
update = {},
}
}
HDRM.module_installed = false
HDRM.event_registered = false
--Detect User Styles--
local styles = dt.styles
local styles_count = 1 -- 'none' = 1
for _,i in pairs(dt.styles) do
if type(i) == 'userdata' then styles_count = styles_count + 1 end
end
local function InRange(test, low, high) --tests if test value is within range of low and high (inclusive)
if test >= low and test <= high then
return true
else
return false
end
end
local function GetFileName(full_path) --Parses a full path (path/filename_identifier.extension) into individual parts
--[[Input: Folder1/Folder2/Folder3/Img_0001.CR2
Returns:
path: Folder1/Folder2/Folder3/
filename: Img_0001
identifier: 0001
extension: .CR2
EX:
path_1, file_1, id_1, ext_1 = GetFileName(full_path_1)
]]
local path = string.match(full_path, '.*[\\/]')
local filename = string.gsub(string.match(full_path, '[%w-_]*%.') , '%.' , '' )
local identifier = string.match(filename, '%d*$')
local extension = string.match(full_path, '%.%w*')
return path, filename, identifier, extension
end
local function CleanSpaces(text) --removes spaces from the front and back of passed in text
text = string.gsub(text,'^%s*','')
text = string.gsub(text,'%s*$','')
return text
end
local function BuildExecuteCmd(prog_table) --creates a program command using elements of the passed in program table
local result = CleanSpaces(prog_table.bin)..' '..CleanSpaces(prog_table.arg_string)..' '..CleanSpaces(prog_table.images_string)
return result
end
local function PreCall(prog_tbl) --looks to see if this is the first call, if so checks to see if program is installed properly
for _,prog in pairs(prog_tbl) do
if prog.first_run then
prog.bin = df.check_if_bin_exists(prog.name)
if not prog.bin then
prog.install_error = true
dt.preferences.write(mod, 'bin_exists', 'bool', false)
else
prog.bin = CleanSpaces(prog.bin)
end
prog.first_run = false
end
end
if not dt.preferences.read(mod, 'bin_exists', 'bool') then
GUI.stack.active = 2
dt.print(_('please update you binary location'))
end
end
local function ExeUpdate(prog_tbl)
dt.preferences.write(mod, 'bin_exists', 'bool', true)
for _,prog in pairs(prog_tbl) do
dt.preferences.write('executable_paths', prog.name, 'string', GUI.exes[prog.name].value)
prog.bin = df.check_if_bin_exists(prog.name)
if not prog.bin then
prog.install_error = true
dt.preferences.write(mod, 'bin_exists', 'bool', false)
else
prog.bin = CleanSpaces(prog.bin)
end
prog.first_run = false
end
if dt.preferences.read(mod, 'bin_exists', 'bool') then
GUI.stack.active = 1
dt.print(_('update successful'))
else
dt.print(_('update unsuccessful, please try again'))
end
end
local function UpdateActivePreference() --sliders & entry boxes do not have a click/changed callback, so their values must be saved to the active preference
temp = GUI.HDR.gap.value
dt.preferences.write(mod, 'active_gap', 'integer', temp)
temp = GUI.Target.add_tags.text
dt.preferences.write(mod, 'active_add_tags', 'string', temp)
end
local function main()
PreCall({HDRM}) --check if furst run then check if install OK
if HDRM.install_error then
dt.print_error('HDRMerge install issue')
dt.print(_('HDRMerge install issue, please ensure the binary path is correct'))
return
end
images = dt.gui.selection() --get selected images
if #images < 2 then --ensure enough images selected
dt.print(_('not enough images selected, select at least 2 images to merge'))
return
end
UpdateActivePreference() --save current gui elements to active preference so those values will be pre-loaded at next startup
--create image string and output path
HDRM.images_string = ''
local out_path = ''
local smallest_id = math.huge
local smallest_name = ''
local largest_id = 0
local source_raw = {}
for _,image in pairs(images) do --loop to concat the images string, also track the image indexes for use in creating the final image name (eg; IMG_1034-1037.dng)
local curr_image = image.path..os_path_seperator..image.filename
HDRM.images_string = HDRM.images_string..df.sanitize_filename(curr_image)..' '
out_path = image.path
_unused, source_name, source_id = GetFileName(image.filename)
source_id = tonumber(source_id) or 0
if source_id < smallest_id then
smallest_id = source_id
smallest_name = source_name
source_raw = image
end
if source_id > largest_id then largest_id = source_id end
end
out_path = out_path..os_path_seperator..smallest_name..'-'..largest_id..'.dng'
out_path = df.create_unique_filename(out_path)
--create argument string
HDRM.arg_string = HDRM.args.bps.text..GUI.HDR.bps.value..' '..HDRM.args.size.text..GUI.HDR.size.value..' '
if GUI.HDR.batch.value then
HDRM.arg_string = HDRM.arg_string..HDRM.args.batch.text..HDRM.args.gap.text..math.floor(GUI.HDR.gap.value)..' -a'
else
HDRM.arg_string = HDRM.arg_string..'-o '..df.sanitize_filename(out_path)
end
-- create run command and execute
local run_cmd = BuildExecuteCmd(HDRM)
resp = dsys.external_command(run_cmd)
if resp == 0 and not GUI.HDR.batch.value then
local imported = dt.database.import(out_path) -- import the new file
if GUI.Target.style.selected > 1 then -- apply selected style
local set_style = styles[GUI.Target.style.selected - 1]
dt.styles.apply(set_style , imported)
end
if GUI.Target.copy_tags.value then -- copy tags from the original file (ignore 'darktable' generated tags)
local all_tags = dt.tags.get_tags(source_raw)
for _,tag in pairs(all_tags) do
if string.match(tag.name, 'darktable|') == nil then dt.tags.attach(tag, imported) end
end
end
local set_tag = GUI.Target.add_tags.text
if set_tag ~= nil then -- add additional user-specified tags
for tag in string.gmatch(set_tag, '[^,]+') do
tag = CleanSpaces(tag)
tag = dt.tags.create(tag)
dt.tags.attach(tag, imported)
end
end
dt.print(_('HDRMerge completed successfully'))
else
dt.print_error('HDRMerge failed')
dt.print(_('HDRMerge failed'))
end
end
local function install_module()
if not HDRM.module_installed then
dt.register_lib( -- register HDRMerge module
'HDRMerge_Lib', -- Module name
_('HDRMerge'), -- name
true, -- expandable
true, -- resetable
{[dt.gui.views.lighttable] = {'DT_UI_CONTAINER_PANEL_RIGHT_CENTER', 99}}, -- containers
dt.new_widget('box'){
orientation = 'vertical',
GUI.stack
}
)
HDRM.module_installed = true
end
end
local function destroy()
dt.gui.libs["HDRMerge_Lib"].visible = false
end
local function restart()
dt.gui.libs["HDRMerge_Lib"].visible = true
end
-- GUI Elements --
local lbl_hdr = dt.new_widget('section_label'){
label = _('HDRMerge options')
}
temp = dt.preferences.read(mod, 'active_bps_ind', 'integer')
if not InRange(temp, 1, 3) then temp = 3 end
GUI.HDR.bps = dt.new_widget('combobox'){
label = _('bits per sample'),
tooltip =_('number of bits per sample in the output image'),
selected = temp,
'16','24','32',
changed_callback = function(self)
dt.preferences.write(mod, 'active_bps', 'integer', self.value)
dt.preferences.write(mod, 'active_bps_ind', 'integer', self.selected)
end,
reset_callback = function(self)
self.selected = 3
dt.preferences.write(mod, 'active_bps', 'integer', self.value)
dt.preferences.write(mod, 'active_bps_ind', 'integer', self.selected)
end
}
temp = dt.preferences.read(mod, 'active_size_ind', 'integer')
if not InRange(temp, 1, 3) then temp = 2 end
GUI.HDR.size = dt.new_widget('combobox'){
label = _('embedded preview size'),
tooltip =_('size of the embedded preview in output image'),
selected = temp,
_('none'),_('half'),_('full'),
changed_callback = function(self)
dt.preferences.write(mod, 'active_size', 'string', self.value)
dt.preferences.write(mod, 'active_size_ind', 'integer', self.selected)
end,
reset_callback = function(self)
self.selected = 2
dt.preferences.write(mod, 'active_size', 'string', self.value)
dt.preferences.write(mod, 'active_size_ind', 'integer', self.selected)
end
}
GUI.HDR.batch = dt.new_widget('check_button'){
label = _('batch mode'),
value = dt.preferences.read(mod, 'active_batch', 'bool'),
tooltip = _('enable batch mode operation \nNOTE: resultant files will NOT be auto-imported'),
clicked_callback = function(self)
dt.preferences.write(mod, 'active_batch', 'bool', self.value)
GUI.HDR.gap.sensitive = self.value
end,
reset_callback = function(self) self.value = false end
}
temp = dt.preferences.read(mod, 'active_gap', 'integer')
if not InRange(temp, 1, 3600) then temp = 3 end
GUI.HDR.gap = dt.new_widget('slider'){
label = _('batch gap [sec.]'),
tooltip = _('gap, in seconds, between batch mode groups'),
soft_min = 1,
soft_max = 30,
hard_min = 1,
hard_max = 3600,
step = 1,
digits = 0,
value = temp,
sensitive = GUI.HDR.batch.value,
reset_callback = function(self)
self.value = 3
end
}
local lbl_import = dt.new_widget('section_label'){
label = _('import options')
}
GUI.Target.style = dt.new_widget('combobox'){
label = _('apply style on import'),
tooltip = _('apply selected style on auto-import to newly created image'),
selected = 1,
_('none'),
changed_callback = function(self)
dt.preferences.write(mod, 'active_style', 'string', self.value)
dt.preferences.write(mod, 'active_style_ind', 'integer', self.selected)
end,
reset_callback = function(self)
self.selected = 1
dt.preferences.write(mod, 'active_style', 'string', self.value)
dt.preferences.write(mod, 'active_style_ind', 'integer', self.selected)
end
}
for k=1, (styles_count-1) do
GUI.Target.style[k+1] = styles[k].name
end
temp = dt.preferences.read(mod, 'active_style_ind', 'integer')
if not InRange(temp, 1, styles_count) then temp = 1 end
GUI.Target.style.selected = temp
GUI.Target.copy_tags = dt.new_widget('check_button'){
label = _('copy tags'),
value = dt.preferences.read(mod, 'active_copy_tags', 'bool'),
tooltip = _('copy tags from first source image'),
clicked_callback = function(self) dt.preferences.write(mod, 'active_copy_tags', 'bool', self.value) end,
reset_callback = function(self) self.value = true end
}
temp = dt.preferences.read(mod, 'active_add_tags', 'string')
if temp == '' then temp = nil end
GUI.Target.add_tags = dt.new_widget('entry'){
tooltip = _('additional tags to be added on import, separate with commas, all spaces will be removed'),
text = temp,
placeholder = _('enter tags, separated by commas'),
editable = true
}
GUI.run = dt.new_widget('button'){
label = _('merge'),
tooltip =_('run HDRMerge with the above settings'),
clicked_callback = function() main() end
}
GUI.exes.HDRMerge = dt.new_widget('file_chooser_button'){
title = _('select HDRmerge executable'),
value = df.get_executable_path_preference(HDRM.name),
is_directory = false
}
GUI.exes.update = dt.new_widget('button'){
label = _('update'),
tooltip =_('update the binary path with current value'),
clicked_callback = function() ExeUpdate({HDRM}) end
}
GUI.options = dt.new_widget('box'){
orientation = 'vertical',
lbl_hdr,
GUI.HDR.bps,
GUI.HDR.size,
GUI.HDR.batch,
GUI.HDR.gap,
lbl_import,
GUI.Target.style,
GUI.Target.copy_tags,
GUI.Target.add_tags,
GUI.run
}
local exes_box = dt.new_widget('box'){
orientation = 'vertical',
GUI.exes.HDRMerge,
GUI.exes.update
}
GUI.stack = dt.new_widget('stack'){
GUI.options,
exes_box
}
if dt.preferences.read(mod, 'bin_exists', 'bool') then
GUI.stack.active = 1
else
GUI.stack.active = 2
end
if dt.gui.current_view().id == "lighttable" then
install_module()
else
if not HDRM.event_registered then
dt.register_event(
"HDRmerge", "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
HDRM.event_registered = true
end
end
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = restart
return script_data

296
contrib/LabelsToTags.lua Normal file
View File

@@ -0,0 +1,296 @@
--[[
LABELS TO TAGS
Allows the mass-application of tags using color labels and ratings
as a guide.
AUTHOR
August Schwerdfeger (august@schwerdfeger.name)
INSTALLATION
* Copy this file into $CONFIGDIR/lua/, where CONFIGDIR
is your darktable configuration directory
* Add the following line in the file $CONFIGDIR/luarc:
require "LabelsToTags"
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
None.
USAGE
In your 'luarc' file or elsewhere, use the function
'register_tag_mapping', defined in this module, to specify
one or more tag mappings for use by the module.
Any mappings so registered will be selectable, according
to their given names, in the module's "mapping" combo box.
A mapping takes the form of a table mapping patterns to
lists of tags. A pattern consists of 6 characters, of which
the first five represent color labels and the last the rating.
Each color label character may be '+', '-', or '*',
indicating that for this pattern to match, the corresponding
color label, respectively, must be on, must be off, or can be
either. Similarly, the rating character may be a numeral
between 0 and 5, "R" for rejected, or "*" for "any value."
An example call to 'register_tag_mapping' is provided in a
comment at the end of this file.
When the "Start" button is pressed, the module will
iterate over each selected image and check the state of
that image's color labels and rating against each pattern
defined in the selected mapping. For each pattern that
matches, the corresponding tags will be added to the
image. Any such tag not already existing in the database
will be created.
LICENSE
LGPLv2+
]]
local darktable = require("darktable")
local du = require "lib/dtutils"
du.check_min_api_version("7.0.0", "LabelsToTags")
local gettext = darktable.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("labels to tags"),
purpose = _("allows the mass-application of tags using color labels and ratings as a guide"),
author = "August Schwerdfeger (august@schwerdfeger.name)",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/LabelsToTags"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Lua 5.3 no longer has "unpack" but "table.unpack"
unpack = unpack or table.unpack
local ltt = {}
ltt.module_installed = false
ltt.event_registered = false
local LIB_ID = _("LabelsToTags")
-- Helper functions: BEGIN
local function keySet(t)
local rv = {}
for k,_ in pairs(t) do
table.insert(rv,k)
end
table.sort(rv)
return(rv)
end
local function generateLabelHash(img)
local hash = ""
hash = hash .. (img.red and "+" or "-")
hash = hash .. (img.yellow and "+" or "-")
hash = hash .. (img.green and "+" or "-")
hash = hash .. (img.blue and "+" or "-")
hash = hash .. (img.purple and "+" or "-")
hash = hash .. (img.rating == -1 and "R" or tostring(img.rating))
return(hash)
end
local function hashMatch(hash,pattern)
if #(hash) ~= #(pattern) then return(false) end
for i = 0,#hash do
if string.sub(hash,i,i) ~= string.sub(pattern,i,i) and
string.sub(pattern,i,i) ~= "*" then
return(false)
end
end
return(true)
end
-- Helper functions: END
local initialAvailableMappings = {
[_("colors")] = { ["+*****"] = { _("red") },
["*+****"] = { _("yellow") },
["**+***"] = { _("green") },
["***+**"] = { _("blue") },
["****+*"] = { _("purple") } },
[_("single colors")] = { ["+----*"] = { _("red"), _("only red") },
["-+---*"] = { _("yellow"), _("only yellow") },
["--+--*"] = { _("green"), _("only green") },
["---+-*"] = { _("blue"), _("only blue") },
["----+*"] = { _("purple"), _("only purple") } },
[_("ratings")] = { ["*****0"] = { _("no stars"), _("not rejected") },
["*****1"] = { _("one star"), _("not rejected") },
["*****2"] = { _("two stars"), _("not rejected") },
["*****3"] = { _("three stars"), _("not rejected") },
["*****4"] = { _("four stars"), _("not rejected") },
["*****5"] = { _("five stars"), _("not rejected") },
["*****R"] = { _("rejected") } }
}
local availableMappings = {}
local function getAvailableMappings()
if availableMappings == nil or next(availableMappings) == nil then
return(initialAvailableMappings)
else
return(availableMappings)
end
end
local function getComboboxTooltip()
if availableMappings == nil or next(availableMappings) == nil then
return(_("no registered mappings -- using defaults"))
else
return(_("select a label-to-tag mapping"))
end
end
local mappingComboBox = darktable.new_widget("combobox"){
label = _("mapping"),
value = 1,
tooltip = getComboboxTooltip(),
reset_callback = function(selfC)
if selfC == nil then
return
end
i = 1
for _,m in pairs(keySet(getAvailableMappings())) do
selfC[i] = m
i = i+1
end
n = #selfC
for j = i,n do
selfC[i] = nil
end
selfC.value = 1
selfC.tooltip = getComboboxTooltip()
end,
unpack(keySet(getAvailableMappings()))
}
local function doTagging(selfC)
local job = darktable.gui.create_job(string.format(_("labels to tags (%d image%s)"), #(darktable.gui.action_images), (#(darktable.gui.action_images) == 1 and "" or "s")), true)
job.percent = 0.0
local pctIncrement = 1.0 / #(darktable.gui.action_images)
local availableMappings = getAvailableMappings()
local memoizedTags = {}
for _,img in ipairs(darktable.gui.action_images) do
local tagsToApply = {}
local hash = generateLabelHash(img)
for k,v in pairs(availableMappings[mappingComboBox.value]) do
if hashMatch(hash,k) then
for _,tag in ipairs(v) do
tagsToApply[tag] = true
end
end
end
for k,_ in pairs(tagsToApply) do
if memoizedTags[k] == nil then
memoizedTags[k] = darktable.tags.create(k)
end
darktable.tags.attach(memoizedTags[k],img)
end
job.percent = job.percent + pctIncrement
end
job.valid = false
end
ltt.my_widget = darktable.new_widget("box") {
orientation = "vertical",
mappingComboBox,
darktable.new_widget("button") {
label = _("start"),
tooltip = _("tag all selected images"),
clicked_callback = doTagging
}
}
local PATTERN_PATTERN = "^[+*-][+*-][+*-][+*-][+*-][0-5R*]$"
darktable.register_tag_mapping = function(name, mapping)
if availableMappings[name] ~= nil then
darktable.print_error("Tag mapping '" .. name .. "' already registered")
return
end
for pattern,tags in pairs(mapping) do
if string.match(pattern,PATTERN_PATTERN) == nil then
darktable.print_error("In tag mapping '" .. name .. "': Pattern '" .. pattern .. "' invalid")
return
end
for _,tag in ipairs(tags) do
if type(tag) ~= "string" then
darktable.print_error("In tag mapping '" .. name .. "': All tag mappings must be lists of strings")
return
end
end
end
availableMappings[name] = mapping
mappingComboBox.reset_callback(mappingComboBox)
end
local function install_module()
if not ltt.module_installed then
darktable.register_lib(LIB_ID,_("labels to tags"),true,true,{
[darktable.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER",20},
},ltt.my_widget,nil,nil)
ltt.module_installed = true
end
end
local function destroy()
darktable.gui.libs[LIB_ID].visible = false
end
local function restart()
darktable.gui.libs[LIB_ID].visible = true
end
--[[
darktable.register_tag_mapping("Example",
{ ["+----*"] = { "Red", "Only red" },
["-+---*"] = { "Yellow", "Only yellow" },
["--+--*"] = { "Green", "Only green" },
["---+-*"] = { "Blue", "Only blue" },
["****+*"] = { "Purple" },
["----+*"] = { "Only purple" },
["*****1"] = { "One star" },
["*****R"] = { "Rejected" } })
]]
if darktable.gui.current_view().id == "lighttable" then
install_module()
else
if not ltt.event_registered then
darktable.register_event(
LIB_ID, "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
ltt.event_registered = true
end
end
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = restart
return script_data

261
contrib/OpenInExplorer.lua Normal file
View File

@@ -0,0 +1,261 @@
--[[
OpenInExplorer plugin for darktable
copyright (c) 2018 Kevin Ertel
Update 2020 and macOS support by Volker Lenhardt
Linux support 2020 by Bill Ferguson
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/>.
]]
--[[About this plugin
This plugin adds the module "OpenInExplorer" to darktable's lighttable view.
----REQUIRED SOFTWARE----
Apple macOS, Microsoft Windows or Linux
----USAGE----
Install: (see here for more detail: https://github.com/darktable-org/lua-scripts )
1) Copy this file into your "lua/contrib" folder where all other scripts reside.
2) Require this file in your luarc file, as with any other dt plug-in
Select the photo(s) you wish to find in your operating system's file manager and press "show in file explorer" in the "selected images" section.
- Nautilus (Linux), Explorer (Windows), and Finder (macOS prior to Mojave) will open one window for each selected image at the file's location. The file name will be highlighted.
- On macOS Mojave and Catalina the Finder will open one window for each different directory. In these windows only the last one of the corresponding files will be highlighted (bug or feature?).
- Dolphin (Linux) will open one window with tabs for the different directories. All the selected images' file names are highlighted in their respective directories.
As an alternative option you can choose to show the image file names as symbolic links in an arbitrary directory. Go to preferences|Lua options. This option is not available for Windows users as on Windows solely admins are allowed to create links.
- Pros: You do not clutter up your display with multiple windows. So there is no need to limit the number of selections.
- Cons: If you want to work with the files you are one step behind the original data.
----KNOWN ISSUES----
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
--Check API version
du.check_min_api_version("7.0.0", "OpenInExplorer")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("open in explorer"),
purpose = _("open a selected file in the system file manager"),
author = "Kevin Ertel",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/OpenInExplorer"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local act_os = dt.configuration.running_os
local PS = act_os == "windows" and "\\" or "/"
--Detect OS and quit if it is not supported.
if act_os ~= "macos" and act_os ~= "windows" and act_os ~= "linux" then
dt.print(_("OpenInExplorer plug-in only supports linux, macos, and windows at this time"))
dt.print_error("OpenInExplorer plug-in only supports Linux, macOS, and Windows at this time")
return
end
local use_links, links_dir = false, ""
if act_os ~= "windows" then
use_links = dt.preferences.read("OpenInExplorer", "use_links", "bool")
links_dir = dt.preferences.read("OpenInExplorer", "linked_image_files_dir", "string")
end
--Check if the directory exists that was chosen for the file links. Return boolean.
local function check_if_links_dir_exists()
local dir_exists = true
if not links_dir then
--Just for paranoic reasons. I tried, but I couldn't devise a setting for a nil value.
dt.print(_("no links directory selected\nplease check the dt preferences (lua options)"))
dt.print_error("OpenInExplorer: No links directory selected")
dir_exists = false
elseif not df.check_if_file_exists(links_dir) then
dt.print(string.format(_("links directory '%s' not found\nplease check the dt preferences (lua options)"), links_dir))
dt.print_error(string.format("OpenInExplorer: Links directory '%s' not found", links_dir))
dir_exists = false
end
return dir_exists
end
--Format strings for the commands to open the corresponding OS's file manager.
local open_dir = {}
open_dir.windows = "explorer.exe /n, %s"
open_dir.macos = "open %s"
open_dir.linux = [[busctl --user call org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1 ShowFolders ass 1 %s ""]]
local open_files = {}
open_files.windows = "explorer.exe /select, %s"
open_files.macos = "osascript -e 'tell application \"Finder\" to (reveal {%s}) activate'"
open_files.linux = [[busctl --user call org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1 ShowItems ass %d %s ""]]
reveal_file_osx_cmd = "\"%s\" as POSIX file"
--Call the osx Finder with each selected image selected.
--For images in multiple folders, Finder will open a separate window for each
local function call_list_of_files_osx(selected_images)
local cmds = {}
for _, image in pairs(selected_images) do
current_image = image.path..PS..image.filename
-- AppleScript needs double quoted strings, and the whole command is wrapped in single quotes.
table.insert(cmds, string.format(reveal_file_osx_cmd, string.gsub(string.gsub(current_image, "\"", "\\\""), "'", "'\"'\"'")))
end
reveal_cmd = table.concat(cmds, ",")
run_cmd = string.format(open_files.macos, reveal_cmd)
dt.print_log("OSX run_cmd = "..run_cmd)
dsys.external_command(run_cmd)
end
--Call the file mangager for each selected image on Linux.
--There is one call to busctl containing a list of all the image file names.
local function call_list_of_files(selected_images)
local current_image, file_uris, run_cmd = "", "", ""
for _, image in pairs(selected_images) do
current_image = image.path..PS..image.filename
file_uris = file_uris .. df.sanitize_filename("file://" .. current_image) .. " "
dt.print_log("file_uris is " .. file_uris)
end
run_cmd = string.format(open_files.linux, #selected_images, file_uris)
dt.print_log("OpenInExplorer run_cmd = "..run_cmd)
dsys.external_command(run_cmd)
end
--Call the file manager for each selected image on Windows and macOS.
local function call_file_by_file(selected_images)
local current_image, run_cmd = "", ""
for _, image in pairs(selected_images) do
current_image = image.path..PS..image.filename
run_cmd = string.format(open_files[act_os], df.sanitize_filename(current_image))
dt.print_log("OpenInExplorer run_cmd = "..run_cmd)
dsys.external_command(run_cmd)
end
end
--Create a link for each selected image, and finally call the file manager.
local function set_links(selected_images)
local current_image, link_target, run_cmd, k = "", "", "", nil
for k, image in pairs(selected_images) do
current_image = image.path..PS..image.filename
link_target = df.create_unique_filename(links_dir .. PS .. image.filename)
run_cmd = string.format("ln -s %s %s", df.sanitize_filename(current_image), df.sanitize_filename(link_target))
--[[
In case Windows will allow normal users to create soft links:
if act_os == "windows" then
run_cmd = string.format("mklink %s %s", df.sanitize_filename(link_target), df.sanitize_filename(current_image))
end
]]
if dsys.external_command(run_cmd) ~= 0 then
dt.print(_("failed to create links, missing rights?"))
dt.print_error("OpenInExplorer: Failed to create links")
return
end
end
--The URI format is necessary only for the Linux busctl command.
--But it is accepted by the Windows Explorer and macOS's Finder all the same.
run_cmd = string.format(open_dir[act_os], df.sanitize_filename("file://"..links_dir))
dt.print_log("OpenInExplorer run_cmd = "..run_cmd)
dsys.external_command(run_cmd)
end
--The working function that starts the particular task.
local function open_in_fmanager()
local images = dt.gui.selection()
if #images == 0 then
dt.print(_("please select an image"))
else
if use_links and not check_if_links_dir_exists() then
return
end
if #images > 15 and not use_links then
dt.print(_("please select fewer images (max. 15)"))
elseif use_links then
set_links(images)
else
if act_os == "linux" then
call_list_of_files(images)
elseif act_os == "macos" then
call_list_of_files_osx(images)
else
call_file_by_file(images)
end
end
end
end
local function destroy()
dt.gui.libs.image.destroy_action("OpenInExplorer")
dt.destroy_event("OpenInExplorer", "shortcut")
if act_os ~= "windows" then
dt.preferences.destroy("OpenInExplorer", "linked_image_files_dir")
end
dt.preferences.destroy("OpenInExplorer", "use_links")
end
-- GUI --
dt.gui.libs.image.register_action(
"OpenInExplorer", _("show in file explorer"),
function() open_in_fmanager() end,
_("open the file manager at the selected image's location")
)
if act_os ~= "windows" then
dt.preferences.register("OpenInExplorer", "linked_image_files_dir", -- name
"directory", -- type
_("OpenInExplorer: linked files directory"), -- label
_("directory to store the links to the file names, requires restart to take effect"), -- tooltip
"Links to image files", -- default
dt.new_widget("file_chooser_button"){
title = _("select directory"),
is_directory = true,
}
)
dt.preferences.register("OpenInExplorer", "use_links", -- name
"bool", -- type
_("OpenInExplorer: use links"), -- label
_("use links instead of multiple windows, requires restart to take effect"), -- tooltip
false, -- default
""
)
end
dt.register_event(
"OpenInExplorer", "shortcut",
function(event, shortcut) open_in_fmanager() end,
"OpenInExplorer"
)
script_data.destroy = destroy
return script_data

272
contrib/RL_out_sharp.lua Normal file
View File

@@ -0,0 +1,272 @@
--[[
Richardson-Lucy output sharpening for darktable using GMic
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/>.
]]
--[[
DESCRIPTION
RL_out_sharp.lua - Richardson-Lucy output sharpening using GMic
This script provides a new target storage "RL output sharpen".
Images exported will be sharpened using GMic (RL deblur algorithm)
REQUIRED SOFTWARE
GMic command line interface (CLI) https://gmic.eu/download.shtml
USAGE
* require this script from main lua file
* in lua preferences, select the GMic cli executable
* from "export selected", choose "RL output sharpen"
* configure output folder
* configure RL parameters with sliders
* configure temp files format and quality, jpg 8bpp (good quality)
and tif 16bpp (best quality) are supported
* configure other export options (size, etc.)
* export, images will be first exported in the temp format, then sharpened
* sharpened images will be stored in jpg format in the output folder
EXAMPLE
set sigma = 0.7, iterations = 10, jpeg output quality = 95,
to correct blur due to image resize for web usage
CAVEATS
MAC compatibility not tested
Although Darktable can handle file names containing spaces, GMic cli cannot,
so if you want to use this script please make sure that your images do not
have spaces in the file name and path
BUGS, COMMENTS, SUGGESTIONS
send to Marco Carrarini, marco.carrarini@gmail.com
CHANGES
* 20200308 - initial version
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
-- module name
local MODULE_NAME = "RL_out_sharp"
-- check API version
du.check_min_api_version("7.0.0", MODULE_NAME)
-- translation
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("RL output sharpening"),
purpose = _("Richardson-Lucy output sharpening using GMic"),
author = "Marco Carrarini <marco.carrarini@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/RL_out_sharp"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- OS compatibility
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
-- initialize module preferences
if not dt.preferences.read(MODULE_NAME, "initialized", "bool") then
dt.preferences.write(MODULE_NAME, "sigma", "string", "0.7")
dt.preferences.write(MODULE_NAME, "iterations", "string", "10")
dt.preferences.write(MODULE_NAME, "jpg_quality", "string", "95")
dt.preferences.write(MODULE_NAME, "initialized", "bool", true)
end
-- preserve original image metadata in the output image -----------------------
local function preserve_metadata(original, sharpened)
local exiftool = df.check_if_bin_exists("exiftool")
if exiftool then
dtsys.external_command("exiftool -overwrite_original_in_place -tagsFromFile " .. original .. " " .. sharpened)
else
dt.print_log(MODULE_NAME .. " exiftool not found, metadata not preserved")
end
end
-- setup export ---------------------------------------------------------------
local function setup_export(storage, img_format, image_table, high_quality, extra_data)
-- set 16bpp if format is tif
if img_format.extension == "tif" then
img_format.bpp = 16
end
end
-- temp export formats: jpg and tif are supported -----------------------------
local function supported(storage, img_format)
return (img_format.extension == "jpg") or (img_format.extension == "tif")
end
-- export and sharpen images --------------------------------------------------
local function export2RL(storage, image_table, extra_data)
local temp_name, new_name, run_cmd, result
local input_file, output_file, options
-- read parameters
local gmic = dt.preferences.read(MODULE_NAME, "gmic_exe", "string")
if gmic == "" then
dt.print(_("GMic executable not configured"))
return
end
gmic = df.sanitize_filename(gmic)
local output_folder = output_folder_selector.value
local sigma_str = string.gsub(string.format("%.2f", sigma_slider.value), ",", ".")
local iterations_str = string.format("%.0f", iterations_slider.value)
local jpg_quality_str = string.format("%.0f", jpg_quality_slider.value)
-- save preferences
dt.preferences.write(MODULE_NAME, "sigma", "string", sigma_str)
dt.preferences.write(MODULE_NAME, "iterations", "string", iterations_str)
dt.preferences.write(MODULE_NAME, "jpg_quality", "string", jpg_quality_str)
local gmic_operation = " -deblur_richardsonlucy "..sigma_str..","..iterations_str..",1"
local i = 0
for image, temp_name in pairs(image_table) do
i = i + 1
dt.print(string.format(_("sharpening image %d ..."), i))
-- create unique filename
new_name = output_folder..PS..df.get_basename(temp_name)..".jpg"
new_name = df.create_unique_filename(new_name)
-- build the GMic command string
input_file = df.sanitize_filename(temp_name)
output_file = df.sanitize_filename(new_name)
options = " cut 0,255 round "
if df.get_filetype(temp_name) == "tif" then options = " -/ 256"..options end
run_cmd = gmic.." "..input_file..gmic_operation..options.."o "..output_file..","..jpg_quality_str
result = dtsys.external_command(run_cmd)
if result ~= 0 then
dt.print(_("sharpening error"))
return
end
-- copy metadata from input_file to output_file
preserve_metadata(input_file, output_file)
-- delete temp image
os.remove(temp_name)
end
dt.print(_("finished exporting"))
end
-- script_manager integration
local function destroy()
dt.destroy_storage("exp2RL")
end
-- new widgets ----------------------------------------------------------------
output_folder_selector = dt.new_widget("file_chooser_button"){
title = _("select output folder"),
tooltip = _("select output folder"),
value = dt.preferences.read(MODULE_NAME, "output_folder", "string"),
is_directory = true,
changed_callback = function(self)
dt.preferences.write(MODULE_NAME, "output_folder", "string", self.value)
end
}
sigma_slider = dt.new_widget("slider"){
label = _("sigma"),
tooltip = _("controls the width of the blur that's applied"),
soft_min = 0.3,
soft_max = 2.0,
hard_min = 0.0,
hard_max = 3.0,
step = 0.05,
digits = 2,
value = 1.0
}
iterations_slider = dt.new_widget("slider"){
label = _("iterations"),
tooltip = _("increase for better sharpening, but slower"),
soft_min = 0,
soft_max = 100,
hard_min = 0,
hard_max = 100,
step = 5,
digits = 0,
value = 10.0
}
jpg_quality_slider = dt.new_widget("slider"){
label = _("output jpg quality"),
tooltip = _("quality of the output jpg file"),
soft_min = 70,
soft_max = 100,
hard_min = 70,
hard_max = 100,
step = 2,
digits = 0,
value = 95.0
}
local storage_widget = dt.new_widget("box"){
orientation = "vertical",
output_folder_selector,
sigma_slider,
iterations_slider,
jpg_quality_slider
}
-- register new storage -------------------------------------------------------
dt.register_storage("exp2RL", _("RL output sharpen"), nil, export2RL, supported, save_preferences, storage_widget)
-- register the new preferences -----------------------------------------------
dt.preferences.register(MODULE_NAME, "gmic_exe", "file",
_("executable for GMic CLI"),
_("select executable for GMic command line version") , "")
-- set sliders to the last used value at startup ------------------------------
sigma_slider.value = dt.preferences.read(MODULE_NAME, "sigma", "float")
iterations_slider.value = dt.preferences.read(MODULE_NAME, "iterations", "float")
jpg_quality_slider.value = dt.preferences.read(MODULE_NAME, "jpg_quality", "float")
-- script_manager integration
script_data.destroy = destroy
return script_data
-- end of script --------------------------------------------------------------
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
-- kate: hl Lua;

132
contrib/auto_snapshot.lua Normal file
View File

@@ -0,0 +1,132 @@
--[[
auto_snapshot.lua - automatically take a snapshot when an image is loaded in darkroom
Copyright (C) 2024 Bill Ferguson <wpferguson@gamil.com>.
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
]]
--[[
auto_snapshot -
automatically take a snapshot when an image is loaded in darkroom
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
None
USAGE
* start the script from script_manager
* open an image in darkroom
BUGS, COMMENTS, SUGGESTIONS
Bill Ferguson <wpferguson@gamil.com>
CHANGES
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local log = require "lib/dtutils.log"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- C O N S T A N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
local MODULE <const> = "auto_snapshot"
local DEFAULT_LOG_LEVEL <const> = log.error
-- - - - - - - - - - - - - - - - - - - - - - - -
-- A P I C H E C K
-- - - - - - - - - - - - - - - - - - - - - - - -
du.check_min_api_version("7.0.0", MODULE) -- choose the minimum version that contains the features you need
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- I 1 8 N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- S C R I P T M A N A G E R I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local script_data = {}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
script_data.metadata = {
name = _("auto snapshot"), -- name of script
purpose = _("automatically take a snapshot when an image is loaded in darkroom"), -- purpose of script
author = "Bill Ferguson <wpferguson@gamil.com>", -- your name and optionally e-mail address
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/auto_snapshot/" -- URL to help/documentation
}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- L O G L E V E L
-- - - - - - - - - - - - - - - - - - - - - - - -
log.log_level(DEFAULT_LOG_LEVEL)
-- - - - - - - - - - - - - - - - - - - - - - - -
-- N A M E S P A C E
-- - - - - - - - - - - - - - - - - - - - - - - -
local auto_snapshot = {}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- P R E F E R E N C E S
-- - - - - - - - - - - - - - - - - - - - - - - -
dt.preferences.register(MODULE, "always_create_snapshot", "bool", "auto_snapshot - " .. _("always automatically create_snapshot"),
_("create a snapshot even if the image is altered"), false)
-- - - - - - - - - - - - - - - - - - - - - - - -
-- D A R K T A B L E I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - -
local function destroy()
dt.destroy_event(MODULE, "darkroom-image-loaded")
end
script_data.destroy = destroy
-- - - - - - - - - - - - - - - - - - - - - - - -
-- E V E N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
dt.register_event(MODULE, "darkroom-image-loaded",
function(event, clean, image)
local always = dt.preferences.read(MODULE, "always_create_snapshot", "bool")
if clean and always then
dt.gui.libs.snapshots.take_snapshot()
elseif clean and not image.is_altered then
dt.gui.libs.snapshots.take_snapshot()
end
end
)
return script_data

View File

@@ -0,0 +1,129 @@
--[[
auto_tag_modified.lua - automatically tag an image when it has been manually modified in darkroom
Copyright (C) 2025 Michael Reiger <michael@rauschpfeife.net>, modeled after auto_snapshot.lua by Bill Ferguson <wpferguson@gamil.com>.
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
]]
--[[
auto_tag_modified -
automatically tag an image when it has been manually modified in the darkroom, that is if its history has changed at the time it is closed from the darkroom.
(This will not catch applying styles from the light table though.)
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
None
USAGE
* start the script from script_manager
* open an image in darkroom, and close it after making an operation that changes the history
BUGS, COMMENTS, SUGGESTIONS
Michael Reiger <michael@rauschpfeife.net>
CHANGES
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local log = require "lib/dtutils.log"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- C O N S T A N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
local MODULE <const> = "auto_tag_modified"
local DEFAULT_TAG_NAME <const> = "darktable manually modified"
local DEFAULT_LOG_LEVEL <const> = log.error
-- - - - - - - - - - - - - - - - - - - - - - - -
-- A P I C H E C K
-- - - - - - - - - - - - - - - - - - - - - - - -
du.check_min_api_version("7.0.0", MODULE) -- choose the minimum version that contains the features you need
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- I 1 8 N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- S C R I P T M A N A G E R I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local script_data = {}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
script_data.metadata = {
name = _("auto tag modified"), -- name of script
purpose = _("automatically tag an image when it has been manually modified in darkroom"), -- purpose of script
author = "Michael Reiger <michael@rauschpfeife.net>", -- your name and optionally e-mail address
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/auto_tag_modified/" -- URL to help/documentation
}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- L O G L E V E L
-- - - - - - - - - - - - - - - - - - - - - - - -
log.log_level(DEFAULT_LOG_LEVEL)
-- - - - - - - - - - - - - - - - - - - - - - - -
-- N A M E S P A C E
-- - - - - - - - - - - - - - - - - - - - - - - -
local auto_tag_modified = {}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- P R E F E R E N C E S
-- - - - - - - - - - - - - - - - - - - - - - - -
dt.preferences.register(MODULE, "auto_modified_tag_name", "string", "auto_tag_modified - " .. _("tag name to use for auto tagging modified images"),
_("tag name to use for auto tagging modified images"), DEFAULT_TAG_NAME)
-- - - - - - - - - - - - - - - - - - - - - - - -
-- D A R K T A B L E I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - -
local function destroy()
dt.destroy_event(MODULE, "darkroom-image-history-changed")
end
script_data.destroy = destroy
-- - - - - - - - - - - - - - - - - - - - - - - -
-- E V E N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
dt.register_event(MODULE, "darkroom-image-history-changed",
function(event, image)
local tag_name = dt.preferences.read(MODULE, "auto_modified_tag_name", "string")
local tag = dt.tags.create(tag_name)
dt.tags.attach(tag, image)
end
)
return script_data

View File

@@ -37,94 +37,41 @@ GPLv2
]]
local darktable = require "darktable"
local du = require "lib/dtutils"
local filelib = require "lib/dtutils.file"
local syslib = require "lib/dtutils.system"
du.check_min_api_version("7.0.0", "autostyle")
-- Forward declare the functions
local autostyle_apply_one_image,autostyle_apply_one_image_event,autostyle_apply,exiftool_attribute,capture
local gettext = darktable.gettext.gettext
-- Tested it with darktable 1.6.1 and darktable git from 2014-01-25
darktable.configuration.check_version(...,{2,0,2},{2,1,0},{3,0,0},{4,0,0},{5,0,0})
-- Receive the event triggered
function autostyle_apply_one_image_event(event,image)
autostyle_apply_one_image(image)
local function _(msgid)
return gettext(msgid)
end
-- Apply the style to an image, if it matches the tag condition
function autostyle_apply_one_image (image)
-- We need the tag, the value and the style_name provided from the configuration string
local tag,value,style_name=string.match(darktable.preferences.read("autostyle","exif_tag","string"),"(%g+)%s*=%s*(%g+)%s*=>%s*(%g+)")
-- return data structure for script_manager
-- check they all exist (correct syntax)
if (not tag) then
darktable.print("EXIF TAG not found in " .. darktable.preferences.read("autostyle","exif_tag","string"))
return
end
if (not value) then
darktable.print("value to match not found in " .. darktable.preferences.read("autostyle","exif_tag","string"))
return
end
if (not style_name) then
darktable.print("style name not found in " .. darktable.preferences.read("autostyle","exif_tag","string"))
return
end
if not checkIfBinExists("exiftool") then
return
end
local script_data = {}
local have_not_printed_config_message = true
-- First find the style (we have its name)
local styles= darktable.styles
local style
for _,s in ipairs(styles) do
if s.name == style_name then
style=s
end
end
if (not style) then
darktable.print("style not found for autostyle: " .. style_name)
end
script_data.metadata = {
name = _("auto style"),
purpose = _("automatically apply a style based on image EXIF tag"),
author = "Marc Cousin <cousinmarc@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/autostyle/"
}
-- Apply the style to image, if it is tagged
local ok,auto_dr_attr= pcall(exiftool_attribute,image.path .. '/' .. image.filename,tag)
-- If the lookup fails, stop here
if (not ok) then
return
end
if auto_dr_attr==value then
-- darktable.print("Image " .. image.filename .. ": autostyle automatically applied " .. darktable.preferences.read("autostyle","exif_tag","string") )
darktable.styles.apply(style,image)
-- else
-- darktable.print("Image " .. image.filename .. ": autostyle not applied, exif tag " .. darktable.preferences.read("autostyle","exif_tag","string") .. " not matched: " .. auto_dr_attr)
end
end
function autostyle_apply( shortcut)
local images = darktable.gui.action_images
for _,image in pairs(images) do
autostyle_apply_one_image(image)
end
end
-- Retrieve the attribute through exiftool
function exiftool_attribute(path,attr)
local cmd="exiftool -" .. attr .. " '" ..path.. "'";
local exifresult=get_stdout(cmd)
local attribute=string.match(exifresult,": (.*)")
if (attribute == nil) then
darktable.print( "Could not find the attribute " .. attr .. " using the command: <" .. cmd .. ">")
-- Raise an error to the caller
error( "Could not find the attribute " .. attr .. " using the command: <" .. cmd .. ">");
end
return attribute
end
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- run command and retrieve stdout
function get_stdout(cmd)
local function get_stdout(cmd)
-- Open the command, for reading
local fd = assert(io.popen(cmd, 'r'))
dt.control.read(fd)
darktable.control.read(fd)
-- slurp the whole file
local data = assert(fd:read('*a'))
@@ -138,12 +85,116 @@ function get_stdout(cmd)
return data
end
-- Retrieve the attribute through exiftool
local function exiftool_attribute(path, attr)
local cmd = "exiftool -" .. attr .. " '" .. path .. "'";
local exifresult = get_stdout(cmd)
local attribute = string.match(exifresult, ": (.*)")
if (attribute == nil) then
darktable.print_error( "Could not find the attribute " .. attr .. " using the command: <" .. cmd .. ">")
-- Raise an error to the caller
error( "Could not find the attribute " .. attr .. " using the command: <" .. cmd .. ">");
end
-- darktable.print_error("Returning attribute: " .. attribute)
return attribute
end
-- Apply the style to an image, if it matches the tag condition
local function autostyle_apply_one_image (image)
local pref = darktable.preferences.read("autostyle", "exif_tag", "string")
if pref and string.len(pref) >= 6 then
-- We need the tag, the value and the style_name provided from the configuration string
local tag, value, style_name = string.match(pref, "(%g+)%s*=%s*([%g ]-)%s*=>%s*(%g+)")
-- check they all exist (correct syntax)
if (not tag) then
darktable.print(string.format(_("EXIF tag not found in %s"), pref))
return 0
end
if (not value) then
darktable.print(string.format(_("value to match not found in %s"), pref))
return 0
end
if (not style_name) then
darktable.print(string.format(_("style name not found in %s"), pref))
return 0
end
if not filelib.check_if_bin_exists("exiftool") then
darktable.print(_("can't find exiftool"))
return 0
end
-- First find the style (we have its name)
local styles = darktable.styles
local style
for _, s in ipairs(styles) do
if s.name == style_name then
style = s
end
end
if (not style) then
darktable.print(string.format(_("style not found for autostyle: %s"), style_name))
return 0
end
-- Apply the style to image, if it is tagged
local ok, auto_dr_attr = pcall(exiftool_attribute, image.path .. '/' .. image.filename,tag)
--darktable.print_error("dr_attr:" .. auto_dr_attr)
-- If the lookup fails, stop here
if (not ok) then
darktable.print(string.format(_("couldn't get attribute %s from exiftool's output"), auto_dr_attr))
return 0
end
if auto_dr_attr == value then
darktable.print_log("Image " .. image.filename .. ": autostyle automatically applied " .. pref)
darktable.styles.apply(style,image)
return 1
else
darktable.print_log("Image " .. image.filename .. ": autostyle not applied, exif tag " .. pref .. " not matched: " .. auto_dr_attr)
return 0
end
elseif have_not_printed_config_message then
have_not_printed_config_message = false
darktable.print(string.format(_("%s is not configured, please configure the preference in Lua options"), script_data.metadata.name))
end
end
-- Receive the event triggered
local function autostyle_apply_one_image_event(event,image)
autostyle_apply_one_image(image)
end
local function autostyle_apply(shortcut)
local images = darktable.gui.action_images
local images_processed = 0
local images_submitted = 0
for _,image in pairs(images) do
images_submitted = images_submitted + 1
images_processed = images_processed + autostyle_apply_one_image(image)
end
darktable.print(string.format(_("applied auto style to %d out of %d image(s)"), images_processed, images_submitted))
end
local function destroy()
darktable.destroy_event("autostyle", "shortcut")
darktable.destroy_event("autostyle", "post-import-image")
end
-- Registering events
darktable.register_event("shortcut",autostyle_apply,
"Apply your chosen style from exiftool tags")
darktable.register_event("autostyle", "shortcut", autostyle_apply,
_("apply your chosen style from exiftool tags"))
darktable.preferences.register("autostyle","exif_tag","string","Autostyle: EXIF_tag=value=>style","apply a style automatically if an EXIF_tag matches value. Find the tag with exiftool","")
darktable.preferences.register("autostyle", "exif_tag", "string",
string.format("%s: EXIF_tag=value=>style", script_data.metadata.name),
_("apply a style automatically if an EXIF tag matches value, find the tag with exiftool"), "")
darktable.register_event("post-import-image",autostyle_apply_one_image_event)
darktable.register_event("autostyle", "post-import-image",
autostyle_apply_one_image_event)
script_data.destroy = destroy
return script_data

View File

@@ -0,0 +1,205 @@
--[[
change group leader
copyright (c) 2020, 2022 Bill Ferguson <wpferguson@gmail.com>
copyright (c) 2021 Angel Angelov
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/>.
]]
--[[
CHANGE GROUP LEADER
automatically change the leader of raw+jpg paired image groups
INSTALLATION
* copy this file in $CONFIGDIR/lua/ where CONFIGDIR is your darktable configuration directory
* add the following line in the file $CONFIGDIR/luarc
require "change_group_leader"
USAGE
* in lighttable mode, select the image groups you wish to process,
select whether you want to set the leader to "jpg" or "raw",
and click "Execute"
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local gettext = dt.gettext.gettext
local MODULE = "change_group_leader"
du.check_min_api_version("3.0.0", MODULE)
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("change group leader"),
purpose = _("automatically change the leader of raw+jpg paired image groups"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/change_group_leader"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- create a namespace to contain persistent data and widgets
local chg_grp_ldr = {}
local cgl = chg_grp_ldr
cgl.widgets = {}
cgl.event_registered = false
cgl.module_installed = false
-- - - - - - - - - - - - - - - - - - - - - - - -
-- F U N C T I O N S
-- - - - - - - - - - - - - - - - - - - - - - - -
local function install_module()
if not cgl.module_installed then
dt.register_lib(
MODULE, -- Module name
_("change group leader"), -- Visible name
true, -- expandable
false, -- resetable
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 700}}, -- containers
cgl.widgets.box,
nil,-- view_enter
nil -- view_leave
)
cgl.module_installed = true
end
end
local function find_group_leader(images, mode)
for _, img in ipairs(images) do
dt.print_log("checking image " .. img.id .. " named " .. img.filename)
local found = false
if mode == "jpg" then
if string.match(string.lower(img.filename), "jpg$") then
dt.print_log("jpg matched image " .. img.filename)
found = true
end
elseif mode == "raw" then
if img.is_raw and img.duplicate_index == 0 then
dt.print_log("found raw " .. img.filename)
found = true
end
elseif mode == "non-raw" then
if img.is_ldr then
dt.print_log("found ldr " .. img.filename)
found = true
end
else
dt.print_error(MODULE .. ": unrecognized mode " .. mode)
return
end
if found then
dt.print_log("making " .. img.filename .. " group leader")
img:make_group_leader()
return
end
end
end
local function process_image_groups(images)
if #images < 1 then
dt.print(_("no images selected"))
dt.print_log(MODULE .. "no images seletected, returning...")
else
local mode = cgl.widgets.mode.value
for _,img in ipairs(images) do
dt.print_log("checking image " .. img.id)
local group_images = img:get_group_members()
if group_images == 1 then
dt.print_log("only one image in group for image " .. image.id)
else
find_group_leader(group_images, mode)
end
end
end
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- S C R I P T M A N A G E R I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - -
local function destroy()
dt.gui.libs[MODULE].visible = false
end
local function restart()
dt.gui.libs[MODULE].visible = true
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- W I D G E T S
-- - - - - - - - - - - - - - - - - - - - - - - -
cgl.widgets.mode = dt.new_widget("combobox"){
label = _("select new group leader"),
tooltip = _("select type of image to be group leader"),
selected = 1,
"jpg", "raw", "non-raw",
}
cgl.widgets.execute = dt.new_widget("button"){
label = _("execute"),
clicked_callback = function()
process_image_groups(dt.gui.action_images)
end
}
cgl.widgets.box = dt.new_widget("box"){
orientation = "vertical",
cgl.widgets.mode,
cgl.widgets.execute,
}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- D A R K T A B L E I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - -
if dt.gui.current_view().id == "lighttable" then
install_module()
else
if not cgl.event_registered then
dt.register_event(
"view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
cgl.event_registered = true
end
end
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = restart
return script_data

View File

@@ -1,6 +1,6 @@
--[[
clear_GPS.lua - export and edit with GIMP
clear_GPS.lua - plugin for Darktable
Copyright (C) 2016 Bill Ferguson <wpferguson@gmail.com>.
@@ -37,20 +37,34 @@
]]
local dt = require "darktable"
local gettext = dt.gettext
local du = require "lib/dtutils"
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("clear GPS info"),
purpose = _("remove GPS data from selected image(s)"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/clear_gps/"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- not a number
local NaN = 0/0
dt.configuration.check_version(...,{3,0,0},{4,0,0})
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("clear_GPS",dt.configuration.config_dir.."/lua/locale/")
local function _(msgid)
return gettext.dgettext("clear_GPS", msgid)
end
du.check_min_api_version("7.0.0", "clear_GPS")
local function clear_GPS(images)
for _, image in ipairs(images) do
@@ -61,15 +75,23 @@ local function clear_GPS(images)
end
end
local function destroy()
dt.destroy_event("clear_GPS", "shortcut")
dt.gui.libs.image.destroy_action("clear_GPS")
end
script_data.destroy = destroy
dt.gui.libs.image.register_action(
_("clear GPS data"),
"clear_GPS", _("clear GPS data"),
function(event, images) clear_GPS(images) end,
"clear GPS data"
_("clear GPS data from selected images")
)
dt.register_event(
"shortcut",
"clear_GPS", "shortcut",
function(event, shortcut) clear_GPS(dt.gui.action_images) end,
"clear GPS data"
_("clear GPS data from selected images")
)
return script_data

View File

@@ -0,0 +1,377 @@
--[[
color_profile_manager.lua - manage external darktable color profiles
Copyright (C) 2021 Bill Ferguson <wpferguson@gmail.com>.
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
]]
--[[
color_profile_manager - manage external darktable color profiles
This script provides a tool to manage input and output external color
profiles used by darktable. Color profiles can be added or removed
to/from the correct directories so that darktable can find and use
them.
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
* None
USAGE
* require this script from your main lua file
* select the input or output set of color profiles
* a list of profiles is displayed. Click the check box beside the
profile name to select it for removal. Click the "remove profile"
button to remove the profile.
* use the file selector to select a color profile to add to the currently
selected set (input or output)
* click the "add profile" button to add the profile to the selected set
BUGS, COMMENTS, SUGGESTIONS
* Send to Bill Ferguson, wpferguson@gmail.com or raise an issue on
https://github.com/dakrtable-org/lua-scripts
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
du.check_min_api_version("7.0.0", "color_profile_manager")
-- - - - - - - - - - - - - - - - - - - - - - - -
-- L O C A L I Z A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- C O N S T A N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
local MODULE_NAME = "color_profile_manager"
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
local CS = dt.configuration.running_os == "windows" and "&" or ";"
local DIR_CMD = dt.configuration.running_os == "windows" and "dir /b" or "ls"
local COLOR_IN_DIR = dt.configuration.config_dir .. PS .. "color" .. PS .. "in"
local COLOR_OUT_DIR = dt.configuration.config_dir .. PS .. "color" .. PS .. "out"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- N A M E S P A C E
-- - - - - - - - - - - - - - - - - - - - - - - -
local cpm = {}
cpm.widgets = {}
cpm.widgets.profile_box = dt.new_widget("box"){
orientation = "vertical",
}
cpm.module_installed = false
cpm.event_registered = false
-- - - - - - - - - - - - - - - - - - - - - - - -
-- F U N C T I O N S
-- - - - - - - - - - - - - - - - - - - - - - - -
local function check_for_directories()
if not df.test_file(COLOR_IN_DIR, "d") then
dt.print_log("didn't find " .. COLOR_IN_DIR)
return false
elseif not df.test_file(COLOR_OUT_DIR, "d") then
dt.print_log("didn't find " .. COLOR_OUT_DIR)
return false
else
dt.print_log("both directories exist")
return true
end
end
local function add_directories()
df.mkdir(COLOR_IN_DIR)
df.mkdir(COLOR_OUT_DIR)
end
local function list_profiles(dir)
local files = {}
local p = io.popen(DIR_CMD .. " " .. dir)
if p then
for line in p:lines() do
table.insert(files, line)
end
end
p:close()
return files
end
local function add_profile(file, dir)
df.file_copy(file, dir)
dt.print(string.format(_("added color profile %s to %s"), file, dir))
dt.print_log("color profile " .. file .. " added to " .. dir)
end
local function remove_profile(file, dir)
os.remove(dir .. PS .. file)
dt.print(string.format(_("removed color profile %s from %s"), file, dir))
dt.print_log("color profile " .. file .. " removed from " .. dir)
end
local function clear_profile_box()
for i = #cpm.widgets.profile_box, 1, -1 do
cpm.widgets.profile_box[i] = nil
end
end
local function add_profile_callback()
local profile_dir = COLOR_IN_DIR
if cpm.widgets.profile_set.selected == 2 then
profile_dir = COLOR_OUT_DIR
end
local new_profile = cpm.widgets.profile_selector.value
if string.lower(df.get_filetype(new_profile)) ~= "icm" and string.lower(df.get_filetype(new_profile)) ~= "icc" then
dt.print(_("ERROR: color profile must be an icc or icm file"))
dt.print_error(new_profile .. " selected and isn't an icc or icm file")
return
end
-- set selector value to directory that new profile came from
-- in case there are more
cpm.widgets.profile_selector.value = df.get_path(cpm.widgets.profile_selector.value)
add_profile(new_profile, profile_dir)
local files = list_profiles(profile_dir)
local widgets = {}
local profile_ptr = 1
for i, file in ipairs(files) do
if #cpm.widgets.profile_box == 0 or cpm.widgets.profile_box[profile_ptr].label ~= file then
table.insert(widgets, dt.new_widget("check_button"){value = false, label = file})
else
table.insert(widgets, cpm.widgets.profile_box[profile_ptr])
profile_ptr = profile_ptr + 1
if profile_ptr > #cpm.widgets.profile_box then
profile_ptr = #cpm.widgets.profile_box
end
end
end
clear_profile_box()
for _, widget in ipairs(widgets) do
table.insert(cpm.widgets.profile_box, widget)
end
if not cpm.widgets.remove_box.visible then
cpm.widgets.remove_box.visible = true
end
end
local function remove_profile_callback()
local widgets_to_keep = {}
local profile_dir = COLOR_IN_DIR
if cpm.widgets.profile_set.selected == 2 then
profile_dir = COLOR_OUT_DIR
end
for _, widget in ipairs(cpm.widgets.profile_box) do
if widget.value == true then
remove_profile(widget.label, profile_dir)
else
table.insert(widgets_to_keep, widget)
end
end
clear_profile_box()
for _, widget in ipairs(widgets_to_keep) do
table.insert(cpm.widgets.profile_box, widget)
end
if #cpm.widgets.profile_box == 0 then
cpm.widgets.remove_box.visible = false
else
cpm.widgets.remove_box.visible = true
end
end
local function list_profile_callback(choice)
local list_dir = COLOR_IN_DIR
if choice == 2 then
list_dir = COLOR_OUT_DIR
end
local files = list_profiles(list_dir)
if #files == 0 then
cpm.widgets.remove_box.visible = false
else
cpm.widgets.remove_box.visible = true
end
clear_profile_box()
for i, file in ipairs(files) do
cpm.widgets.profile_box[i] = dt.new_widget("check_button"){value = false, label = file}
end
end
local function install_module()
if not cpm.module_installed then
dt.register_lib(
MODULE_NAME, -- Module name
_("color profile manager"), -- Visible name
true, -- expandable
false, -- resetable
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER", 0}}, -- containers
cpm.widgets.main_widget,
nil,-- view_enter
nil -- view_leave
)
cpm.module_installed = true
dt.control.sleep(500)
if not cpm.initialized then
cpm.widgets.profile_set.visible = false
cpm.widgets.add_box.visible = false
cpm.widgets.remove_box.visible = false
else
cpm.widgets.profile_set.selected = 1
end
end
end
local function destroy()
dt.gui.libs[MODULE_NAME].visible = false
return
end
local function restart()
dt.gui.libs[MODULE_NAME].visible = true
return
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- W I D G E T S
-- - - - - - - - - - - - - - - - - - - - - - - -
cpm.initialized = check_for_directories()
dt.print_log("cpm.initialized is " .. tostring(cpm.initialized))
if not cpm.initialized then
dt.print_log("creating init_box")
cpm.widgets.init_box = dt.new_widget("box"){
orientation = "vertical",
dt.new_widget("button"){
label = _("initialize color profiles"),
tooltip = _("create the directory structure to contain the color profiles"),
clicked_callback = function(this)
add_directories()
cpm.initialized = true
cpm.widgets.profile_set.visible = true
cpm.widgets.add_box.visible = true
cpm.widgets.remove_box.visible = false
cpm.widgets.init_box.visible = false
cpm.widgets.profile_set.selected = 1
end
}
}
end
cpm.widgets.profile_set = dt.new_widget("combobox"){
label = _("select profile set"),
tooltip = _("select input or output profiles"),
visible = cpm.initialized and false or true,
changed_callback = function(this)
if cpm.initialized then
list_profile_callback(this.selected)
end
end,
_("input"), _("output"),
}
cpm.widgets.profile_selector = dt.new_widget("file_chooser_button"){
title = _("select color profile to add"),
tooltip = _("select the .icc or .icm file to add"),
is_directory = false
}
cpm.widgets.add_box = dt.new_widget("box"){
orientation = "vertical",
visible = cpm.initialized and true or false,
dt.new_widget("section_label"){label = _("add profile")},
cpm.widgets.profile_selector,
dt.new_widget("button"){
label = _("add selected color profile"),
tooltip = _("add selected file to profiles"),
clicked_callback = function(this)
add_profile_callback()
end
}
}
cpm.widgets.remove_box = dt.new_widget("box"){
orientation = "vertical",
visible = cpm.initialized and true or false,
dt.new_widget("section_label"){label = _("remove profile")},
cpm.widgets.profile_box,
dt.new_widget("button"){
label = _("remove selected profile(s)"),
tooltip = _("remove the checked profile(s)"),
clicked_callback = function(this)
remove_profile_callback()
end
}
}
local main_widgets = {}
if not cpm.initialized then
table.insert(main_widgets, cpm.widgets.init_box)
end
table.insert(main_widgets, cpm.widgets.profile_set)
table.insert(main_widgets, cpm.widgets.remove_box)
table.insert(main_widgets, cpm.widgets.add_box)
cpm.widgets.main_widget = dt.new_widget("box"){
orientation = "vertical",
table.unpack(main_widgets)
}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- M A I N
-- - - - - - - - - - - - - - - - - - - - - - - -
if dt.gui.current_view().id == "lighttable" then
install_module()
else
if not cpm.event_registered then
dt.register_event(
MODULE_NAME, "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
cpm.event_registered = true
end
end
local script_data = {}
script_data.metadata = {
name = _("color profile manager"),
purpose = _("manage external darktable color profiles"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/color_profile_manager"
}
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = restart
return script_data

View File

@@ -37,18 +37,38 @@ USAGE
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local debug = require "darktable.debug"
local gettext = dt.gettext
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
local gettext = dt.gettext.gettext
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("copy_attach_detach_tags",dt.configuration.config_dir.."/lua/locale/")
du.check_min_api_version("7.0.0", "copy_attach_detach_tags")
local function _(msgid)
return gettext.dgettext("copy_attach_detach_tags", msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("copy attach detach tags"),
purpose = _("shortcuts to copy, paste, replace, or remove tags from images"),
author = "Christian Kanzian",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/copy_attach_detach_tags"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local cadt = {}
cadt.module_installed = false
cadt.event_registered = false
cadt.widget_table = {}
local image_tags = {}
@@ -83,7 +103,7 @@ local function mcopy_tags()
end
end
dt.print(_('Image tags copied ...'))
dt.print(_('image tags copied ...'))
--create UI tag list
local taglist = ""
@@ -105,7 +125,7 @@ local function mcopy_tags()
local function attach_tags()
if next(image_tags) == nil then
dt.print(_('No tags to attached, please copy tags first.'))
dt.print(_('no tag to attach, please copy tags first.'))
return true
end
@@ -129,7 +149,7 @@ local function attach_tags()
end
end
end
dt.print(_('Tags attached ...'))
dt.print(_('tags attached ...'))
end
local function detach_tags()
@@ -145,13 +165,68 @@ local function detach_tags()
end
end
end
dt.print(_('Tags removed from image(s).'))
dt.print(_('tags removed from image(s).'))
end
local function replace_tags()
detach_tags()
attach_tags()
dt.print(_('Tags replaced'))
dt.print(_('tags replaced'))
end
local function install_module()
if not cadt.module_installed then
dt.register_lib("tagging_addon",_('tagging addon'),true,true,{
[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER",500}
},
dt.new_widget("box") {
-- orientation = "vertical",
reset_callback = function()
taglist_label.label = ""
image_tags = {}
end,
table.unpack(cadt.widget_table),
},
nil,
nil
)
cadt.module_installed = true
end
end
local function destroy()
dt.destroy_event("cadt_ct", "shortcut")
dt.destroy_event("cadt_at", "shortcut")
dt.destroy_event("cadt_dt", "shortcut")
dt.destroy_event("cadt_rt", "shortcut")
dt.gui.libs["tagging_addon"].visible = false
end
local function restart()
-- shortcut for copy
dt.register_event("cadt_ct", "shortcut",
mcopy_tags,
_('copy tags from selected image(s)'))
-- shortcut for attach
dt.register_event("cadt_at", "shortcut",
attach_tags,
_('paste tags to selected image(s)'))
-- shortcut for detaching tags
dt.register_event("cadt_dt", "shortcut",
detach_tags,
_('remove tags from selected image(s)'))
-- shortcut for replace tags
dt.register_event("cadt_rt", "shortcut",
replace_tags,
_('replace tags from selected image(s)'))
dt.gui.libs["tagging_addon"].visible = true
end
local function show()
dt.gui.libs["tagging_addon"].visible = true
end
-- create modul Tagging addons
@@ -168,72 +243,81 @@ local box1 = dt.new_widget("box"){
orientation = "horizontal",
dt.new_widget("button") {
label = _('multi copy tags'),
tooltip = _('copy tags from selected image(s)'),
clicked_callback = mcopy_tags},
dt.new_widget("button") {
tooltip = _('paste tags to selected image(s)'),
label = _('paste tags'),
clicked_callback = attach_tags}
}
local box2 = dt.new_widget("box"){
orientation = "horizontal",
dt.new_widget("button") {
label = _('replace tags'),
tooltip = _('replace tags from selected image(s)'),
clicked_callback = replace_tags},
dt.new_widget("button") {
label = _('remove all tags'),
tooltip = _('remove tags from selected image(s)'),
clicked_callback = detach_tags}
}
local sep = dt.new_widget("separator"){}
-- pack elements into widget table for a nicer layout
local widget_table = {}
widget_table[1] = box1
widget_table[#widget_table+1] = box2
cadt.widget_table[1] = box1
cadt.widget_table[#cadt.widget_table+1] = box2
widget_table[#widget_table+1] = sep
widget_table[#widget_table+1] = taglabel
widget_table[#widget_table+1] = taglist_label
cadt.widget_table[#cadt.widget_table+1] = sep
cadt.widget_table[#cadt.widget_table+1] = taglabel
cadt.widget_table[#cadt.widget_table+1] = taglist_label
-- create modul
dt.register_lib("tagging_addon","Tagging addon",true,true,{
[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER",500}
},
dt.new_widget("box") {
-- orientation = "vertical",
reset_callback = function()
taglist_label.label = ""
image_tags = {}
end,
table.unpack(widget_table),
},
nil,
nil
if dt.gui.current_view().id == "lighttable" then
install_module()
else
if not cadt.event_registered then
dt.register_event(
"cadt", "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
cadt.event_registered = true
end
end
-- shortcut for copy
dt.register_event("shortcut",
dt.register_event("cadt_ct", "shortcut",
mcopy_tags,
_('copy tags from selected image(s)'))
-- shortcut for attach
dt.register_event("shortcut",
dt.register_event("cadt_at", "shortcut",
attach_tags,
_('paste tags to selected image(s)'))
-- shortcut for detaching tags
dt.register_event("shortcut",
dt.register_event("cadt_dt", "shortcut",
detach_tags,
_('remove tags from selected image(s)'))
-- shortcut for replace tags
dt.register_event("shortcut",
dt.register_event("cadt_rt", "shortcut",
replace_tags,
_('replace tags from selected image(s)'))
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = show
return script_data
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
-- kate: tab-indents: off; indent-width 2; replace-tabs on; remove-trailing-space on;

View File

@@ -33,9 +33,31 @@ USAGE
]]
local darktable = require "darktable"
local du = require "lib/dtutils"
-- Tested with darktable 2.0.1
darktable.configuration.check_version(...,{2,0,0},{3,0,0},{4,0,0})
du.check_min_api_version("7.0.0", "cr2hdr")
local gettext = darktable.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("cr2hdr"),
purpose = _("process Magic Lantern dual ISO images"),
author = "Till Theato <theato@ttill.de>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/cr2hdr"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local queue = {}
local processed_files = {}
@@ -60,7 +82,7 @@ end
local function convert_image(image)
if string.sub(image.filename, -3) == "CR2" then
local filename = image.path .. "/" .. image.filename
local result = dt.control.execute( "cr2hdr " .. filename)
local result = darktable.control.execute( "cr2hdr " .. filename)
local out_filename = string.gsub(filename, ".CR2", ".DNG")
local file = io.open(out_filename)
if file then
@@ -78,7 +100,7 @@ end
local function convert_images()
if next(queue) == nil then return end
job = darktable.gui.create_job("Dual ISO conversion", true, stop_conversion)
job = darktable.gui.create_job(_("dual ISO conversion"), true, stop_conversion)
for key,image in pairs(queue) do
if job.valid then
job.percent = (key-1)/#queue
@@ -89,7 +111,7 @@ local function convert_images()
end
local success_count = 0
for _ in pairs(processed_files) do success_count = success_count + 1 end
darktable.print("Dual ISO conversion successful on " .. success_count .. "/" .. #queue .. " images.")
darktable.print(string.format(_("dual ISO conversion successful on %d/%d images."), success_count, #queue))
job.valid = false
processed_files = {}
queue = {}
@@ -106,8 +128,21 @@ local function convert_action_images(shortcut)
convert_images()
end
darktable.register_event("shortcut", convert_action_images, "Run cr2hdr (Magic Lantern DualISO converter) on selected images")
darktable.register_event("post-import-image", file_imported)
darktable.register_event("post-import-film", film_imported)
local function destroy()
darktable.destroy_event("cr2hdr", "shortcut")
darktable.destroy_event("cr2hdr", "post-import-image")
darktable.destroy_event("cr2hdr", "post-import-film")
end
darktable.preferences.register("cr2hdr", "onimport", "bool", "Invoke on import", "If true then cr2hdr will try to proccess every file during importing. Warning: cr2hdr is quite slow even in figuring out on whether the file is Dual ISO or not.", false)
darktable.register_event("cr2hdr", "shortcut",
convert_action_images, _("run cr2hdr (Magic Lantern DualISO converter) on selected images"))
darktable.register_event("cr2hdr", "post-import-image",
file_imported)
darktable.register_event("cr2hdr", "post-import-film",
film_imported)
darktable.preferences.register("cr2hdr", "onimport", "bool", _("invoke on import"), _("if true then cr2hdr will try to proccess every file during importing\nwarning: cr2hdr is quite slow even in figuring out on whether the file is dual ISO or not."), false)
script_data.destroy = destroy
return script_data

View File

@@ -0,0 +1,162 @@
--[[
cycle_group_leader.lua - change image group leader
Copyright (C) 2024 Bill Ferguson <wpferguson@gmail.com>
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
]]
--[[
cycle_group_leader - change image grouip leader
cycle_group_leader changes the group leader to the next
image in the group. If the end of the group is reached
then the next image is wrapped around to the first image.
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
None
USAGE
* enable with script_manager
* assign a key to the shortcut
BUGS, COMMENTS, SUGGESTIONS
Bill Ferguson <wpferguson@gmail.com>
CHANGES
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- C O N S T A N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
local MODULE = "cycle_group_leader"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- A P I C H E C K
-- - - - - - - - - - - - - - - - - - - - - - - -
du.check_min_api_version("7.0.0", MODULE)
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- I 1 8 N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- S C R I P T M A N A G E R I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local script_data = {}
script_data.metadata = {
name = _("cycle group leader"),
purpose = _("change image group leader"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/cycle_group_leader"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- - - - - - - - - - - - - - - - - - - - - - - -
-- F U N C T I O N S
-- - - - - - - - - - - - - - - - - - - - - - - -
local function toggle_global_toolbox_grouping()
dt.gui.libs.global_toolbox.grouping = false
dt.gui.libs.global_toolbox.grouping = true
end
local function hinter_msg(msg)
dt.print_hinter(msg)
dt.control.sleep(1500)
dt.print_hinter(" ")
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- M A I N P R O G R A M
-- - - - - - - - - - - - - - - - - - - - - - - -
local function cycle_group_leader(image)
local group_images = image:get_group_members()
if #group_images < 2 then
hinter_msg(_("no images to cycle through in group"))
return
else
local position = nil
for i, img in ipairs(group_images) do
if image == img then
position = i
end
end
if position == #group_images then
position = 1
else
position = position + 1
end
new_leader = group_images[position]
new_leader:make_group_leader()
dt.gui.selection({new_leader})
if dt.gui.libs.global_toolbox.grouping then
-- toggle the grouping to make the new leader show
toggle_global_toolbox_grouping()
end
end
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- D A R K T A B L E I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - -
local function destroy()
-- put things to destroy (events, storages, etc) here
dt.destroy_event(MODULE, "shortcut")
end
script_data.destroy = destroy
-- - - - - - - - - - - - - - - - - - - - - - - -
-- E V E N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
dt.register_event(MODULE, "shortcut",
function(event, shortcut)
-- ignore the film roll, it contains all the images, not just the imported
local images = dt.gui.selection()
if #images < 1 then
dt.print(_("no image selected, please select an image and try again"))
else
cycle_group_leader(images[1])
end
end,
_("cycle group leader")
)
return script_data

View File

@@ -0,0 +1,486 @@
-- Route handlers. Each function receives a request table and returns:
-- status (int), body (string), content_type (string|nil), extra_headers (table|nil)
local json = require "json"
local auth = require "auth"
local db = require "db"
local preview = require "preview"
local config = require "config"
local modules = require "modules"
local socket = require "socket"
-- ── Refresh queue (IPC with the darktable bridge plugin) ──────────────────────
-- The bridge plugin running inside darktable polls this file and calls
-- image:drop_cache() + image:generate_cache() for each queued image ID.
--
-- We append atomically via a .tmp + rename idiom to avoid partial reads:
-- 1. Write IDs to <queue>.tmp.<pid>
-- 2. Append that file's contents to the main queue (or rename if queue absent)
-- In practice, for low-frequency refresh calls a simple append is fine because
-- the bridge reads and renames the queue file atomically.
local function enqueue_refresh(image_id)
local qf = config.refresh_queue
local f, ferr = io.open(qf, "a")
if not f then
return false, "cannot open refresh queue " .. qf .. ": " .. (ferr or "?")
end
f:write(tostring(image_id) .. "\n")
f:close()
return true
end
local function enqueue_export(image_id)
local qf = config.export_queue
local f, ferr = io.open(qf, "a")
if not f then
return false, "cannot open export queue " .. qf .. ": " .. (ferr or "?")
end
f:write(tostring(image_id) .. "\n")
f:close()
return true
end
local function export_path(image_id)
return config.export_dir .. "/" .. tostring(image_id) .. ".jpg"
end
local M = {}
-- ── Helpers ───────────────────────────────────────────────────────────────────
local function ok(data, ct)
return 200, json.encode(data), ct or "application/json; charset=utf-8"
end
local function err(status, code, detail)
local body = json.encode({ error = code, detail = detail })
return status, body, "application/json; charset=utf-8"
end
-- Parse application/x-www-form-urlencoded or application/json body.
local function parse_body(req)
local ct = (req.headers["content-type"] or ""):lower()
if ct:find("application/json", 1, true) then
return json.decode(req.body or "{}")
end
-- form-encoded
local fields = {}
for k, v in (req.body or ""):gmatch("([^&=]+)=([^&]*)") do
k = k:gsub("+", " "):gsub("%%(%x%x)", function(h) return string.char(tonumber(h,16)) end)
v = v:gsub("+", " "):gsub("%%(%x%x)", function(h) return string.char(tonumber(h,16)) end)
fields[k] = v
end
return fields
end
-- Authenticate the request and check an optional scope.
-- Returns: payload on success.
-- Returns: nil, status, body, ct on failure (caller does "return s,b,ct").
local function require_auth(req, scope)
local payload, aerr = auth.authenticate(req)
if not payload then
return nil, err(401, "unauthorized", aerr)
end
if scope and not auth.require_scope(payload, scope) then
return nil, err(403, "forbidden", "scope '" .. scope .. "' required")
end
return payload
end
-- ── Public endpoints ──────────────────────────────────────────────────────────
-- GET /health — liveness check, no auth required
function M.health(req)
return ok({ status = "ok", timestamp = os.time() })
end
-- ── OAuth 2.0 ─────────────────────────────────────────────────────────────────
-- POST /oauth/token
-- Accepts: application/x-www-form-urlencoded or application/json
-- Required fields: grant_type=client_credentials, client_id, client_secret
-- Optional: scope (space-separated, must be subset of client's scopes)
--
-- Returns: { access_token, token_type, expires_in, scope }
function M.oauth_token(req)
local fields = parse_body(req)
if not fields then
return err(400, "invalid_request", "could not parse request body")
end
if fields.grant_type ~= "client_credentials" then
return err(400, "unsupported_grant_type",
"only 'client_credentials' is supported")
end
-- Also accept Basic Auth header for client credentials
local client_id, client_secret = fields.client_id, fields.client_secret
if not client_id then
local basic = (req.headers["authorization"] or ""):match("^[Bb]asic%s+(.+)$")
if basic then
local decoded = require("base64").decode(basic)
client_id, client_secret = decoded:match("^([^:]+):(.+)$")
end
end
if not client_id or not client_secret then
return err(400, "invalid_request", "client_id and client_secret are required")
end
local ok_flag, client_scopes = auth.validate_client(client_id, client_secret)
if not ok_flag then
return err(401, "invalid_client", client_scopes)
end
-- Restrict to requested scopes if provided
local granted = client_scopes
if fields.scope and fields.scope ~= "" then
local requested = {}
for s in fields.scope:gmatch("%S+") do requested[s] = true end
granted = {}
for _, s in ipairs(client_scopes) do
if requested[s] then granted[#granted+1] = s end
end
if #granted == 0 then
return err(400, "invalid_scope", "none of the requested scopes are available")
end
end
local token = auth.issue_token(client_id, granted)
return ok({
access_token = token,
token_type = "Bearer",
expires_in = config.token_ttl,
scope = table.concat(granted, " "),
})
end
-- ── Images ────────────────────────────────────────────────────────────────────
-- GET /api/v1/images
-- Query params: rating_min, rating_max, rating, film_id, from, to,
-- color_label, is_raw, is_hdr, search, tag,
-- limit (1-500, default 50), offset, sort_by, sort_dir
function M.list_images(req)
local payload, s, b, ct = require_auth(req, "images:read")
if not payload then return s, b, ct end
local result = db.list_images(req.params)
return ok(result)
end
-- GET /api/v1/images/:id
function M.get_image(req)
local payload, s, b, ct = require_auth(req, "images:read")
if not payload then return s, b, ct end
local id = tonumber(req.path_params.id)
if not id then return err(400, "invalid_id", "id must be an integer") end
local img = db.get_image(id)
if not img then return err(404, "not_found", "image " .. id .. " not found") end
return ok(img)
end
-- ── Previews ──────────────────────────────────────────────────────────────────
-- GET /api/v1/images/:id/preview[?size=thumb|small|medium|large|xlarge|0-5]
-- Returns JPEG data directly (Content-Type: image/jpeg).
function M.get_preview(req)
local payload, s, b, ct = require_auth(req, "previews:read")
if not payload then return s, b, ct end
local id = tonumber(req.path_params.id)
if not id then return err(400, "invalid_id", "id must be an integer") end
local img = db.get_image(id)
if not img then return err(404, "not_found", "image " .. id .. " not found") end
local data, ct, redirect = preview.get(id, img.path, img.filename, req.params.size)
if data then
return 200, data, ct
end
if redirect then
-- Attempt to serve the local file directly rather than issuing a redirect,
-- since file:// URLs are not useful to HTTP clients.
local file_data = preview.read_local(redirect)
if file_data then
local ext = (img.filename or ""):match("%.([^%.]+)$") or ""
local mime = ext:lower():match("^png$") and "image/png" or "image/jpeg"
return 200, file_data, mime
end
end
-- No cached preview exists. Enqueue a full-pipeline thumbnail generation
-- so the bridge renders one; the client should retry after a few seconds.
enqueue_refresh(id)
return 202, json.encode({
status = "generating",
image_id = id,
retry_after = 4,
message = "thumbnail is being generated; retry in a few seconds",
}), "application/json; charset=utf-8", { ["Retry-After"] = "4" }
end
-- ── Tags ──────────────────────────────────────────────────────────────────────
-- GET /api/v1/tags[?search=&limit=&offset=]
function M.list_tags(req)
local payload, s, b, ct = require_auth(req, "tags:read")
if not payload then return s, b, ct end
local tags = db.list_tags(req.params)
return ok({ items = tags })
end
-- ── Film rolls ────────────────────────────────────────────────────────────────
-- GET /api/v1/films[?search=&limit=&offset=]
function M.list_films(req)
local payload, s, b, ct = require_auth(req, "films:read")
if not payload then return s, b, ct end
local films = db.list_films(req.params)
return ok({ items = films })
end
-- ── Cache refresh ─────────────────────────────────────────────────────────────
-- POST /api/v1/images/:id/refresh
-- Enqueues the image for thumbnail regeneration via the darktable bridge.
-- The bridge calls image:drop_cache() + image:generate_cache(true, …), which
-- re-renders through darktable's full processing pipeline so that development
-- settings (tone curves, exposure, colour grading, etc.) are reflected.
-- Requires scope: cache:refresh
function M.refresh_cache(req)
local payload, s, b, ct = require_auth(req, "cache:refresh")
if not payload then return s, b, ct end
local id = tonumber(req.path_params.id)
if not id then return err(400, "invalid_id", "id must be an integer") end
local img = db.get_image(id)
if not img then return err(404, "not_found", "image " .. id .. " not found") end
local queued, qerr = enqueue_refresh(id)
if not queued then
return err(500, "queue_error", qerr)
end
return 202, json.encode({
status = "accepted",
image_id = id,
filename = img.filename,
queue = config.refresh_queue,
message = "cache refresh enqueued; darktable bridge will re-render thumbnails shortly",
}), "application/json; charset=utf-8"
end
-- ── Development modules ───────────────────────────────────────────────────────
-- GET /api/v1/images/:id/modules
-- Returns every operation in the history stack (active entry per operation).
-- Response includes decoded params for known modules; base64 blob for others.
-- Requires scope: images:read
function M.list_modules(req)
local payload, s, b, ct = require_auth(req, "images:read")
if not payload then return s, b, ct end
local id = tonumber(req.path_params.id)
if not id then return err(400, "invalid_id", "id must be an integer") end
local img = db.get_image(id)
if not img then return err(404, "not_found", "image " .. id .. " not found") end
local mods = db.list_modules(id)
return ok({ image_id = id, items = mods })
end
-- GET /api/v1/images/:id/modules/:op
-- Returns the active history entry for one operation.
-- Requires scope: images:read
function M.get_module(req)
local payload, s, b, ct = require_auth(req, "images:read")
if not payload then return s, b, ct end
local id = tonumber(req.path_params.id)
local op = req.path_params.op
if not id then return err(400, "invalid_id", "id must be an integer") end
local img = db.get_image(id)
if not img then return err(404, "not_found", "image " .. id .. " not found") end
local mod = db.get_module(id, op)
if not mod then
return err(404, "module_not_found",
"operation '" .. op .. "' not in history for image " .. id)
end
return ok(mod)
end
-- PATCH /api/v1/images/:id/modules/:op
-- Body (JSON):
-- {
-- "enabled": true|false, -- optional: change enabled state
-- "params": { field: value, … } -- optional: named params for known modules
-- "params_b64": "<base64>" -- alternative: raw binary for unknown modules
-- }
-- Query param: ?preview=thumb|small|medium|large|xlarge
-- If given, waits up to 30 s for the thumbnail to update and returns the JPEG.
-- Otherwise returns 204 No Content.
-- Requires scope: cache:refresh
function M.patch_module(req)
local payload, s, b, ct = require_auth(req, "cache:refresh")
if not payload then return s, b, ct end
local id = tonumber(req.path_params.id)
local op = req.path_params.op
if not id then return err(400, "invalid_id", "id must be an integer") end
local img = db.get_image(id)
if not img then return err(404, "not_found", "image " .. id .. " not found") end
local mod = db.get_module(id, op)
if not mod then
return err(404, "module_not_found",
"operation '" .. op .. "' not in history for image " .. id)
end
-- Parse request body
local body = parse_body(req)
if not body then
return err(400, "invalid_body", "could not parse JSON body")
end
local new_enabled = body.enabled -- may be nil (leave unchanged)
local new_blob = nil
if body.params_b64 then
-- Caller provided raw base64 params (for unknown modules)
local ok_dec, decoded = pcall(require("base64").decode, body.params_b64)
if not ok_dec then
return err(400, "invalid_params_b64", "base64 decode failed")
end
new_blob = decoded
elseif body.params then
if mod.params then
local existing_blob = db.get_module_blob(id, op)
if not existing_blob then
return err(500, "db_error", "could not read existing params blob")
end
new_blob = modules.encode(op, mod.module_version, existing_blob, body.params)
if not new_blob then
return err(400, "unsupported_module",
"named-param editing is not supported for operation '" .. op ..
"'; use params_b64 with a raw binary blob instead")
end
else
-- Unknown module, caller must supply params_b64
return err(400, "params_required",
"operation '" .. op .. "' requires params_b64 (binary blob) for editing")
end
end
-- Persist to history table
local ok_write, werr = db.set_module_params(id, op, new_enabled, new_blob)
if not ok_write then
return err(500, "db_write_error", werr)
end
-- Enqueue a thumbnail refresh so the bridge re-renders with the new params.
enqueue_refresh(id)
-- Optional synchronous preview response
local preview_size = req.params.preview
if preview_size and preview_size ~= "" then
-- Read the thumbnail before the refresh so we can detect when it changes.
local old_data = preview.get(id, img.path, img.filename, preview_size)
local deadline = os.time() + 30
local new_data
while os.time() < deadline do
socket.select(nil, nil, 0.5)
local candidate = preview.get(id, img.path, img.filename, preview_size)
if candidate and candidate ~= old_data then
new_data = candidate
break
end
end
if new_data then
return 200, new_data, "image/jpeg"
end
-- Timeout — return what we have (may be stale) with a warning header
local fallback = preview.get(id, img.path, img.filename, preview_size)
if fallback then
return 200, fallback, "image/jpeg",
{ ["X-Preview-Warning"] = "regeneration-timeout; thumbnail may be stale" }
end
return err(504, "preview_timeout",
"thumbnail regeneration timed out after 30 s; retry the preview endpoint")
end
return 204, "", nil
end
-- ── Full-resolution export ────────────────────────────────────────────────────
-- POST /api/v1/images/:id/export
-- Removes any stale export file, enqueues the bridge job, returns 202.
-- The client should poll GET /full until it receives a 200.
-- Requires scope: cache:refresh
function M.trigger_export(req)
local payload, s, b, ct = require_auth(req, "cache:refresh")
if not payload then return s, b, ct end
local id = tonumber(req.path_params.id)
if not id then return err(400, "invalid_id", "id must be an integer") end
local img = db.get_image(id)
if not img then return err(404, "not_found", "image " .. id .. " not found") end
-- Remove stale export so the client can detect when the fresh one lands.
os.remove(export_path(id))
local queued, qerr = enqueue_export(id)
if not queued then return err(500, "queue_error", qerr) end
return 202, json.encode({
status = "accepted",
image_id = id,
filename = img.filename,
message = "export enqueued; poll GET /api/v1/images/" .. id .. "/full",
}), "application/json; charset=utf-8"
end
-- GET /api/v1/images/:id/full
-- Serves the full-resolution JPEG previously exported via POST /export.
-- If no export exists yet, enqueues one and returns 202 so the client can retry.
-- Requires scope: previews:read
function M.get_full(req)
local payload, s, b, ct = require_auth(req, "previews:read")
if not payload then return s, b, ct end
local id = tonumber(req.path_params.id)
if not id then return err(400, "invalid_id", "id must be an integer") end
local img = db.get_image(id)
if not img then return err(404, "not_found", "image " .. id .. " not found") end
local path = export_path(id)
local f = io.open(path, "rb")
if f then
local data = f:read("*a"); f:close()
local stem = (img.filename or "export"):match("^(.+)%.[^.]+$") or (img.filename or "export")
local disposition = string.format('attachment; filename="%s.jpg"', stem)
return 200, data, "image/jpeg", { ["Content-Disposition"] = disposition }
end
-- Not yet exported — enqueue and tell the client to retry.
local queued, qerr = enqueue_export(id)
if not queued then
return err(500, "queue_error", qerr)
end
return 202, json.encode({
status = "queued",
image_id = id,
filename = img.filename,
retry_after = 5,
message = "export enqueued; retry in a few seconds",
}), "application/json; charset=utf-8", { ["Retry-After"] = "5" }
end
return M

View File

@@ -0,0 +1,96 @@
-- OAuth 2.0 Client Credentials grant + HS256 JWT
-- Requires: LuaJIT FFI with libcrypto (OpenSSL)
local ffi = require "ffi"
local base64 = require "base64"
local json = require "json"
local config = require "config"
-- ── OpenSSL HMAC-SHA256 via FFI ───────────────────────────────────────────────
ffi.cdef[[
void *EVP_sha256(void);
unsigned char *HMAC(const void *evp_md, const void *key, int key_len,
const unsigned char *data, size_t data_len,
unsigned char *md, unsigned int *md_len);
]]
-- libcrypto ships as part of OpenSSL; path varies by distro but the soname is standard
local crypto = ffi.load("crypto")
local function hmac_sha256(key, data)
local digest = ffi.new("unsigned char[32]")
local dlen = ffi.new("unsigned int[1]")
crypto.HMAC(crypto.EVP_sha256(), key, #key, data, #data, digest, dlen)
return ffi.string(digest, 32)
end
-- ── JWT helpers ───────────────────────────────────────────────────────────────
local HEADER_B64 = base64.urlencode(json.encode({ alg = "HS256", typ = "JWT" }))
local function jwt_sign(payload_tbl)
local payload = base64.urlencode(json.encode(payload_tbl))
local signing = HEADER_B64 .. "." .. payload
local sig = base64.urlencode(hmac_sha256(config.jwt_secret, signing))
return signing .. "." .. sig
end
local function jwt_verify(token)
local h, p, s = token:match("^([^.]+)%.([^.]+)%.([^.]+)$")
if not h then return nil, "malformed token" end
local expected = base64.urlencode(hmac_sha256(config.jwt_secret, h .. "." .. p))
if s ~= expected then return nil, "invalid signature" end
local payload, err = json.decode(base64.urldecode(p))
if not payload then return nil, "invalid payload: " .. (err or "?") end
if os.time() > (payload.exp or 0) then return nil, "token expired" end
return payload
end
-- ── Public API ────────────────────────────────────────────────────────────────
local M = {}
-- Validate client_id / client_secret pair; returns true + scopes or false + error.
function M.validate_client(client_id, client_secret)
local client = config.clients[client_id]
if not client then return false, "unknown client" end
if client.secret ~= client_secret then return false, "invalid client secret" end
return true, client.scopes
end
-- Issue an access token for a validated client.
function M.issue_token(client_id, scopes)
local now = os.time()
return jwt_sign({
iss = "darktable-api",
sub = client_id,
scope = table.concat(scopes, " "),
iat = now,
exp = now + config.token_ttl,
})
end
-- Extract and verify a Bearer token from a request.
-- Returns payload table on success, or nil + error string on failure.
function M.authenticate(req)
local auth = (req.headers or {})["authorization"] or ""
local token = auth:match("^[Bb]earer%s+(.+)$")
if not token then return nil, "missing Bearer token" end
return jwt_verify(token)
end
-- Check that the authenticated payload contains a required scope.
function M.require_scope(payload, scope)
if not payload then return false end
local scopes = payload.scope or ""
for s in scopes:gmatch("%S+") do
if s == scope then return true end
end
return false
end
return M

View File

@@ -0,0 +1,52 @@
-- Base64 and Base64url encode/decode (pure Lua, no dependencies)
local M = {}
local CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
local LOOKUP = {}
for i = 1, #CHARS do LOOKUP[CHARS:sub(i,i)] = i - 1 end
function M.encode(s)
local out = {}
for i = 1, #s, 3 do
local a, b, c = s:byte(i, i + 2)
b, c = b or 0, c or 0
local n = a * 65536 + b * 256 + c
out[#out+1] = CHARS:sub(math.floor(n / 262144) % 64 + 1, math.floor(n / 262144) % 64 + 1)
out[#out+1] = CHARS:sub(math.floor(n / 4096) % 64 + 1, math.floor(n / 4096) % 64 + 1)
out[#out+1] = CHARS:sub(math.floor(n / 64) % 64 + 1, math.floor(n / 64) % 64 + 1)
out[#out+1] = CHARS:sub( n % 64 + 1, n % 64 + 1)
end
local rem = #s % 3
if rem == 1 then out[#out-1], out[#out] = "=", "=" end
if rem == 2 then out[#out] = "=" end
return table.concat(out)
end
function M.decode(s)
s = s:gsub("[^A-Za-z0-9+/=]", "")
local out = {}
for i = 1, #s, 4 do
local a = LOOKUP[s:sub(i, i )] or 0
local b = LOOKUP[s:sub(i+1, i+1)] or 0
local c = LOOKUP[s:sub(i+2, i+2)] or 0
local d = LOOKUP[s:sub(i+3, i+3)] or 0
local n = a * 262144 + b * 4096 + c * 64 + d
out[#out+1] = string.char(math.floor(n / 65536))
if s:sub(i+2, i+2) ~= "=" then out[#out+1] = string.char(math.floor(n / 256) % 256) end
if s:sub(i+3, i+3) ~= "=" then out[#out+1] = string.char(n % 256) end
end
return table.concat(out)
end
-- URL-safe Base64 (RFC 4648 §5): replace +/ with -_ and strip padding
function M.urlencode(s)
return M.encode(s):gsub("+", "-"):gsub("/", "_"):gsub("=", "")
end
function M.urldecode(s)
s = s:gsub("-", "+"):gsub("_", "/")
local pad = (4 - #s % 4) % 4
return M.decode(s .. string.rep("=", pad))
end
return M

View File

@@ -0,0 +1,33 @@
meta {
name: Health Check
type: http
seq: 1
}
get {
url: {{baseUrl}}/health
body: none
auth: none
}
tests {
test("returns 200", function() {
expect(res.status).to.equal(200);
});
test("status is ok", function() {
expect(res.body.status).to.equal("ok");
});
test("has timestamp", function() {
expect(res.body.timestamp).to.be.a("number");
expect(res.body.timestamp).to.be.above(0);
});
}
docs {
## Health Check
Liveness probe — no authentication required.
Returns `{"status":"ok","timestamp":<unix>}`.
}

View File

@@ -0,0 +1,33 @@
meta {
name: Get Token (Bad Secret)
type: http
seq: 2
}
post {
url: {{baseUrl}}/oauth/token
body: form-urlencoded
auth: none
}
body:form-urlencoded {
grant_type: client_credentials
client_id: {{clientId}}
client_secret: wrong-secret
}
tests {
test("returns 401", function() {
expect(res.status).to.equal(401);
});
test("error is invalid_client", function() {
expect(res.body.error).to.equal("invalid_client");
});
}
docs {
## Negative test — wrong client secret
Verifies the server rejects bad credentials with 401.
}

View File

@@ -0,0 +1,64 @@
meta {
name: Get Token
type: http
seq: 1
}
post {
url: {{baseUrl}}/oauth/token
body: form-urlencoded
auth: none
}
body:form-urlencoded {
grant_type: client_credentials
client_id: {{clientId}}
client_secret: {{clientSecret}}
}
script:post-response {
if (res.status === 200) {
bru.setVar("accessToken", res.body.access_token);
console.log("Token stored. Expires in", res.body.expires_in, "seconds.");
console.log("Scopes:", res.body.scope);
} else {
console.error("Token request failed:", res.status, res.body);
}
}
tests {
test("returns 200", function() {
expect(res.status).to.equal(200);
});
test("has access_token", function() {
expect(res.body.access_token).to.be.a("string");
expect(res.body.access_token.length).to.be.above(0);
});
test("token_type is Bearer", function() {
expect(res.body.token_type).to.equal("Bearer");
});
test("scope includes images:read", function() {
expect(res.body.scope).to.include("images:read");
});
test("scope includes cache:refresh", function() {
expect(res.body.scope).to.include("cache:refresh");
});
test("expires_in is 3600", function() {
expect(res.body.expires_in).to.equal(3600);
});
}
docs {
## OAuth 2.0 — Client Credentials Grant
Exchanges `client_id` + `client_secret` for a short-lived Bearer JWT.
The post-response script stores the token in `{{accessToken}}` so all
other requests pick it up automatically.
Run this request first before calling any protected endpoint.
}

View File

@@ -0,0 +1,6 @@
{
"version": "1",
"name": "Darktable API",
"type": "collection",
"ignore": []
}

View File

@@ -0,0 +1,12 @@
vars {
baseUrl: http://127.0.0.1:7645
clientId: darktable-client
clientSecret: changeme
accessToken:
imageId: 1
}
vars:secret [
clientSecret,
accessToken
]

View File

@@ -0,0 +1,12 @@
vars {
baseUrl: http://192.168.1.134:7645
clientId: darktable-client
clientSecret: changeme
accessToken:
imageId: 1
}
vars:secret [
clientSecret,
accessToken
]

View File

@@ -0,0 +1,54 @@
meta {
name: List Films
type: http
seq: 1
}
get {
url: {{baseUrl}}/api/v1/films
body: none
auth: bearer
}
auth:bearer {
token: {{accessToken}}
}
params:query {
limit: 50
offset: 0
~search: 2018
}
tests {
test("returns 200", function() {
expect(res.status).to.equal(200);
});
test("has items array", function() {
expect(res.body.items).to.be.an("array");
});
test("each film has id, folder, image_count", function() {
res.body.items.forEach(function(film) {
expect(film.id).to.be.a("number");
expect(film.folder).to.be.a("string");
expect(film.image_count).to.be.a("number");
});
});
test("image counts are positive", function() {
res.body.items.forEach(function(film) {
expect(film.image_count).to.be.above(0);
});
});
}
docs {
## List Films
Returns all film rolls (import folders) with their image counts, sorted by folder path.
Use `?search=` to filter by folder path substring.
Use `?limit` and `?offset` for pagination (max 2000 per page).
}

View File

@@ -0,0 +1,52 @@
meta {
name: Export Image
type: http
seq: 6
}
post {
url: {{baseUrl}}/api/v1/images/{{imageId}}/export
body: none
auth: bearer
}
auth:bearer {
token: {{accessToken}}
}
tests {
test("returns 202 Accepted", function() {
expect(res.status).to.equal(202);
});
test("status is accepted", function() {
expect(res.body.status).to.equal("accepted");
});
test("image_id matches request", function() {
expect(res.body.image_id).to.equal(Number(bru.getVar("imageId")));
});
test("has filename", function() {
expect(res.body.filename).to.be.a("string");
});
test("has export path", function() {
expect(res.body.export).to.be.a("string");
});
}
docs {
## Export Image (Full Resolution)
Enqueues a full-resolution JPEG export processed through darktable's complete
development pipeline — tone curves, exposure, colour grading, noise reduction,
and all other active modules are applied.
Returns **202 Accepted** immediately. The darktable bridge plugin writes the
result to the path shown in `export` (default: `/tmp/dt-api-exports/<id>.jpg`).
Poll **GET /api/v1/images/:id/full** to retrieve the image once ready.
Requires scope: `cache:refresh`
}

View File

@@ -0,0 +1,57 @@
meta {
name: Get Full Image
type: http
seq: 7
}
get {
url: {{baseUrl}}/api/v1/images/{{imageId}}/full
body: none
auth: bearer
}
auth:bearer {
token: {{accessToken}}
}
tests {
test("returns 200 or 202", function() {
expect([200, 202]).to.include(res.status);
});
test("if 200, content-type is image/jpeg", function() {
if (res.status === 200) {
expect(res.headers["content-type"]).to.equal("image/jpeg");
}
});
test("if 200, body is non-empty", function() {
if (res.status === 200) {
expect(res.body.length).to.be.above(0);
}
});
test("if 202, export was queued", function() {
if (res.status === 202) {
expect(res.body.status).to.equal("queued");
expect(res.body.retry_after).to.be.a("number");
}
});
}
docs {
## Get Full-Resolution Image
Returns the full-resolution JPEG developed through darktable's complete
processing pipeline (all active development modules applied).
### Workflow
1. POST `/api/v1/images/:id/export` — enqueue the export (returns 202)
2. Wait ~2–10 s (depending on complexity and hardware)
3. GET `/api/v1/images/:id/full` — download the result (200 with JPEG body)
If no export exists yet this endpoint auto-enqueues one and returns **202**
with a `Retry-After: 5` header. Keep retrying until you receive **200**.
Requires scope: `previews:read`
}

View File

@@ -0,0 +1,31 @@
meta {
name: Get Image (Not Found)
type: http
seq: 3
}
get {
url: {{baseUrl}}/api/v1/images/999999
body: none
auth: bearer
}
auth:bearer {
token: {{accessToken}}
}
tests {
test("returns 404", function() {
expect(res.status).to.equal(404);
});
test("error is not_found", function() {
expect(res.body.error).to.equal("not_found");
});
}
docs {
## Get Image — Not Found
Verifies a non-existent image ID returns 404.
}

View File

@@ -0,0 +1,72 @@
meta {
name: Get Image
type: http
seq: 2
}
get {
url: {{baseUrl}}/api/v1/images/{{imageId}}
body: none
auth: bearer
}
auth:bearer {
token: {{accessToken}}
}
script:post-response {
if (res.status === 200) {
// Store this image's ID for use by preview / refresh requests
bru.setVar("imageId", res.body.id);
}
}
tests {
test("returns 200", function() {
expect(res.status).to.equal(200);
});
test("has correct id", function() {
expect(res.body.id).to.equal(Number(bru.getVar("imageId")));
});
test("has filename", function() {
expect(res.body.filename).to.be.a("string");
expect(res.body.filename.length).to.be.above(0);
});
test("has path", function() {
expect(res.body.path).to.be.a("string");
});
test("has rating in valid range", function() {
expect(res.body.rating).to.be.at.least(-1);
expect(res.body.rating).to.be.at.most(5);
});
test("has tags array", function() {
expect(res.body.tags).to.be.an("array");
});
test("has color_labels array", function() {
expect(res.body.color_labels).to.be.an("array");
});
test("has metadata object", function() {
expect(res.body.metadata).to.be.an("object");
});
test("has boolean flags", function() {
expect(res.body.is_raw).to.be.a("boolean");
expect(res.body.is_hdr).to.be.a("boolean");
expect(res.body.is_ldr).to.be.a("boolean");
});
}
docs {
## Get Image
Returns full detail for a single image including tags, color labels, and metadata.
Set `{{imageId}}` in the environment (or pick up from "List Images" run).
}

View File

@@ -0,0 +1,67 @@
meta {
name: Get Preview
type: http
seq: 4
}
get {
url: {{baseUrl}}/api/v1/images/{{imageId}}/preview
body: none
auth: bearer
}
auth:bearer {
token: {{accessToken}}
}
params:query {
size: small
~size: medium
~size: large
~size: thumb
~size: xlarge
}
tests {
test("returns 200 or 404", function() {
expect([200, 404]).to.include(res.status);
});
test("if 200, content-type is image/jpeg or image/png", function() {
if (res.status === 200) {
expect(res.headers["content-type"]).to.match(/image\/(jpeg|png)/);
}
});
test("if 200, body is non-empty", function() {
if (res.status === 200) {
expect(res.body.length).to.be.above(0);
}
});
test("if 404, no_preview error returned", function() {
if (res.status === 404) {
expect(res.body.error).to.equal("no_preview");
}
});
}
docs {
## Get Preview
Returns a JPEG thumbnail from darktable's mipmap cache.
### Size options
| Value | Approx. long edge |
|---|---|
| `thumb` | ~135 px |
| `small` | ~270 px |
| `medium` | ~540 px (default) |
| `large` | ~1080 px |
| `xlarge` | ~2160 px |
| `0`–`5` | Raw mip level |
Only one `size` param is active at a time — uncomment the desired one above.
Falls back to lower mip levels automatically if the requested size isn't cached.
Returns 404 if no cached thumbnail exists at any level.
}

View File

@@ -0,0 +1,27 @@
meta {
name: List Images (No Auth)
type: http
seq: 6
}
get {
url: {{baseUrl}}/api/v1/images
body: none
auth: none
}
tests {
test("returns 401 without token", function() {
expect(res.status).to.equal(401);
});
test("error is unauthorized", function() {
expect(res.body.error).to.equal("unauthorized");
});
}
docs {
## List Images — No Auth
Verifies that protected endpoints return 401 when no Bearer token is supplied.
}

View File

@@ -0,0 +1,87 @@
meta {
name: List Images
type: http
seq: 1
}
get {
url: {{baseUrl}}/api/v1/images
body: none
auth: bearer
}
auth:bearer {
token: {{accessToken}}
}
params:query {
limit: 10
offset: 0
sort_by: datetime_taken
sort_dir: desc
~rating_min: 1
~rating_max: 5
~rating: 3
~film_id: 1
~from: 2018-01-01
~to: 2018-12-31
~color_label: red
~is_raw: true
~is_hdr: false
~search: 500mm
~tag: realestate
}
tests {
test("returns 200", function() {
expect(res.status).to.equal(200);
});
test("has items array", function() {
expect(res.body.items).to.be.an("array");
});
test("has total count", function() {
expect(res.body.total).to.be.a("number");
expect(res.body.total).to.be.above(0);
});
test("has limit and offset", function() {
expect(res.body.limit).to.equal(10);
expect(res.body.offset).to.equal(0);
});
test("each image has required fields", function() {
res.body.items.forEach(function(img) {
expect(img.id).to.be.a("number");
expect(img.filename).to.be.a("string");
expect(img.path).to.be.a("string");
expect(img.rating).to.be.a("number");
});
});
}
docs {
## List Images
Returns a paginated list of images from the darktable catalog.
### Active query params (remove `~` prefix to enable)
| Param | Type | Description |
|---|---|---|
| `limit` | int | Results per page (max 500, default 50) |
| `offset` | int | Pagination offset |
| `sort_by` | string | `id`, `filename`, `datetime_taken`, `rating`, `focal_length`, `iso` |
| `sort_dir` | string | `asc` or `desc` |
| `rating_min` | int | Minimum star rating (−1=rejected, 0=unrated, 1–5=stars) |
| `rating_max` | int | Maximum star rating |
| `rating` | int | Exact rating |
| `film_id` | int | Filter by film roll ID |
| `from` | date | Earliest capture date (YYYY-MM-DD) |
| `to` | date | Latest capture date (YYYY-MM-DD) |
| `color_label` | string | `red`, `yellow`, `green`, `blue`, `purple` |
| `is_raw` | bool | `true` / `false` |
| `is_hdr` | bool | `true` / `false` |
| `search` | string | Free-text search in filename, maker, model, lens |
| `tag` | string | Filter by exact tag name |
}

View File

@@ -0,0 +1,49 @@
meta {
name: Refresh Cache
type: http
seq: 5
}
post {
url: {{baseUrl}}/api/v1/images/{{imageId}}/refresh
body: none
auth: bearer
}
auth:bearer {
token: {{accessToken}}
}
tests {
test("returns 202 Accepted", function() {
expect(res.status).to.equal(202);
});
test("status is accepted", function() {
expect(res.body.status).to.equal("accepted");
});
test("image_id matches request", function() {
expect(res.body.image_id).to.equal(Number(bru.getVar("imageId")));
});
test("has filename", function() {
expect(res.body.filename).to.be.a("string");
});
test("has queue path", function() {
expect(res.body.queue).to.be.a("string");
});
}
docs {
## Refresh Cache
Enqueues the image for thumbnail regeneration inside the running darktable instance.
Returns **202 Accepted** immediately. The darktable bridge plugin
(`darktable-api-bridge.lua`) polls `/tmp/dt-api-refresh.queue` every second
and calls `image:drop_cache()` + `image:generate_cache()` when it finds this ID.
Requires scope: `cache:refresh`
}

View File

@@ -0,0 +1,31 @@
meta {
name: Get Module (Not Found)
type: http
seq: 4
}
get {
url: {{baseUrl}}/api/v1/images/{{imageId}}/modules/nonexistent_module
body: none
auth: bearer
}
auth:bearer {
token: {{accessToken}}
}
tests {
test("returns 404", function() {
expect(res.status).to.equal(404);
});
test("error is module_not_found", function() {
expect(res.body.error).to.equal("module_not_found");
});
}
docs {
## Get Module — Not Found
Verifies 404 is returned for an operation that does not exist in the image history.
}

View File

@@ -0,0 +1,55 @@
meta {
name: Get Module
type: http
seq: 2
}
get {
url: {{baseUrl}}/api/v1/images/{{imageId}}/modules/filmicrgb
body: none
auth: bearer
}
auth:bearer {
token: {{accessToken}}
}
tests {
test("returns 200", function() {
expect(res.status).to.equal(200);
});
test("operation is filmicrgb", function() {
expect(res.body.operation).to.equal("filmicrgb");
});
test("has enabled flag", function() {
expect(res.body.enabled).to.be.a("boolean");
});
test("has decoded params", function() {
expect(res.body.params).to.be.an("object");
expect(res.body.params.grey_point_source).to.be.a("number");
expect(res.body.params.black_point_source).to.be.a("number");
expect(res.body.params.white_point_source).to.be.a("number");
expect(res.body.params.contrast).to.be.a("number");
expect(res.body.params.saturation).to.be.a("number");
});
// Save for the Patch Module test
bru.setVar("filmicGreyPointSource", res.body.params.grey_point_source);
}
docs {
## Get Module
Returns the active history entry for the `filmicrgb` module.
Change the URL path segment to inspect a different module, e.g.:
- `.../modules/exposure`
- `.../modules/temperature`
- `.../modules/highlights`
- `.../modules/channelmixerrgb`
Returns 404 if the operation has never been added to this image's history.
}

View File

@@ -0,0 +1,79 @@
meta {
name: List Modules
type: http
seq: 1
}
get {
url: {{baseUrl}}/api/v1/images/{{imageId}}/modules
body: none
auth: bearer
}
auth:bearer {
token: {{accessToken}}
}
tests {
test("returns 200", function() {
expect(res.status).to.equal(200);
});
test("has image_id", function() {
expect(res.body.image_id).to.equal(Number(bru.getVar("imageId")));
});
test("has items array", function() {
expect(res.body.items).to.be.an("array");
expect(res.body.items.length).to.be.above(0);
});
test("each item has required fields", function() {
res.body.items.forEach(function(m) {
expect(m.operation).to.be.a("string");
expect(m.enabled).to.be.a("boolean");
expect(m.module_version).to.be.a("number");
expect(m.history_num).to.be.a("number");
});
});
test("known modules have decoded params", function() {
var known = res.body.items.filter(function(m) {
return ["exposure","temperature","filmicrgb","highlights",
"channelmixerrgb","flip","gamma","rawprepare","demosaic"].indexOf(m.operation) >= 0;
});
known.forEach(function(m) {
expect(m.params).to.not.be.null;
expect(typeof m.params).to.equal("object");
});
});
test("unknown modules have params_b64", function() {
var unknown = res.body.items.filter(function(m) { return m.params === undefined || m.params === null; });
unknown.forEach(function(m) {
expect(m.params_b64).to.be.a("string");
});
});
// Save the first module op for subsequent tests
bru.setVar("moduleOp", res.body.items[0].operation);
}
docs {
## List Modules
Returns all active development modules (history stack entries) for the image.
Each item includes:
- `operation` – module name (e.g. `"exposure"`, `"filmicrgb"`)
- `enabled` – whether the module is currently active in the pipeline
- `module_version` – params struct version stored in the database
- `multi_name` – user label for multi-instance modules (empty for single-instance)
- `history_num` – position in the history stack (higher = more recent)
- `params` – decoded named parameters (for supported modules)
- `params_b64` – base64-encoded raw binary blob (for unsupported modules)
### Supported modules (params decoded)
`exposure`, `temperature`, `filmicrgb`, `channelmixerrgb`, `highlights`,
`flip`, `gamma`, `rawprepare`, `demosaic`
}

View File

@@ -0,0 +1,89 @@
meta {
name: Patch Module
type: http
seq: 3
}
patch {
url: {{baseUrl}}/api/v1/images/{{imageId}}/modules/filmicrgb
body: json
auth: bearer
}
auth:bearer {
token: {{accessToken}}
}
params:query {
~preview: medium
}
body:json {
{
"enabled": true,
"params": {
"grey_point_source": 18.45,
"white_point_source": 4.0,
"black_point_source": -8.0,
"contrast": 1.0
}
}
}
tests {
test("returns 204 (no preview) or 200 (with preview)", function() {
expect([200, 204]).to.include(res.status);
});
test("if 200, content-type is image/jpeg", function() {
if (res.status === 200) {
expect(res.headers["content-type"]).to.equal("image/jpeg");
}
});
}
docs {
## Patch Module
Update one or more parameters on a development module and optionally get a
preview image back showing the result.
### Body fields
- `enabled` (boolean, optional) – enable or disable the module
- `params` (object, optional) – named parameter overrides for known modules
- `params_b64` (string, optional) – raw base64 binary blob for unknown modules
(mutually exclusive with `params`)
Only fields present in `params` are changed; all others keep their current values.
### Preview query param
Add `?preview=small|medium|large|xlarge` to receive a JPEG thumbnail (200)
instead of empty 204. The server waits up to 30 s for the thumbnail to
regenerate before returning. Without this param the endpoint returns
**204 No Content** immediately (the bridge regenerates async in ~1-3 s).
### filmicrgb key parameters
| Field | Description | Default |
|---|---|---|
| `grey_point_source` | middle-grey exposure % | 18.45 |
| `black_point_source` | black relative exposure EV | -8.0 |
| `white_point_source` | white relative exposure EV | 4.0 |
| `contrast` | S-curve contrast | 1.0 |
| `saturation` | extreme-luminance saturation | 0.0 |
| `balance` | shadows ↔ highlights balance | 0.0 |
| `auto_hardness` | auto-adjust curve hardness | true |
### exposure key parameters
| Field | Description |
|---|---|
| `exposure` | exposure compensation in EV |
| `black` | black level correction |
| `mode` | 0=manual, 1=deflicker |
### temperature key parameters
| Field | Description |
|---|---|
| `red` | red channel multiplier |
| `green` | green channel multiplier |
| `blue` | blue channel multiplier |
}

View File

@@ -0,0 +1,54 @@
meta {
name: List Tags
type: http
seq: 1
}
get {
url: {{baseUrl}}/api/v1/tags
body: none
auth: bearer
}
auth:bearer {
token: {{accessToken}}
}
params:query {
limit: 50
offset: 0
~search: darktable
}
tests {
test("returns 200", function() {
expect(res.status).to.equal(200);
});
test("has items array", function() {
expect(res.body.items).to.be.an("array");
});
test("each tag has id, name, image_count", function() {
res.body.items.forEach(function(tag) {
expect(tag.id).to.be.a("number");
expect(tag.name).to.be.a("string");
expect(tag.image_count).to.be.a("number");
});
});
test("tags are sorted alphabetically", function() {
var names = res.body.items.map(function(t) { return t.name; });
var sorted = names.slice().sort();
expect(names).to.deep.equal(sorted);
});
}
docs {
## List Tags
Returns all tags in the catalog with their image counts, sorted alphabetically.
Use `?search=keyword` to filter by tag name prefix/substring.
Use `?limit` and `?offset` for pagination (max 2000 per page).
}

View File

@@ -0,0 +1,38 @@
local M = {}
local home = os.getenv("HOME") or "/root"
M.host = os.getenv("DT_API_HOST") or "127.0.0.1"
M.port = tonumber(os.getenv("DT_API_PORT")) or 7645
-- Darktable paths
M.library_db = os.getenv("DT_LIBRARY") or (home .. "/.config/darktable/library.db")
M.data_db = os.getenv("DT_DATA_DB") or (home .. "/.config/darktable/data.db")
M.cache_dir = os.getenv("DT_CACHE_DIR") or (home .. "/.cache/darktable")
-- JWT / OAuth
M.jwt_secret = os.getenv("DT_JWT_SECRET") or "change-this-secret-in-production"
M.token_ttl = tonumber(os.getenv("DT_TOKEN_TTL")) or 3600
-- OAuth 2.0 clients table: client_id -> { secret, scopes[] }
-- Additional clients can be registered by adding entries here or setting
-- DT_CLIENT_ID / DT_CLIENT_SECRET environment variables.
M.clients = {}
local default_id = os.getenv("DT_CLIENT_ID") or "darktable-client"
local default_secret = os.getenv("DT_CLIENT_SECRET") or "changeme"
M.clients[default_id] = {
secret = default_secret,
scopes = { "images:read", "previews:read", "tags:read", "films:read", "cache:refresh" },
}
-- Queue file the bridge plugin watches for cache-refresh requests.
M.refresh_queue = os.getenv("DT_REFRESH_QUEUE") or "/tmp/dt-api-refresh.queue"
-- Queue file the bridge plugin watches for full-resolution export requests.
M.export_queue = os.getenv("DT_EXPORT_QUEUE") or "/tmp/dt-api-export.queue"
-- Directory where the bridge writes full-resolution JPEG exports.
-- Served by GET /api/v1/images/:id/full.
M.export_dir = os.getenv("DT_EXPORT_DIR") or "/tmp/dt-api-exports"
return M

View File

@@ -0,0 +1,302 @@
--[[
darktable-api-bridge.lua
Companion plugin for the darktable REST API server.
Runs inside a live darktable instance and watches two queue files written by
the standalone LuaJIT server.
Refresh queue (DT_REFRESH_QUEUE, default /tmp/dt-api-refresh.queue)
One image ID per line. The bridge calls image:drop_cache() +
image:generate_cache(true, …) so that darktable re-renders thumbnails
through its full processing pipeline, reflecting tone curves, exposure,
colour grading, and all other development settings.
Export queue (DT_EXPORT_QUEUE, default /tmp/dt-api-export.queue)
One image ID per line. The bridge exports a full-resolution JPEG via
darktable's rendering pipeline to DT_EXPORT_DIR/<id>.jpg.
Install: add the following line to ~/.config/darktable/luarc
require "contrib/darktable-api/darktable-api-bridge"
Or let the startup script (start-with-api.sh) do it automatically.
--]]
local dt = require "darktable"
local du = require "lib/dtutils"
du.check_min_api_version("7.0.0", "darktable-api-bridge")
local MODULE = "darktable-api-bridge"
-- ── Configuration ─────────────────────────────────────────────────────────────
-- Must match config.refresh_queue / export_queue / export_dir in config.lua.
local QUEUE_FILE = os.getenv("DT_REFRESH_QUEUE") or "/tmp/dt-api-refresh.queue"
local EXPORT_QUEUE = os.getenv("DT_EXPORT_QUEUE") or "/tmp/dt-api-export.queue"
local EXPORT_DIR = os.getenv("DT_EXPORT_DIR") or "/tmp/dt-api-exports"
local POLL_MS = 1000 -- poll interval in milliseconds
-- Mipmap range to regenerate: 0 = smallest thumbnail, 4 ≈ 1080 px.
local MIP_MIN = 0
local MIP_MAX = 4
-- JPEG quality used for full-resolution exports.
local EXPORT_QUALITY = tonumber(os.getenv("DT_EXPORT_QUALITY")) or 95
-- ── Logging ───────────────────────────────────────────────────────────────────
local function log(msg)
dt.print_log("[" .. MODULE .. "] " .. msg)
end
local function notify(msg)
dt.print("[" .. MODULE .. "] " .. msg)
log(msg)
end
-- ── Image lookup ──────────────────────────────────────────────────────────────
-- Build a fast id→image map from dt.database.
-- dt.database is a table-like object; iterating it is O(n) but fast enough
-- for typical library sizes (thousands of images).
local function build_id_map()
local map = {}
for _, img in ipairs(dt.database) do
map[img.id] = img
end
return map
end
-- ── Queue file handling ───────────────────────────────────────────────────────
-- Atomically claim the queue file by renaming it, then read all IDs from it.
-- Returns a set table { [id] = true } of unique image IDs, or {} if none.
local function drain_queue()
local processing = QUEUE_FILE .. ".processing"
-- Rename is atomic on POSIX filesystems: the server's append-only writes
-- will start a fresh QUEUE_FILE after we claim this one.
local ok = os.rename(QUEUE_FILE, processing)
if not ok then
return {} -- queue file doesn't exist yet
end
local ids = {}
local f = io.open(processing, "r")
if f then
for line in f:lines() do
local id = tonumber(line)
if id then ids[id] = true end
end
f:close()
os.remove(processing)
end
return ids
end
-- ── Mipmap directory ─────────────────────────────────────────────────────────
-- Darktable's mipmap_cache->cachedir is not directly accessible from Lua, so
-- we replicate the naming: SHA1 hex of realpath(library.db) + ".d".
-- We compute it once and cache it here.
local _mipmap_cachedir
local function mipmap_cachedir()
if _mipmap_cachedir then return _mipmap_cachedir end
local cache_dir = os.getenv("DT_CACHE_DIR")
if not cache_dir then
local home = os.getenv("HOME") or "~"
cache_dir = home .. "/.cache/darktable"
end
-- There is exactly one mipmaps-<sha1>.d directory per library.
-- Find it by globbing rather than recomputing the SHA1.
local h = io.popen(string.format("ls -d %q/mipmaps-*.d 2>/dev/null | head -1", cache_dir))
local found = h and h:read("*l"); if h then h:close() end
if found and #found > 0 then
-- Strip trailing ".d" to get the base prefix used in file paths.
_mipmap_cachedir = found:match("^(.+)%.d$") or found
log("mipmap cachedir: " .. _mipmap_cachedir .. ".d")
return _mipmap_cachedir
end
log("WARNING: could not find mipmap cache directory under " .. cache_dir)
return nil
end
-- Delete all mipmap disk files for an image so generate_cache regenerates them.
local function delete_mipmap_files(imgid)
local base = mipmap_cachedir()
if not base then return end
for level = 0, 8 do
local path = string.format("%s.d/%d/%d.jpg", base, level, imgid)
os.remove(path)
end
end
-- ── Cache regeneration ────────────────────────────────────────────────────────
local function refresh_image(img)
local label = string.format("id=%d %s/%s", img.id, img.path, img.filename)
log("refreshing " .. label)
-- Remove disk mipmap files first so generate_cache doesn't skip any level.
-- drop_cache() only clears the in-memory entry; existing disk files would
-- cause generate_cache to skip those levels (it guards with dt_util_test_image_file).
delete_mipmap_files(img.id)
img:drop_cache()
-- create_dirs=true ensures the per-level directories exist.
img:generate_cache(true, MIP_MIN, MIP_MAX)
log("done " .. label)
end
local function export_image(img, dest_path)
local label = string.format("id=%d → %s", img.id, dest_path)
log("exporting " .. label)
local fmt = dt.new_format("jpeg")
fmt.quality = EXPORT_QUALITY
-- max_width/max_height = 0 means no scaling: full resolution.
fmt.max_width = 0
fmt.max_height = 0
local export_err = fmt:write_image(img, dest_path)
if export_err then
error("export failed: " .. tostring(export_err))
end
log("export done " .. label)
end
-- Atomically claim the export queue and return a set of unique image IDs.
local function drain_export_queue()
local processing = EXPORT_QUEUE .. ".processing"
local ok = os.rename(EXPORT_QUEUE, processing)
if not ok then return {} end
local ids = {}
local f = io.open(processing, "r")
if f then
for line in f:lines() do
local id = tonumber(line)
if id then ids[id] = true end
end
f:close()
os.remove(processing)
end
return ids
end
-- Process all pending refresh IDs in one pass.
local function process_queue()
local ids = drain_queue()
local count = 0
for id, _ in pairs(ids) do count = count + 1 end
if count == 0 then return end
log(string.format("processing %d queued refresh request(s)", count))
local id_map = build_id_map()
for id, _ in pairs(ids) do
local img = id_map[id]
if img then
local ok, err = pcall(refresh_image, img)
if not ok then
log("error refreshing id=" .. id .. ": " .. tostring(err))
end
else
log("image id=" .. id .. " not found in database (may have been removed)")
end
end
-- Nudge the lighttable to redraw so updated thumbnails appear immediately.
dt.gui.views.lighttable.is_culling_mode = dt.gui.views.lighttable.is_culling_mode
end
-- Process all pending export IDs in one pass.
local function process_export_queue()
local ids = drain_export_queue()
local count = 0
for id, _ in pairs(ids) do count = count + 1 end
if count == 0 then return end
-- Ensure export directory exists.
os.execute('mkdir -p "' .. EXPORT_DIR .. '"')
log(string.format("processing %d queued export request(s)", count))
local id_map = build_id_map()
for id, _ in pairs(ids) do
local img = id_map[id]
if img then
local dest = EXPORT_DIR .. "/" .. tostring(id) .. ".jpg"
local ok, err = pcall(export_image, img, dest)
if not ok then
log("error exporting id=" .. id .. ": " .. tostring(err))
end
else
log("export: image id=" .. id .. " not found in database")
end
end
end
-- ── Background polling loop ───────────────────────────────────────────────────
-- dt.control.dispatch runs the function asynchronously in darktable's worker
-- thread pool, leaving the UI thread free. We loop inside with sleep() so
-- one dispatch call drives the whole bridge.
local running = true
local function poll_loop()
notify(string.format(
"started; polling queues every %d ms\n refresh: %s\n export: %s → %s",
POLL_MS, QUEUE_FILE, EXPORT_QUEUE, EXPORT_DIR))
while running do
local ok, err = pcall(process_queue)
if not ok then log("process_queue error: " .. tostring(err)) end
local ok2, err2 = pcall(process_export_queue)
if not ok2 then log("process_export_queue error: " .. tostring(err2)) end
dt.control.sleep(POLL_MS)
end
notify("stopped")
end
-- ── Plugin lifecycle ──────────────────────────────────────────────────────────
local script_data = {}
script_data.metadata = {
name = "darktable API bridge",
purpose = "Watch the REST API refresh queue and regenerate image thumbnails",
author = "darktable-api",
help = "https://github.com/darktable-org/lua-scripts",
}
local function destroy()
running = false
-- Give the poll loop one final chance to exit cleanly.
dt.control.sleep(POLL_MS + 200)
dt.destroy_event(MODULE, "shortcut")
end
script_data.destroy = destroy
-- Register a manual-trigger shortcut so the user can force an immediate poll
-- without waiting for the next timer tick.
dt.register_event(MODULE, "shortcut",
function(event, shortcut)
log("manual poll triggered via shortcut")
local ok, err = pcall(process_queue)
if not ok then notify("error during manual poll: " .. tostring(err)) end
local ok2, err2 = pcall(process_export_queue)
if not ok2 then notify("export error during manual poll: " .. tostring(err2)) end
end,
"poll refresh queue now"
)
-- Start the background loop.
dt.control.dispatch(poll_loop)
return script_data

View File

@@ -0,0 +1,525 @@
-- Darktable SQLite catalog access (read-only for image queries; read-write for
-- module-parameter edits via the history table).
-- Schema inspected from an actual darktable library (recent version):
--
-- images(id, group_id, film_id, filename, width, height, aspect_ratio,
-- maker_id, model_id, lens_id, camera_id,
-- exposure, aperture, iso, focal_length, focus_distance,
-- datetime_taken INTEGER (Unix epoch),
-- flags, orientation, longitude, latitude, altitude,
-- version, max_version, write_timestamp, change_timestamp, ...)
-- makers(id, name) models(id, name) lens(id, name)
-- film_rolls(id, access_timestamp, folder)
-- tagged_images(imgid, tagid, position)
-- color_labels(imgid, color) -- color: 0=red 1=yellow 2=green 3=blue 4=purple
-- data.tags(id, name, ...) -- in data.db
-- meta_data(id, key, value) -- key references data.meta_data.key
--
-- images.flags & 0x07 → rating (0=unrated, 1-5=stars, 6=rejected)
-- images.flags & 64 → DT_IMAGE_RAW
-- images.flags & 128 → DT_IMAGE_HDR
-- images.flags & 32 → DT_IMAGE_LDR
local sqlite3 = require "lsqlite3"
local bit = require "bit" -- LuaJIT built-in; Lua 5.1 bitwise
local config = require "config"
local band = bit.band
local unpack = unpack or table.unpack -- Lua 5.1 vs 5.2+ compatibility
local M = {}
-- ── Connections ───────────────────────────────────────────────────────────────
local _db -- read-only, lazy
local _db_rw -- read-write, opened on first write
local function get_db()
if _db then return _db end
_db = sqlite3.open(config.library_db, sqlite3.OPEN_READONLY)
if not _db then
error("Cannot open darktable library: " .. config.library_db)
end
local data_db = config.data_db:gsub("'", "''")
_db:exec(string.format("ATTACH DATABASE '%s' AS data", data_db))
return _db
end
local function get_db_rw()
if _db_rw then return _db_rw end
_db_rw = sqlite3.open(config.library_db) -- read-write
if not _db_rw then
error("Cannot open darktable library for writing: " .. config.library_db)
end
-- WAL mode: allow concurrent reads from the darktable process.
_db_rw:exec("PRAGMA journal_mode=WAL; PRAGMA busy_timeout=5000;")
return _db_rw
end
-- ── Query helpers ─────────────────────────────────────────────────────────────
local function query(sql, params)
local d = get_db()
local stmt = d:prepare(sql)
if not stmt then
error("SQL error: " .. (d:errmsg() or "?") .. "\nSQL: " .. sql)
end
if params and #params > 0 then
stmt:bind_values(unpack(params))
end
local rows = {}
for row in stmt:nrows() do
rows[#rows+1] = row
end
stmt:finalize()
return rows
end
local function query_one(sql, params)
return query(sql, params)[1]
end
-- ── Schema helpers ────────────────────────────────────────────────────────────
-- Rating is packed into the low 3 bits of flags: 0=unrated, 1-5=stars, 6=rejected
local function decode_rating(flags)
local r = band(flags or 0, 0x07)
return r == 6 and -1 or r
end
-- datetime_taken is stored as GLib microseconds since 0001-01-01 00:00:00 UTC.
-- Unix epoch (1970-01-01) = 62135596800 seconds after 0001-01-01.
local GLIB_EPOCH_OFFSET = 62135596800 -- seconds
local function glib_to_unix(glib_us)
if not glib_us or glib_us == 0 then return nil end
return math.floor(glib_us / 1000000) - GLIB_EPOCH_OFFSET
end
local function fmt_datetime(glib_us)
local unix_ts = glib_to_unix(glib_us)
if not unix_ts then return nil end
return os.date("!%Y-%m-%dT%H:%M:%SZ", unix_ts)
end
local LABEL_NAMES = { [0]="red", [1]="yellow", [2]="green", [3]="blue", [4]="purple" }
local function row_to_image(row)
if not row then return nil end
return {
id = row.id,
film_id = row.film_id,
group_id = row.group_id,
filename = row.filename,
path = row.folder,
width = row.width,
height = row.height,
aspect_ratio = row.aspect_ratio,
maker = row.maker,
model = row.model,
lens = row.lens,
exposure = row.exposure,
aperture = row.aperture,
iso = row.iso,
focal_length = row.focal_length,
datetime_taken = fmt_datetime(row.datetime_taken),
rating = decode_rating(row.flags),
is_raw = band(row.flags or 0, 64) ~= 0,
is_hdr = band(row.flags or 0, 128) ~= 0,
is_ldr = band(row.flags or 0, 32) ~= 0,
latitude = row.latitude,
longitude = row.longitude,
altitude = row.altitude,
version = row.version,
write_timestamp = row.write_timestamp,
change_timestamp = row.change_timestamp,
}
end
-- Standard SELECT columns + JOINs used by both list_images and get_image.
local IMAGE_SELECT = [[
SELECT i.id, i.group_id, i.film_id, i.filename,
i.width, i.height, i.aspect_ratio,
mk.name AS maker, mo.name AS model, ln.name AS lens,
i.exposure, i.aperture, i.iso, i.focal_length,
i.datetime_taken, i.flags, i.version,
i.longitude, i.latitude, i.altitude,
i.write_timestamp, i.change_timestamp,
f.folder
FROM images i
JOIN film_rolls f ON f.id = i.film_id
LEFT JOIN makers mk ON mk.id = i.maker_id
LEFT JOIN models mo ON mo.id = i.model_id
LEFT JOIN lens ln ON ln.id = i.lens_id
]]
-- ── Filter builder ────────────────────────────────────────────────────────────
local COLOR_MAP = { red=0, yellow=1, green=2, blue=3, purple=4 }
local VALID_SORT = {
id=true, filename=true, datetime_taken=true, rating=true,
focal_length=true, iso=true,
}
-- Convert a YYYY-MM-DD string to a GLib microsecond timestamp for DB comparison.
local function date_to_glib_us(date_str, end_of_day)
local y, m, d = date_str:match("(%d%d%d%d)[%-:](%d%d)[%-:](%d%d)")
if not y then return nil end
local unix_ts = os.time({
year=tonumber(y), month=tonumber(m), day=tonumber(d),
hour = end_of_day and 23 or 0,
min = end_of_day and 59 or 0,
sec = end_of_day and 59 or 0,
})
return (unix_ts + GLIB_EPOCH_OFFSET) * 1000000
end
local function build_filter(filters)
local conds = {}
local params = {}
-- Star rating (packed in flags & 0x07; 6 = rejected)
if filters.rating_min then
local r = tonumber(filters.rating_min) or 0
table.insert(conds, "(i.flags & 7) >= ?")
table.insert(params, r == -1 and 6 or r)
end
if filters.rating_max then
local r = tonumber(filters.rating_max) or 5
table.insert(conds, "(i.flags & 7) <= ?")
table.insert(params, r == -1 and 6 or r)
end
if filters.rating then
local r = tonumber(filters.rating)
if r then
table.insert(conds, "(i.flags & 7) = ?")
table.insert(params, r == -1 and 6 or r)
end
end
-- Film roll / folder
if filters.film_id then
table.insert(conds, "i.film_id = ?")
table.insert(params, tonumber(filters.film_id))
end
-- Date range (datetime_taken is GLib microseconds since 0001-01-01)
if filters.from then
local glib_us = date_to_glib_us(filters.from, false)
if glib_us then
table.insert(conds, "i.datetime_taken >= ?")
table.insert(params, glib_us)
end
end
if filters.to then
local glib_us = date_to_glib_us(filters.to, true)
if glib_us then
table.insert(conds, "i.datetime_taken <= ?")
table.insert(params, glib_us)
end
end
-- Color label
if filters.color_label then
local cid = COLOR_MAP[filters.color_label:lower()]
if cid ~= nil then
table.insert(conds, "EXISTS (SELECT 1 FROM color_labels cl WHERE cl.imgid=i.id AND cl.color=?)")
table.insert(params, cid)
end
end
-- RAW / HDR flags (SQLite supports & bitwise)
if filters.is_raw == "true" then table.insert(conds, "(i.flags & 64) != 0") end
if filters.is_raw == "false" then table.insert(conds, "(i.flags & 64) = 0") end
if filters.is_hdr == "true" then table.insert(conds, "(i.flags & 128) != 0") end
-- Free-text search across maker/model/lens/filename
if filters.search and filters.search ~= "" then
table.insert(conds, "(i.filename LIKE ? OR mk.name LIKE ? OR mo.name LIKE ? OR ln.name LIKE ?)")
local pat = "%" .. filters.search .. "%"
for _ = 1, 4 do table.insert(params, pat) end
end
-- Tag filter (correlated EXISTS; works for both data.tags and main.tags layouts)
if filters.tag and filters.tag ~= "" then
table.insert(conds, [[EXISTS (
SELECT 1 FROM tagged_images ti2, data.tags t2
WHERE ti2.imgid = i.id AND t2.id = ti2.tagid AND t2.name = ?)]])
table.insert(params, filters.tag)
end
local where = #conds > 0 and ("WHERE " .. table.concat(conds, " AND ")) or ""
return where, params
end
-- ── Public API ────────────────────────────────────────────────────────────────
function M.list_images(filters)
filters = filters or {}
local where, params = build_filter(filters)
local limit = math.max(1, math.min(tonumber(filters.limit) or 50, 500))
local offset = math.max(0, tonumber(filters.offset) or 0)
local sort_by = VALID_SORT[filters.sort_by] and ("i." .. filters.sort_by) or "i.datetime_taken"
local sort_dir = (filters.sort_dir == "asc") and "ASC" or "DESC"
-- Total count (same filter, no pagination)
local count_params = {}
for _, v in ipairs(params) do count_params[#count_params+1] = v end
local count_sql = string.format(
"SELECT COUNT(*) AS total FROM images i " ..
"JOIN film_rolls f ON f.id = i.film_id " ..
"LEFT JOIN makers mk ON mk.id = i.maker_id " ..
"LEFT JOIN models mo ON mo.id = i.model_id " ..
"LEFT JOIN lens ln ON ln.id = i.lens_id %s",
where)
local count_row = query_one(count_sql, count_params)
local total = count_row and count_row.total or 0
-- Data rows
local data_params = {}
for _, v in ipairs(params) do data_params[#data_params+1] = v end
data_params[#data_params+1] = limit
data_params[#data_params+1] = offset
local data_sql = IMAGE_SELECT ..
where ..
string.format(" ORDER BY %s %s LIMIT ? OFFSET ?", sort_by, sort_dir)
local images = {}
for _, row in ipairs(query(data_sql, data_params)) do
images[#images+1] = row_to_image(row)
end
return { total = total, limit = limit, offset = offset, items = images }
end
function M.get_image(id)
local row = query_one(IMAGE_SELECT .. " WHERE i.id = ?", { tonumber(id) })
if not row then return nil end
local img = row_to_image(row)
-- Tags
local tag_rows = query([[
SELECT t.name FROM tagged_images ti
JOIN data.tags t ON t.id = ti.tagid
WHERE ti.imgid = ? ORDER BY t.name
]], { img.id })
img.tags = {}
for _, tr in ipairs(tag_rows) do img.tags[#img.tags+1] = tr.name end
-- Color labels
local cl_rows = query("SELECT color FROM color_labels WHERE imgid=?", { img.id })
img.color_labels = {}
for _, cl in ipairs(cl_rows) do
if LABEL_NAMES[cl.color] then
img.color_labels[#img.color_labels+1] = LABEL_NAMES[cl.color]
end
end
-- Metadata (caption, description, creator, etc. via data.meta_data key map)
local ok_meta, meta_rows = pcall(query, [[
SELECT dm.tagname, m.value
FROM meta_data m JOIN data.meta_data dm ON dm.key = m.key
WHERE m.id = ?
]], { img.id })
img.metadata = {}
if ok_meta then
for _, mr in ipairs(meta_rows) do
local subkey = mr.tagname:match("%.([^%.]+)$") or mr.tagname
img.metadata[subkey] = mr.value
end
end
return img
end
-- ── Tags ──────────────────────────────────────────────────────────────────────
function M.list_tags(filters)
filters = filters or {}
local conds, params = {}, {}
if filters.search and filters.search ~= "" then
table.insert(conds, "t.name LIKE ?")
table.insert(params, "%" .. filters.search .. "%")
end
local where = #conds > 0 and ("WHERE " .. table.concat(conds, " AND ")) or ""
local limit = math.min(tonumber(filters.limit) or 200, 2000)
local offset = tonumber(filters.offset) or 0
params[#params+1] = limit
params[#params+1] = offset
local rows = query(string.format([[
SELECT t.id, t.name,
(SELECT COUNT(*) FROM tagged_images ti WHERE ti.tagid=t.id) AS image_count
FROM data.tags t %s ORDER BY t.name LIMIT ? OFFSET ?
]], where), params)
local tags = {}
for _, r in ipairs(rows) do
tags[#tags+1] = { id=r.id, name=r.name, image_count=r.image_count }
end
return tags
end
-- ── Film rolls ────────────────────────────────────────────────────────────────
function M.list_films(filters)
filters = filters or {}
local conds, params = {}, {}
if filters.search and filters.search ~= "" then
table.insert(conds, "f.folder LIKE ?")
table.insert(params, "%" .. filters.search .. "%")
end
local where = #conds > 0 and ("WHERE " .. table.concat(conds, " AND ")) or ""
local limit = math.min(tonumber(filters.limit) or 200, 2000)
local offset = tonumber(filters.offset) or 0
params[#params+1] = limit
params[#params+1] = offset
local rows = query(string.format([[
SELECT f.id, f.folder, f.access_timestamp,
(SELECT COUNT(*) FROM images i WHERE i.film_id=f.id) AS image_count
FROM film_rolls f %s ORDER BY f.folder LIMIT ? OFFSET ?
]], where), params)
local films = {}
for _, r in ipairs(rows) do
films[#films+1] = {
id = r.id,
folder = r.folder,
access_timestamp = r.access_timestamp,
image_count = r.image_count,
}
end
return films
end
-- ── Module history ────────────────────────────────────────────────────────────
-- The history table stores one or more entries per (imgid, operation).
-- Only the entry with the highest `num` is the active one.
-- `module` column = the params-struct version number for that row.
local modules_mod -- lazy-loaded to avoid circular requires
local function get_modules_mod()
if not modules_mod then modules_mod = require "modules" end
return modules_mod
end
local function history_row_to_module(row)
local mods = get_modules_mod()
local blob = row.op_params or ""
local ver = row.module or 0
local params = mods.decode(row.operation, ver, blob)
return {
operation = row.operation,
enabled = row.enabled ~= 0,
module_version = ver,
multi_name = row.multi_name or "",
multi_priority = row.multi_priority or 0,
history_num = row.num,
params = params, -- nil for unknown modules
params_b64 = params and nil or require("base64").encode(blob),
}
end
-- Return the active (highest-num) history entry for every operation on imgid.
function M.list_modules(imgid)
local rows = query([[
SELECT h.operation, h.module, h.enabled, h.op_params,
h.multi_name, h.multi_priority, h.num
FROM history h
INNER JOIN (
SELECT operation, MAX(num) AS max_num
FROM history WHERE imgid = ?
GROUP BY operation
) latest ON h.operation = latest.operation AND h.num = latest.max_num
WHERE h.imgid = ?
ORDER BY h.operation
]], { tonumber(imgid), tonumber(imgid) })
local result = {}
for _, row in ipairs(rows) do
result[#result+1] = history_row_to_module(row)
end
return result
end
-- Return the raw op_params binary blob for one operation (latest history entry).
function M.get_module_blob(imgid, operation)
local row = query_one([[
SELECT op_params FROM history
WHERE imgid = ? AND operation = ?
ORDER BY num DESC LIMIT 1
]], { tonumber(imgid), operation })
return row and row.op_params or nil
end
-- Return the single active history entry for one operation.
function M.get_module(imgid, operation)
local row = query_one([[
SELECT h.operation, h.module, h.enabled, h.op_params,
h.multi_name, h.multi_priority, h.num
FROM history h
WHERE h.imgid = ? AND h.operation = ?
ORDER BY h.num DESC LIMIT 1
]], { tonumber(imgid), operation })
if not row then return nil end
return history_row_to_module(row)
end
-- Update the active history entry for an operation.
-- `new_blob` (string|nil) – new binary op_params; nil to leave unchanged
-- `new_enabled` (bool|nil) – new enabled flag; nil to leave unchanged
-- Returns true on success, or false + error message.
function M.set_module_params(imgid, operation, new_enabled, new_blob)
-- Find the current latest entry and its num.
local row = query_one([[
SELECT num, module, op_params, enabled, blendop_params, blendop_version,
multi_priority, multi_name, multi_name_hand_edited
FROM history
WHERE imgid = ? AND operation = ?
ORDER BY num DESC LIMIT 1
]], { tonumber(imgid), operation })
if not row then
return false, "module '" .. operation .. "' not found in history for image " .. imgid
end
local d = get_db_rw()
-- Find the global max num for this image so we can insert after it.
local max_row = query_one("SELECT MAX(num) AS m FROM history WHERE imgid=?", {tonumber(imgid)})
local new_num = (max_row and max_row.m or 0) + 1
local enabled_val = (new_enabled == nil) and row.enabled or (new_enabled and 1 or 0)
local blob_val = new_blob or row.op_params
-- Insert a new history entry (preserves darktable's undo history).
local sql = [[
INSERT INTO history
(imgid, num, module, operation, op_params, enabled,
blendop_params, blendop_version, multi_priority, multi_name, multi_name_hand_edited)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
]]
local stmt = d:prepare(sql)
if not stmt then
return false, "SQL prepare failed: " .. (d:errmsg() or "?")
end
stmt:bind_values(
tonumber(imgid), new_num, row.module, operation, blob_val, enabled_val,
row.blendop_params, row.blendop_version,
row.multi_priority, row.multi_name, row.multi_name_hand_edited
)
local rc = stmt:step()
stmt:finalize()
if rc ~= sqlite3.DONE then
return false, "INSERT failed (rc=" .. tostring(rc) .. "): " .. (d:errmsg() or "?")
end
return true
end
return M

View File

@@ -0,0 +1,155 @@
-- Minimal JSON encoder/decoder (pure Lua, no dependencies)
local M = {}
-- ── Encoder ──────────────────────────────────────────────────────────────────
-- Iterate byte-by-byte to avoid null-byte issues in Lua pattern ranges.
local function encode_str(s)
local buf = {'"'}
for i = 1, #s do
local b = s:byte(i)
if b == 34 then buf[#buf+1] = '\\"'
elseif b == 92 then buf[#buf+1] = '\\\\'
elseif b == 10 then buf[#buf+1] = '\\n'
elseif b == 13 then buf[#buf+1] = '\\r'
elseif b == 9 then buf[#buf+1] = '\\t'
elseif b < 32 or b == 127 then
buf[#buf+1] = string.format('\\u%04x', b)
else
buf[#buf+1] = s:sub(i, i)
end
end
buf[#buf+1] = '"'
return table.concat(buf)
end
local function enc(v, depth)
if depth > 64 then error("json.encode: table too deeply nested") end
local t = type(v)
if t == "nil" then return "null"
elseif t == "boolean" then return tostring(v)
elseif t == "number" then
if v ~= v or math.abs(v) == math.huge then return "null" end
return v == math.floor(v) and string.format("%d", v) or string.format("%.10g", v)
elseif t == "string" then
return encode_str(v)
elseif t == "table" then
-- Treat as array when it has a consecutive integer key sequence from 1
if #v > 0 then
local parts = {}
for i = 1, #v do parts[i] = enc(v[i], depth + 1) end
return "[" .. table.concat(parts, ",") .. "]"
end
local parts = {}
for k, x in pairs(v) do
if type(k) == "string" then
parts[#parts+1] = encode_str(k) .. ":" .. enc(x, depth + 1)
end
end
return "{" .. table.concat(parts, ",") .. "}"
end
return "null"
end
function M.encode(v) return enc(v, 0) end
-- ── Decoder ───────────────────────────────────────────────────────────────────
function M.decode(src)
local pos = 1
local function skip()
while pos <= #src and src:byte(pos) <= 32 do pos = pos + 1 end
end
local parse -- forward declaration
local function parse_string()
pos = pos + 1 -- consume opening "
local buf = {}
while pos <= #src do
local c = src:sub(pos, pos)
if c == '"' then pos = pos + 1; return table.concat(buf) end
if c == '\\' then
pos = pos + 1
c = src:sub(pos, pos)
if c == '"' then buf[#buf+1] = '"'
elseif c == '\\' then buf[#buf+1] = '\\'
elseif c == '/' then buf[#buf+1] = '/'
elseif c == 'n' then buf[#buf+1] = '\n'
elseif c == 'r' then buf[#buf+1] = '\r'
elseif c == 't' then buf[#buf+1] = '\t'
elseif c == 'b' then buf[#buf+1] = '\b'
elseif c == 'f' then buf[#buf+1] = '\f'
elseif c == 'u' then
local hex = tonumber(src:sub(pos+1, pos+4), 16) or 0
-- Only emit ASCII; multi-byte unicode emits a placeholder
buf[#buf+1] = hex < 128 and string.char(hex) or '\xEF\xBF\xBD'
pos = pos + 4
end
else
buf[#buf+1] = c
end
pos = pos + 1
end
error("json.decode: unterminated string near pos " .. pos)
end
local function parse_object()
pos = pos + 1 -- consume '{'
local obj = {}
skip()
if src:sub(pos, pos) == '}' then pos = pos + 1; return obj end
while true do
skip()
local key = parse_string()
skip()
if src:sub(pos, pos) ~= ':' then error("json.decode: expected ':' near pos " .. pos) end
pos = pos + 1
skip()
obj[key] = parse()
skip()
local ch = src:sub(pos, pos); pos = pos + 1
if ch == '}' then return obj end
if ch ~= ',' then error("json.decode: expected ',' or '}' near pos " .. pos) end
end
end
local function parse_array()
pos = pos + 1 -- consume '['
local arr = {}
skip()
if src:sub(pos, pos) == ']' then pos = pos + 1; return arr end
while true do
skip()
arr[#arr+1] = parse()
skip()
local ch = src:sub(pos, pos); pos = pos + 1
if ch == ']' then return arr end
if ch ~= ',' then error("json.decode: expected ',' or ']' near pos " .. pos) end
end
end
parse = function()
skip()
local c = src:sub(pos, pos)
if c == '"' then return parse_string()
elseif c == '{' then return parse_object()
elseif c == '[' then return parse_array()
elseif c == 't' then pos = pos + 4; return true
elseif c == 'f' then pos = pos + 5; return false
elseif c == 'n' then pos = pos + 4; return nil
else
-- Parentheses create the capture; without them find returns only start/end.
local _, e, n = src:find("^(-?%d+%.?%d*[eE]?[+-]?%d*)", pos)
if n then pos = e + 1; return tonumber(n) end
error("json.decode: unexpected token '" .. c .. "' at pos " .. pos)
end
end
local ok, result = pcall(parse)
if not ok then return nil, result end
return result
end
return M

View File

@@ -0,0 +1,502 @@
-- Module parameter decoder / encoder for the darktable REST API.
-- Runs in the LuaJIT server process. Uses FFI to unpack and repack the
-- binary op_params blobs stored in the library.db history table.
--
-- Each struct definition mirrors the darktable 4.6 iop C struct exactly so
-- that sizeof() matches the byte count in the database. The `module` column
-- in the history table carries the version number stored for that row.
--
-- Unknown modules (or unsupported versions) pass through as a base64 string.
local ffi = require "ffi"
local base64 = require "base64"
-- ── C struct definitions ───────────────────────────────────────────────────────
ffi.cdef[[
/* --- flip (ver=2, 4 bytes) --- */
typedef struct { int32_t orientation; } dt_flip_v2_t;
/* --- gamma / display encoding (ver=1, 8 bytes) --- */
typedef struct { float gamma; float linear; } dt_gamma_v1_t;
/* --- temperature / white balance (ver=3, 16 bytes) --- */
typedef struct { float red; float green; float blue; float various; } dt_temperature_v3_t;
/* --- exposure (ver=7, 28 bytes) --- */
typedef struct {
int32_t mode;
float black;
float exposure;
float deflicker_percentile;
float deflicker_target_level;
int32_t compensate_exposure_bias;
int32_t compensate_hilite_pres;
} dt_exposure_v7_t;
/* --- rawprepare (ver=1, 28 bytes) --- */
typedef struct {
int32_t left; int32_t top; int32_t right; int32_t bottom;
uint16_t raw_black_level_separate[4];
uint16_t raw_white_point;
uint16_t _pad1;
} dt_rawprepare_v1_t;
/* --- rawprepare (ver=2, 32 bytes) --- */
typedef struct {
int32_t left; int32_t top; int32_t right; int32_t bottom;
uint16_t raw_black_level_separate[4];
uint16_t raw_white_point;
uint16_t _pad1;
int32_t flat_field;
} dt_rawprepare_v2_t;
/* --- demosaic (ver=3, 20 bytes) --- */
typedef struct {
int32_t green_eq;
float median_thrs;
int32_t color_smoothing;
int32_t demosaicing_method;
int32_t lmmse_refine;
} dt_demosaic_v3_t;
/* --- highlights (ver=4, 48 bytes) --- */
typedef struct {
int32_t mode;
float blendL;
float blendC;
float strength;
float clip;
float noise_level;
int32_t iterations;
int32_t scales;
float candidating;
float combine;
int32_t recovery;
float solid_color;
} dt_highlights_v4_t;
/* --- channelmixerrgb (ver=3, 160 bytes) --- */
typedef struct {
float red[4];
float green[4];
float blue[4];
float saturation[4];
float lightness[4];
float grey[4];
int32_t normalize_R;
int32_t normalize_G;
int32_t normalize_B;
int32_t normalize_sat;
int32_t normalize_light;
int32_t normalize_grey;
int32_t illuminant;
int32_t illum_fluo;
int32_t illum_led;
int32_t adaptation;
float x;
float y;
float temperature;
float gamut;
int32_t clip;
int32_t version;
} dt_channelmixerrgb_v3_t;
/* --- filmicrgb (ver=6, 116 bytes) --- */
typedef struct {
float grey_point_source;
float black_point_source;
float white_point_source;
float reconstruct_threshold;
float reconstruct_feather;
float reconstruct_bloom_vs_details;
float reconstruct_grey_vs_color;
float reconstruct_structure_vs_texture;
float security_factor;
float grey_point_target;
float black_point_target;
float white_point_target;
float output_power;
float latitude;
float contrast;
float saturation;
float balance;
float noise_level;
int32_t preserve_color;
int32_t version;
int32_t auto_hardness;
int32_t custom_grey;
int32_t high_quality_reconstruction;
int32_t noise_distribution;
int32_t shadows;
int32_t highlights;
int32_t compensate_icc_black;
int32_t spline_version;
int32_t enable_highlight_reconstruction;
} dt_filmicrgb_v6_t;
]]
-- ── Internal helpers ──────────────────────────────────────────────────────────
local function bool(v) return v ~= 0 end
-- Cast a Lua binary string into a pointer to ctype.
local function cast_blob(ctype, blob)
local buf = ffi.new("uint8_t[?]", #blob)
ffi.copy(buf, blob, #blob)
return ffi.cast(ctype, buf), buf -- return buf too so GC doesn't collect it
end
-- Read a 4-float array field from a cdata array into a Lua table.
local function farr(p, n)
n = n or 4
local t = {}
for i = 0, n-1 do t[i+1] = p[i] end
return t
end
-- Write a Lua table back into a cdata 4-float array.
local function set_farr(p, t, n)
n = n or 4
for i = 0, n-1 do
if t[i+1] ~= nil then p[i] = t[i+1] end
end
end
-- Apply a field-level patch: if `src[k]` exists, set `dst.k = src[k]`.
local function patch_fields(dst, src, ...)
for _, k in ipairs({...}) do
if src[k] ~= nil then dst[k] = src[k] end
end
end
-- Build a fresh binary blob by copying the existing one and applying changes.
local function make_blob(ctype, size, existing, apply_fn)
local buf = ffi.new("uint8_t[?]", size)
if existing then ffi.copy(buf, existing, size) end
local p = ffi.cast(ctype, buf)
apply_fn(p)
return ffi.string(buf, size)
end
-- ── Per-module decode / encode ────────────────────────────────────────────────
local function decode_flip(blob, ver)
if ver ~= 2 or #blob ~= 4 then return nil end
local p, _ = cast_blob("dt_flip_v2_t *", blob)
return { orientation = tonumber(p.orientation) }
end
local function encode_flip(blob, changes)
return make_blob("dt_flip_v2_t *", 4, blob, function(p)
if changes.orientation ~= nil then p.orientation = changes.orientation end
end)
end
-- ---------------------------------------------------------------------------
local function decode_gamma(blob, ver)
if ver ~= 1 or #blob ~= 8 then return nil end
local p, _ = cast_blob("dt_gamma_v1_t *", blob)
return { gamma = tonumber(p.gamma), linear = tonumber(p.linear) }
end
local function encode_gamma(blob, changes)
return make_blob("dt_gamma_v1_t *", 8, blob, function(p)
patch_fields(p, changes, "gamma", "linear")
end)
end
-- ---------------------------------------------------------------------------
local function decode_temperature(blob, ver)
if ver ~= 3 or #blob ~= 16 then return nil end
local p, _ = cast_blob("dt_temperature_v3_t *", blob)
return {
red = tonumber(p.red),
green = tonumber(p.green),
blue = tonumber(p.blue),
various = tonumber(p.various),
}
end
local function encode_temperature(blob, changes)
return make_blob("dt_temperature_v3_t *", 16, blob, function(p)
patch_fields(p, changes, "red", "green", "blue", "various")
end)
end
-- ---------------------------------------------------------------------------
local function decode_exposure(blob, ver)
if ver ~= 7 or #blob ~= 28 then return nil end
local p, _ = cast_blob("dt_exposure_v7_t *", blob)
return {
mode = tonumber(p.mode),
black = tonumber(p.black),
exposure = tonumber(p.exposure),
deflicker_percentile = tonumber(p.deflicker_percentile),
deflicker_target_level = tonumber(p.deflicker_target_level),
compensate_exposure_bias = bool(p.compensate_exposure_bias),
compensate_hilite_pres = bool(p.compensate_hilite_pres),
}
end
local function encode_exposure(blob, changes)
return make_blob("dt_exposure_v7_t *", 28, blob, function(p)
patch_fields(p, changes, "mode", "black", "exposure",
"deflicker_percentile", "deflicker_target_level")
if changes.compensate_exposure_bias ~= nil then
p.compensate_exposure_bias = changes.compensate_exposure_bias and 1 or 0
end
if changes.compensate_hilite_pres ~= nil then
p.compensate_hilite_pres = changes.compensate_hilite_pres and 1 or 0
end
end)
end
-- ---------------------------------------------------------------------------
local function decode_rawprepare(blob, ver)
if ver == 1 and #blob == 28 then
local p, _ = cast_blob("dt_rawprepare_v1_t *", blob)
return {
left = tonumber(p.left), top = tonumber(p.top),
right = tonumber(p.right), bottom = tonumber(p.bottom),
raw_black_level_separate = farr(p.raw_black_level_separate, 4),
raw_white_point = tonumber(p.raw_white_point),
}
elseif ver == 2 and #blob == 32 then
local p, _ = cast_blob("dt_rawprepare_v2_t *", blob)
return {
left = tonumber(p.left), top = tonumber(p.top),
right = tonumber(p.right), bottom = tonumber(p.bottom),
raw_black_level_separate = farr(p.raw_black_level_separate, 4),
raw_white_point = tonumber(p.raw_white_point),
flat_field = tonumber(p.flat_field),
}
end
return nil
end
local function encode_rawprepare(blob, changes, ver)
if ver == 1 then
return make_blob("dt_rawprepare_v1_t *", 28, blob, function(p)
patch_fields(p, changes, "left", "top", "right", "bottom", "raw_white_point")
if changes.raw_black_level_separate then
set_farr(p.raw_black_level_separate, changes.raw_black_level_separate, 4)
end
end)
else
return make_blob("dt_rawprepare_v2_t *", 32, blob, function(p)
patch_fields(p, changes, "left", "top", "right", "bottom", "raw_white_point", "flat_field")
if changes.raw_black_level_separate then
set_farr(p.raw_black_level_separate, changes.raw_black_level_separate, 4)
end
end)
end
end
-- ---------------------------------------------------------------------------
local function decode_demosaic(blob, ver)
if ver ~= 3 or #blob ~= 20 then return nil end
local p, _ = cast_blob("dt_demosaic_v3_t *", blob)
return {
green_eq = tonumber(p.green_eq),
median_thrs = tonumber(p.median_thrs),
color_smoothing = tonumber(p.color_smoothing),
demosaicing_method = tonumber(p.demosaicing_method),
lmmse_refine = tonumber(p.lmmse_refine),
}
end
local function encode_demosaic(blob, changes)
return make_blob("dt_demosaic_v3_t *", 20, blob, function(p)
patch_fields(p, changes, "green_eq", "median_thrs", "color_smoothing",
"demosaicing_method", "lmmse_refine")
end)
end
-- ---------------------------------------------------------------------------
local function decode_highlights(blob, ver)
if ver ~= 4 or #blob ~= 48 then return nil end
local p, _ = cast_blob("dt_highlights_v4_t *", blob)
return {
mode = tonumber(p.mode),
blendL = tonumber(p.blendL),
blendC = tonumber(p.blendC),
strength = tonumber(p.strength),
clip = tonumber(p.clip),
noise_level = tonumber(p.noise_level),
iterations = tonumber(p.iterations),
scales = tonumber(p.scales),
candidating = tonumber(p.candidating),
combine = tonumber(p.combine),
recovery = tonumber(p.recovery),
solid_color = tonumber(p.solid_color),
}
end
local function encode_highlights(blob, changes)
return make_blob("dt_highlights_v4_t *", 48, blob, function(p)
patch_fields(p, changes, "mode", "blendL", "blendC", "strength", "clip",
"noise_level", "iterations", "scales", "candidating",
"combine", "recovery", "solid_color")
end)
end
-- ---------------------------------------------------------------------------
local function decode_channelmixerrgb(blob, ver)
if ver ~= 3 or #blob ~= 160 then return nil end
local p, _ = cast_blob("dt_channelmixerrgb_v3_t *", blob)
return {
red = farr(p.red),
green = farr(p.green),
blue = farr(p.blue),
saturation = farr(p.saturation),
lightness = farr(p.lightness),
grey = farr(p.grey),
normalize_R = bool(p.normalize_R),
normalize_G = bool(p.normalize_G),
normalize_B = bool(p.normalize_B),
normalize_sat = bool(p.normalize_sat),
normalize_light = bool(p.normalize_light),
normalize_grey = bool(p.normalize_grey),
illuminant = tonumber(p.illuminant),
illum_fluo = tonumber(p.illum_fluo),
illum_led = tonumber(p.illum_led),
adaptation = tonumber(p.adaptation),
x = tonumber(p.x),
y = tonumber(p.y),
temperature = tonumber(p.temperature),
gamut = tonumber(p.gamut),
clip = bool(p.clip),
version = tonumber(p.version),
}
end
local function encode_channelmixerrgb(blob, changes)
return make_blob("dt_channelmixerrgb_v3_t *", 160, blob, function(p)
for _, k in ipairs({"red","green","blue","saturation","lightness","grey"}) do
if changes[k] then set_farr(p[k], changes[k], 4) end
end
for _, k in ipairs({"normalize_R","normalize_G","normalize_B",
"normalize_sat","normalize_light","normalize_grey","clip"}) do
if changes[k] ~= nil then p[k] = changes[k] and 1 or 0 end
end
patch_fields(p, changes, "illuminant","illum_fluo","illum_led","adaptation",
"x","y","temperature","gamut","version")
end)
end
-- ---------------------------------------------------------------------------
local function decode_filmicrgb(blob, ver)
if ver ~= 6 or #blob ~= 116 then return nil end
local p, _ = cast_blob("dt_filmicrgb_v6_t *", blob)
return {
grey_point_source = tonumber(p.grey_point_source),
black_point_source = tonumber(p.black_point_source),
white_point_source = tonumber(p.white_point_source),
reconstruct_threshold = tonumber(p.reconstruct_threshold),
reconstruct_feather = tonumber(p.reconstruct_feather),
reconstruct_bloom_vs_details = tonumber(p.reconstruct_bloom_vs_details),
reconstruct_grey_vs_color = tonumber(p.reconstruct_grey_vs_color),
reconstruct_structure_vs_texture = tonumber(p.reconstruct_structure_vs_texture),
security_factor = tonumber(p.security_factor),
grey_point_target = tonumber(p.grey_point_target),
black_point_target = tonumber(p.black_point_target),
white_point_target = tonumber(p.white_point_target),
output_power = tonumber(p.output_power),
latitude = tonumber(p.latitude),
contrast = tonumber(p.contrast),
saturation = tonumber(p.saturation),
balance = tonumber(p.balance),
noise_level = tonumber(p.noise_level),
preserve_color = tonumber(p.preserve_color),
version = tonumber(p.version),
auto_hardness = bool(p.auto_hardness),
custom_grey = bool(p.custom_grey),
high_quality_reconstruction = tonumber(p.high_quality_reconstruction),
noise_distribution = tonumber(p.noise_distribution),
shadows = tonumber(p.shadows),
highlights = tonumber(p.highlights),
compensate_icc_black = bool(p.compensate_icc_black),
spline_version = tonumber(p.spline_version),
enable_highlight_reconstruction = bool(p.enable_highlight_reconstruction),
}
end
local function encode_filmicrgb(blob, changes)
return make_blob("dt_filmicrgb_v6_t *", 116, blob, function(p)
patch_fields(p, changes,
"grey_point_source","black_point_source","white_point_source",
"reconstruct_threshold","reconstruct_feather",
"reconstruct_bloom_vs_details","reconstruct_grey_vs_color",
"reconstruct_structure_vs_texture","security_factor",
"grey_point_target","black_point_target","white_point_target",
"output_power","latitude","contrast","saturation","balance","noise_level",
"preserve_color","version","high_quality_reconstruction",
"noise_distribution","shadows","highlights","spline_version")
for _, k in ipairs({"auto_hardness","custom_grey","compensate_icc_black",
"enable_highlight_reconstruction"}) do
if changes[k] ~= nil then p[k] = changes[k] and 1 or 0 end
end
end)
end
-- ── Dispatch tables ───────────────────────────────────────────────────────────
local DECODERS = {
flip = decode_flip,
gamma = decode_gamma,
temperature = decode_temperature,
exposure = decode_exposure,
rawprepare = decode_rawprepare,
demosaic = decode_demosaic,
highlights = decode_highlights,
channelmixerrgb = decode_channelmixerrgb,
filmicrgb = decode_filmicrgb,
}
local ENCODERS = {
flip = encode_flip,
gamma = encode_gamma,
temperature = encode_temperature,
exposure = encode_exposure,
rawprepare = function(b, c, v) return encode_rawprepare(b, c, v) end,
demosaic = encode_demosaic,
highlights = encode_highlights,
channelmixerrgb = encode_channelmixerrgb,
filmicrgb = encode_filmicrgb,
}
-- ── Public API ────────────────────────────────────────────────────────────────
local M = {}
-- Decode a binary op_params blob for `operation` (ver = history.module column).
-- Returns a Lua table of named fields, or nil if the operation/version is unknown.
function M.decode(operation, ver, blob)
local fn = DECODERS[operation]
if not fn then return nil end
local ok, result = pcall(fn, blob, ver)
if ok then return result end
return nil
end
-- Apply `changes` (a table of field overrides) to `blob` and return the
-- modified binary string. Returns nil if the operation is not known.
-- For unknown modules, the caller should pass params_b64 directly.
function M.encode(operation, ver, blob, changes)
local fn = ENCODERS[operation]
if not fn then return nil end
local ok, result = pcall(fn, blob, changes, ver)
if ok then return result end
return nil
end
return M

View File

@@ -0,0 +1,131 @@
-- Serve image previews from darktable's mipmap cache.
--
-- Darktable stores mipmaps as individual JPEG files at:
-- <cache_dir>/mipmaps-<sha1_of_library_realpath>.d/<mip_level>/<imgid>.jpg
--
-- Mip levels (approximate pixel sizes on the long edge):
-- 0 → ~67 px 1 → ~135 px 2 → ~270 px 3 → ~540 px
-- 4 → ~1080 px (good "medium") 5 → ~2160 px
--
-- If no cached mipmap is found we fall back to exiftool (embedded EXIF
-- thumbnail) and finally to serving the original file path as a redirect.
local ffi = require "ffi"
local config = require "config"
ffi.cdef[[
unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);
]]
local crypto = ffi.load("crypto")
local M = {}
-- ── Locate the mipmap cache directory (computed once) ─────────────────────────
local _mipmap_base -- e.g. "/home/user/.cache/darktable/mipmaps-abc123"
local function mipmap_base()
if _mipmap_base then return _mipmap_base end
-- Resolve the real path of library.db (darktable uses realpath before hashing)
local h = io.popen("realpath " .. config.library_db .. " 2>/dev/null")
local realpath = h:read("*l"); h:close()
realpath = realpath or config.library_db
-- SHA1 hex of the realpath (same algorithm as mipmap_cache.c)
local md = ffi.new("unsigned char[20]")
crypto.SHA1(realpath, #realpath, md)
local hex = {}
for i = 0, 19 do hex[i+1] = string.format("%02x", md[i]) end
local sha1hex = table.concat(hex)
_mipmap_base = config.cache_dir .. "/mipmaps-" .. sha1hex
return _mipmap_base
end
-- ── Size → mip level mapping ──────────────────────────────────────────────────
-- size param: "thumb" (~135 px), "small" (~270 px), "medium" (~540 px),
-- "large" (~1080 px), "xlarge" (~2160 px), or an integer level 0-5.
local SIZE_TO_MIP = {
thumb = 1,
small = 2,
medium = 3,
large = 4,
xlarge = 5,
}
local function size_to_mip(size)
if not size or size == "" then return 3 end -- default: "medium"
local n = tonumber(size)
if n then return math.max(0, math.min(5, math.floor(n))) end
return SIZE_TO_MIP[size:lower()] or 3
end
-- ── Try to read a file, return nil on failure ─────────────────────────────────
local function read_file(path)
local f = io.open(path, "rb")
if not f then return nil end
local data = f:read("*a")
f:close()
return data
end
-- ── Public: get preview data for an image id ──────────────────────────────────
--
-- Returns: data (string), content_type (string)
-- or: nil, nil, redirect_url (caller should issue a 302)
-- or: nil, nil, nil (404)
function M.get(image_id, image_path, filename, size_param)
local mip = size_to_mip(size_param)
-- 1. Walk mip levels: first downward (smaller = smaller file, faster),
-- then upward (larger mip levels, let the browser scale down).
-- This ensures we serve something even when only higher-resolution
-- mipmaps have been cached (e.g. darktable only wrote levels 2-4).
local base = mipmap_base()
for level = mip, 0, -1 do
local path = string.format("%s.d/%d/%d.jpg", base, level, image_id)
local data = read_file(path)
if data then return data, "image/jpeg" end
end
for level = mip + 1, 5 do
local path = string.format("%s.d/%d/%d.jpg", base, level, image_id)
local data = read_file(path)
if data then return data, "image/jpeg" end
end
-- 2. Try exiftool to extract the embedded EXIF thumbnail from the source file.
if image_path and filename then
local src = image_path .. "/" .. filename
-- exiftool writes the thumbnail to stdout with -b
local cmd = string.format("exiftool -b -ThumbnailImage %q 2>/dev/null", src)
local fh = io.popen(cmd)
if fh then
local data = fh:read("*a"); fh:close()
if data and #data > 100 then
return data, "image/jpeg"
end
end
end
-- 3. For JPEG/PNG source files redirect to the original (client caches it).
if image_path and filename then
local src = image_path .. "/" .. filename
local ext = filename:match("%.([^%.]+)$") or ""
if ext:lower():match("^jpe?g$") or ext:lower() == "png" then
return nil, nil, "file://" .. src -- caller issues redirect or reads directly
end
end
return nil, nil, nil -- no preview available
end
-- ── Helper: read a local file and serve it inline ─────────────────────────────
-- Used by the API handler when get() returns a file:// redirect.
function M.read_local(path)
local stripped = path:match("^file://(.+)$") or path
return read_file(stripped)
end
return M

View File

@@ -0,0 +1,68 @@
-- Simple radix-style HTTP router.
-- Supports static segments and named captures (:name).
-- Usage:
-- router.get("/api/v1/images", handler)
-- router.get("/api/v1/images/:id", handler)
-- router.post("/oauth/token", handler)
--
-- local handler, params = router.match("GET", "/api/v1/images/42")
-- -- handler = <function>, params = { id = "42" }
local M = {}
local routes = {} -- { method, pattern_parts, handler }
-- Convert a route pattern like "/api/v1/images/:id/preview" into a segment list.
local function compile(pattern)
local parts = {}
-- Strip leading slash so the segment list aligns with the path splitter below.
for seg in (pattern:gsub("^/", "") .. "/"):gmatch("([^/]*)/") do
if seg:sub(1,1) == ":" then
parts[#parts+1] = { capture = seg:sub(2) }
else
parts[#parts+1] = { literal = seg }
end
end
return parts
end
local function register(method, pattern, handler)
routes[#routes+1] = { method = method:upper(), parts = compile(pattern), handler = handler }
end
function M.get(pattern, handler) register("GET", pattern, handler) end
function M.post(pattern, handler) register("POST", pattern, handler) end
function M.put(pattern, handler) register("PUT", pattern, handler) end
function M.patch(pattern, handler) register("PATCH", pattern, handler) end
function M.delete(pattern, handler) register("DELETE", pattern, handler) end
-- Match a request against registered routes.
-- Returns: handler, path_params or nil, nil
function M.match(method, path)
-- Split path into segments
local segs = {}
for seg in (path:gsub("^/","") .. "/"):gmatch("([^/]*)/") do
segs[#segs+1] = seg
end
method = method:upper()
for _, route in ipairs(routes) do
if route.method == method and #route.parts == #segs then
local params = {}
local matched = true
for i, part in ipairs(route.parts) do
if part.capture then
params[part.capture] = segs[i]
elseif part.literal ~= segs[i] then
matched = false
break
end
end
if matched then return route.handler, params end
end
end
return nil, nil
end
return M

View File

@@ -0,0 +1,280 @@
#!/usr/bin/env luajit
-- Darktable REST API — standalone LuaJIT HTTP server
-- Usage: luajit server.lua [port] [host]
--
-- Dependencies (install via luarocks):
-- luasocket — luarocks install luasocket
-- lsqlite3 — luarocks install lsqlite3
-- libcrypto — provided by the system OpenSSL package
--
-- Quick-start:
-- export DT_CLIENT_ID=myclient DT_CLIENT_SECRET=mysecret DT_JWT_SECRET=longrandomstring
-- luajit server.lua
--
-- Then get a token:
-- curl -s -X POST http://127.0.0.1:7645/oauth/token \
-- -d 'grant_type=client_credentials&client_id=myclient&client_secret=mysecret'
--
-- And use it:
-- curl -s -H "Authorization: Bearer <token>" http://127.0.0.1:7645/api/v1/images
-- ── Bootstrap: make local modules findable ────────────────────────────────────
local script_dir = debug.getinfo(1, "S").source:match("^@(.+)/[^/]+$") or "."
package.path = script_dir .. "/?.lua;" .. package.path
-- ── Load modules ──────────────────────────────────────────────────────────────
local socket = require "socket"
local config = require "config"
local router = require "router"
local api = require "api"
-- ── Static file server (PWA) ──────────────────────────────────────────────────
local WEB_BUILD = script_dir .. "/web/build"
local MIME = {
html = "text/html; charset=utf-8",
js = "application/javascript; charset=utf-8",
mjs = "application/javascript; charset=utf-8",
css = "text/css; charset=utf-8",
json = "application/json",
webmanifest = "application/manifest+json",
png = "image/png",
jpg = "image/jpeg",
jpeg = "image/jpeg",
svg = "image/svg+xml",
ico = "image/x-icon",
woff = "font/woff",
woff2 = "font/woff2",
txt = "text/plain; charset=utf-8",
map = "application/json",
}
-- Read a file from the web build directory. Returns data, content-type or nil.
-- Prevents directory traversal by rejecting any path containing "..".
local function read_static(req_path)
if req_path:find("%.%.", 1, true) then return nil end
-- Strip leading slash; normalise double-slashes.
local rel = req_path:gsub("^/+", ""):gsub("//+", "/")
local full = WEB_BUILD .. "/" .. rel
local f = io.open(full, "rb")
if not f then return nil end
local data = f:read("*a")
f:close()
local ext = rel:match("%.([^%.]+)$") or ""
local ct = MIME[ext:lower()] or "application/octet-stream"
return data, ct
end
-- Cache headers: hashed assets get long TTL; everything else no-store.
local function cache_header(path)
-- Vite fingerprints assets with a hash in the filename (e.g. index-Bx3Rk.js)
if path:match("/assets/") then
return "public, max-age=31536000, immutable"
end
return "no-store"
end
-- ── Register routes ───────────────────────────────────────────────────────────
router.post("/oauth/token", api.oauth_token)
router.get("/health", api.health)
router.get("/api/v1/images", api.list_images)
router.get("/api/v1/images/:id", api.get_image)
router.get("/api/v1/images/:id/preview", api.get_preview)
router.get("/api/v1/images/:id/full", api.get_full)
router.post("/api/v1/images/:id/refresh", api.refresh_cache)
router.post("/api/v1/images/:id/export", api.trigger_export)
router.get("/api/v1/images/:id/modules", api.list_modules)
router.get("/api/v1/images/:id/modules/:op", api.get_module)
router.patch("/api/v1/images/:id/modules/:op", api.patch_module)
router.get("/api/v1/tags", api.list_tags)
router.get("/api/v1/films", api.list_films)
-- ── HTTP helpers ──────────────────────────────────────────────────────────────
local STATUS_TEXT = {
[200] = "OK", [201] = "Created", [202] = "Accepted", [204] = "No Content",
[301] = "Moved Permanently",
[400] = "Bad Request", [401] = "Unauthorized", [403] = "Forbidden",
[404] = "Not Found", [405] = "Method Not Allowed",
[500] = "Internal Server Error", [504] = "Gateway Timeout",
}
local function url_decode(s)
return s:gsub("+", " "):gsub("%%(%x%x)", function(h) return string.char(tonumber(h, 16)) end)
end
-- Parse the raw HTTP request from a connected socket.
-- Returns a request table, or nil on parse/timeout error.
local function read_request(client)
client:settimeout(10)
local line, lerr = client:receive("*l")
if not line then return nil end
local method, raw_path = line:match("^(%S+)%s+(%S+)%s+HTTP/")
if not method then return nil end
-- Headers
local headers = {}
while true do
local hline, herr = client:receive("*l")
if not hline or hline == "" then break end
local name, value = hline:match("^([^:]+):%s*(.*)$")
if name then
-- normalise to lowercase, strip trailing whitespace
headers[name:lower():gsub("%s+$", "")] = value:gsub("%s+$", "")
end
end
-- Body
local body = ""
local clen = tonumber(headers["content-length"])
if clen and clen > 0 then
body = client:receive(math.min(clen, 4 * 1024 * 1024)) or "" -- 4 MiB cap
end
-- Split path from query string
local path, qs = raw_path:match("^([^?]*)%??(.*)")
-- Parse query parameters
local params = {}
for k, v in (qs or ""):gmatch("([^&=]+)=([^&]*)") do
params[url_decode(k)] = url_decode(v)
end
return {
method = method:upper(),
path = path,
raw_path = raw_path,
headers = headers,
body = body,
params = params,
path_params = {},
}
end
local CORS_HEADERS = {
["Access-Control-Allow-Origin"] = "*",
["Access-Control-Allow-Methods"] = "GET, POST, PATCH, PUT, DELETE, OPTIONS",
["Access-Control-Allow-Headers"] = "Authorization, Content-Type",
["Access-Control-Max-Age"] = "86400",
}
-- Write an HTTP response to the socket.
local function write_response(client, status, body, content_type, extra_headers)
body = body or ""
content_type = content_type or "application/json; charset=utf-8"
local phrase = STATUS_TEXT[status] or "Unknown"
local lines = {
string.format("HTTP/1.1 %d %s\r\n", status, phrase),
"Server: darktable-api/1.0\r\n",
"Content-Type: " .. content_type .. "\r\n",
"Content-Length: " .. #body .. "\r\n",
"Connection: close\r\n",
}
for k, v in pairs(CORS_HEADERS) do
lines[#lines+1] = k .. ": " .. v .. "\r\n"
end
if extra_headers then
for k, v in pairs(extra_headers) do
lines[#lines+1] = k .. ": " .. v .. "\r\n"
end
end
lines[#lines+1] = "\r\n"
lines[#lines+1] = body
client:send(table.concat(lines))
end
local json = require "json"
local function handle_client(client)
local req = read_request(client)
if not req then
write_response(client, 400, '{"error":"bad_request"}')
return
end
-- CORS preflight
if req.method == "OPTIONS" then
write_response(client, 204, "")
return
end
-- API / OAuth routes take priority over static files.
local handler, path_params = router.match(req.method, req.path)
if handler then
req.path_params = path_params or {}
local status, body, ct, extra = handler(req)
write_response(client, status, body, ct, extra)
return
end
-- Static file serving for the PWA (GET/HEAD only).
if req.method == "GET" or req.method == "HEAD" then
local data, ct = read_static(req.path)
if not data then
-- SPA fallback: any unknown path gets index.html so client-side routing works.
data, ct = read_static("/index.html")
end
if data then
local extra = { ["Cache-Control"] = cache_header(req.path) }
write_response(client, 200, req.method == "HEAD" and "" or data, ct, extra)
return
end
end
write_response(client, 404, json.encode({ error = "not_found", path = req.path }))
end
-- ── Main server loop ──────────────────────────────────────────────────────────
local port = tonumber(arg and arg[1]) or config.port
local host = (arg and arg[2]) or config.host
local server, serr = socket.bind(host, port)
if not server then
io.stderr:write("darktable-api: cannot bind " .. host .. ":" .. port .. ": " .. tostring(serr) .. "\n")
os.exit(1)
end
server:settimeout(0) -- non-blocking accept
io.write(string.format(
"darktable-api: listening on http://%s:%d\n" ..
" library : %s\n" ..
" cache : %s\n" ..
" web app : http://%s:%d/\n",
host, port, config.library_db, config.cache_dir, host, port))
io.flush()
while true do
local client, cerr = server:accept()
if client then
local ok, result = pcall(handle_client, client)
if not ok then
pcall(write_response, client, 500,
json.encode({ error = "internal_server_error", detail = tostring(result) }))
io.stderr:write("darktable-api: error: " .. tostring(result) .. "\n")
end
pcall(function() client:close() end)
else
-- No connection yet — yield CPU briefly.
socket.select(nil, nil, 0.05)
end
end

View File

@@ -0,0 +1,109 @@
#!/usr/bin/env bash
# start-with-api.sh — Launch the darktable REST API server and darktable together.
#
# What it does:
# 1. Optionally configures darktable's luarc to load the bridge plugin.
# 2. Starts the standalone LuaJIT REST API server in the background.
# 3. Starts darktable in the foreground.
# 4. Stops the API server when darktable exits.
#
# Usage:
# ./start-with-api.sh [darktable-options...]
#
# Environment variables (all optional):
# DT_CLIENT_ID OAuth client ID (default: darktable-client)
# DT_CLIENT_SECRET OAuth client secret (default: changeme)
# DT_JWT_SECRET JWT signing secret (default: change-this-secret-in-production)
# DT_API_HOST Server bind address (default: 127.0.0.1)
# DT_API_PORT Server port (default: 7645)
# DT_LIBRARY darktable library DB (default: ~/.config/darktable/library.db)
# DT_REFRESH_QUEUE IPC queue file (default: /tmp/dt-api-refresh.queue)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
: "${DT_CLIENT_ID:=darktable-client}"
: "${DT_CLIENT_SECRET:=changeme}"
: "${DT_JWT_SECRET:=change-this-secret-in-production}"
: "${DT_API_HOST:=127.0.0.1}"
: "${DT_API_PORT:=7645}"
: "${DT_REFRESH_QUEUE:=/tmp/dt-api-refresh.queue}"
export DT_CLIENT_ID DT_CLIENT_SECRET DT_JWT_SECRET
export DT_API_HOST DT_API_PORT DT_REFRESH_QUEUE
# ── 1. Ensure the bridge plugin is in darktable's luarc ───────────────────────
LUARC="$HOME/.config/darktable/luarc"
BRIDGE_REQUIRE='require "contrib/darktable-api/darktable-api-bridge"'
if ! grep -qF "$BRIDGE_REQUIRE" "$LUARC" 2>/dev/null; then
echo "[start-with-api] Adding bridge plugin to $LUARC"
echo "$BRIDGE_REQUIRE" >> "$LUARC"
fi
# ── 2. Install the bridge plugin into darktable's lua directory ───────────────
# darktable searches $HOME/.config/darktable/lua/ for scripts.
# We copy (not symlink) the bridge plugin file there so darktable can
# require "contrib/darktable-api/darktable-api-bridge" without any extra path config.
DT_LUA_DIR="$HOME/.config/darktable/lua"
BRIDGE_DEST="$DT_LUA_DIR/contrib/darktable-api"
BRIDGE_SRC="$SCRIPT_DIR/darktable-api-bridge.lua"
mkdir -p "$BRIDGE_DEST"
if ! cmp -s "$BRIDGE_SRC" "$BRIDGE_DEST/darktable-api-bridge.lua" 2>/dev/null; then
cp "$BRIDGE_SRC" "$BRIDGE_DEST/darktable-api-bridge.lua"
echo "[start-with-api] Installed bridge plugin → $BRIDGE_DEST/"
fi
# ── 3. Clean up any stale queue file ─────────────────────────────────────────
rm -f "$DT_REFRESH_QUEUE" "${DT_REFRESH_QUEUE}.processing"
# ── 4. Start the LuaJIT REST API server ───────────────────────────────────────
API_LOG="${TMPDIR:-/tmp}/darktable-api.log"
echo "[start-with-api] Starting API server on http://${DT_API_HOST}:${DT_API_PORT}"
echo "[start-with-api] Log: $API_LOG"
luajit "$SCRIPT_DIR/server.lua" "$DT_API_PORT" "$DT_API_HOST" >"$API_LOG" 2>&1 &
API_PID=$!
# Give the server a moment to bind and confirm it's up.
sleep 0.5
if ! kill -0 "$API_PID" 2>/dev/null; then
echo "[start-with-api] ERROR: API server failed to start. Check $API_LOG" >&2
cat "$API_LOG" >&2
exit 1
fi
if ! curl -sf "http://${DT_API_HOST}:${DT_API_PORT}/health" >/dev/null 2>&1; then
echo "[start-with-api] WARNING: health check failed; server may still be starting"
fi
echo "[start-with-api] API server running (PID $API_PID)"
echo ""
echo " Get a token:"
echo " curl -X POST http://${DT_API_HOST}:${DT_API_PORT}/oauth/token \\"
echo " -d 'grant_type=client_credentials&client_id=${DT_CLIENT_ID}&client_secret=${DT_CLIENT_SECRET}'"
echo ""
echo " Trigger a cache refresh (replace TOKEN and IMAGE_ID):"
echo " curl -X POST http://${DT_API_HOST}:${DT_API_PORT}/api/v1/images/IMAGE_ID/refresh \\"
echo " -H 'Authorization: Bearer TOKEN'"
echo ""
# ── 5. Start darktable ────────────────────────────────────────────────────────
echo "[start-with-api] Starting darktable..."
darktable "$@" || true
# ── 6. Stop the API server on exit ───────────────────────────────────────────
echo ""
echo "[start-with-api] darktable exited; stopping API server (PID $API_PID)"
kill "$API_PID" 2>/dev/null || true
wait "$API_PID" 2>/dev/null || true
rm -f "$DT_REFRESH_QUEUE" "${DT_REFRESH_QUEUE}.processing"
echo "[start-with-api] done"

4
contrib/darktable-api/web/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
node_modules/
build/
dist/
.vite/

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/icon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<meta name="theme-color" content="#0d0d0d" />
<meta name="description" content="darktable REST API web interface" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="darktable" />
<link rel="apple-touch-icon" href="/icon.svg" />
<title>darktable Gallery</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>

6058
contrib/darktable-api/web/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,20 @@
{
"name": "darktable-api-pwa",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.3.4",
"vite": "^5.4.11",
"vite-plugin-pwa": "^0.21.1"
}
}

View File

@@ -0,0 +1,28 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<!-- Dark background -->
<rect width="512" height="512" rx="80" fill="#0d0d0d"/>
<!-- Aperture blades in orange accent -->
<!-- Center circle -->
<circle cx="256" cy="256" r="60" fill="none" stroke="#f4a22d" stroke-width="8"/>
<!-- Aperture blade 1 -->
<path d="M256 120 L296 196 L256 196 Z" fill="#f4a22d" opacity="0.9"/>
<!-- Aperture blade 2 -->
<path d="M370 181 L316 240 L296 196 Z" fill="#f4a22d" opacity="0.9"/>
<!-- Aperture blade 3 -->
<path d="M392 296 L316 240 L336 296 Z" fill="#f4a22d" opacity="0.9"/>
<!-- Aperture blade 4 -->
<path d="M336 392 L256 316 L336 296 Z" fill="#f4a22d" opacity="0.9"/>
<!-- Aperture blade 5 -->
<path d="M176 392 L196 316 L256 316 Z" fill="#f4a22d" opacity="0.9"/>
<!-- Aperture blade 6 -->
<path d="M120 296 L196 316 L176 240 Z" fill="#f4a22d" opacity="0.9"/>
<!-- Aperture blade 7 -->
<path d="M120 181 L176 240 L196 196 Z" fill="#f4a22d" opacity="0.9"/>
<!-- Aperture blade 8 -->
<path d="M216 120 L216 196 L256 196 Z" fill="#f4a22d" opacity="0.9"/>
<!-- Outer ring -->
<circle cx="256" cy="256" r="180" fill="none" stroke="#f4a22d" stroke-width="12" opacity="0.6"/>
<!-- Inner highlight -->
<circle cx="256" cy="256" r="40" fill="#f4a22d" opacity="0.3"/>
<circle cx="256" cy="256" r="20" fill="#f4a22d"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,69 @@
import React, {
createContext,
useCallback,
useContext,
useEffect,
useReducer,
} from 'react';
import { ToastProvider } from './components/Toast.jsx';
import { getSettings } from './api.js';
import Settings from './screens/Settings.jsx';
import Gallery from './screens/Gallery.jsx';
// ── App Context ───────────────────────────────────────────────────────────────
const AppContext = createContext(null);
export function useApp() {
const ctx = useContext(AppContext);
if (!ctx) throw new Error('useApp must be used within AppContext');
return ctx;
}
const initialState = {
screen: 'gallery', // 'settings' | 'gallery'
configured: false,
};
function reducer(state, action) {
switch (action.type) {
case 'INIT':
return { ...state, configured: action.configured, screen: action.configured ? 'gallery' : 'settings' };
case 'GO_SETTINGS':
return { ...state, screen: 'settings' };
case 'GO_GALLERY':
return { ...state, screen: 'gallery', configured: true };
default:
return state;
}
}
// ── App Root ──────────────────────────────────────────────────────────────────
export default function App() {
const [state, dispatch] = useReducer(reducer, initialState);
useEffect(() => {
const settings = getSettings();
dispatch({ type: 'INIT', configured: !!settings });
}, []);
const goSettings = useCallback(() => dispatch({ type: 'GO_SETTINGS' }), []);
const goGallery = useCallback(() => dispatch({ type: 'GO_GALLERY' }), []);
const contextValue = { goSettings, goGallery, configured: state.configured };
return (
<AppContext.Provider value={contextValue}>
<ToastProvider>
<div style={{ height: '100%', display: 'flex', flexDirection: 'column' }}>
{state.screen === 'settings' ? (
<Settings />
) : (
<Gallery />
)}
</div>
</ToastProvider>
</AppContext.Provider>
);
}

View File

@@ -0,0 +1,353 @@
// Darktable REST API client
// Handles OAuth2 client_credentials, token caching, all endpoints.
const STORAGE_KEYS = {
SETTINGS: 'dt_settings',
TOKEN: 'dt_token',
};
// ── Settings ─────────────────────────────────────────────────────────────────
export function getSettings() {
try {
const raw = localStorage.getItem(STORAGE_KEYS.SETTINGS);
return raw ? JSON.parse(raw) : null;
} catch {
return null;
}
}
export function saveSettings(settings) {
localStorage.setItem(STORAGE_KEYS.SETTINGS, JSON.stringify(settings));
}
export function clearSettings() {
localStorage.removeItem(STORAGE_KEYS.SETTINGS);
localStorage.removeItem(STORAGE_KEYS.TOKEN);
}
// ── Token management ──────────────────────────────────────────────────────────
function getCachedToken() {
try {
const raw = localStorage.getItem(STORAGE_KEYS.TOKEN);
if (!raw) return null;
const token = JSON.parse(raw);
// Treat as expired 30 seconds early to avoid race conditions
if (Date.now() >= token.expiresAt - 30_000) return null;
return token.accessToken;
} catch {
return null;
}
}
function cacheToken(accessToken, expiresIn) {
const token = {
accessToken,
expiresAt: Date.now() + expiresIn * 1000,
};
localStorage.setItem(STORAGE_KEYS.TOKEN, JSON.stringify(token));
}
let tokenFetchPromise = null;
async function fetchToken(settings) {
const url = `${settings.baseUrl}/oauth/token`;
const body = new URLSearchParams({
grant_type: 'client_credentials',
client_id: settings.clientId,
client_secret: settings.clientSecret,
});
const res = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: body.toString(),
});
if (!res.ok) {
const text = await res.text().catch(() => '');
throw new ApiError(res.status, `Token request failed: ${text || res.statusText}`);
}
const data = await res.json();
const expiresIn = data.expires_in ?? 3600;
cacheToken(data.access_token, expiresIn);
return data.access_token;
}
async function getToken() {
const settings = getSettings();
if (!settings) throw new ApiError(0, 'Not configured. Please open Settings.');
const cached = getCachedToken();
if (cached) return cached;
// Deduplicate concurrent token fetches
if (!tokenFetchPromise) {
tokenFetchPromise = fetchToken(settings).finally(() => {
tokenFetchPromise = null;
});
}
return tokenFetchPromise;
}
// ── Error class ───────────────────────────────────────────────────────────────
export class ApiError extends Error {
constructor(status, message) {
super(message);
this.status = status;
this.name = 'ApiError';
}
}
// ── Core fetch helper ─────────────────────────────────────────────────────────
async function apiFetch(path, options = {}) {
const settings = getSettings();
if (!settings) throw new ApiError(0, 'Not configured. Please open Settings.');
const token = await getToken();
const url = `${settings.baseUrl}${path}`;
const headers = {
Authorization: `Bearer ${token}`,
...options.headers,
};
const res = await fetch(url, { ...options, headers });
if (!res.ok) {
const text = await res.text().catch(() => '');
let message;
try {
const json = JSON.parse(text);
message = json.error || json.message || text;
} catch {
message = text || res.statusText;
}
throw new ApiError(res.status, message);
}
return res;
}
async function apiJson(path, options = {}) {
const res = await apiFetch(path, {
...options,
headers: { Accept: 'application/json', ...options.headers },
});
return res.json();
}
// ── Blob URL cache ────────────────────────────────────────────────────────────
// Keeps a reference-counted map of blob URLs so we don't recreate them for the
// same image+size combination within a session.
const blobCache = new Map(); // key → { url, refs }
export function releaseBlobUrl(key) {
const entry = blobCache.get(key);
if (!entry) return;
entry.refs -= 1;
if (entry.refs <= 0) {
URL.revokeObjectURL(entry.url);
blobCache.delete(key);
}
}
export async function getPreviewBlob(id, size = 'thumb') {
const key = `preview:${id}:${size}`;
const existing = blobCache.get(key);
if (existing) {
existing.refs += 1;
return { url: existing.url, key };
}
// Use raw fetch so we can inspect the status before assuming it's an image.
const settings = getSettings();
if (!settings) throw new ApiError(0, 'Not configured.');
const token = await getToken();
const res = await fetch(
`${settings.baseUrl}/api/v1/images/${id}/preview?size=${size}`,
{ headers: { Authorization: `Bearer ${token}` } },
);
// 202 means the server has enqueued thumbnail generation; client should retry.
if (res.status === 202) {
const retryAfter = parseInt(res.headers.get('Retry-After') ?? '4', 10);
return { generating: true, retryAfter };
}
if (!res.ok) {
const text = await res.text().catch(() => '');
throw new ApiError(res.status, text || res.statusText);
}
const blob = await res.blob();
const url = URL.createObjectURL(blob);
blobCache.set(key, { url, refs: 1 });
return { url, key };
}
export async function getFullBlob(id) {
const key = `full:${id}`;
const existing = blobCache.get(key);
if (existing) {
existing.refs += 1;
return { url: existing.url, key };
}
const res = await apiFetch(`/api/v1/images/${id}/full`);
// May return 202 with Retry-After; caller handles polling
if (res.status === 202) {
const retryAfter = parseInt(res.headers.get('Retry-After') ?? '2', 10);
return { pending: true, retryAfter };
}
const blob = await res.blob();
const url = URL.createObjectURL(blob);
blobCache.set(key, { url, refs: 1 });
return { url, key };
}
// ── Images ────────────────────────────────────────────────────────────────────
export async function listImages(params = {}) {
const qs = new URLSearchParams();
const allowed = [
'limit', 'offset', 'sort_by', 'sort_dir',
'rating_min', 'rating_max', 'film_id',
'from', 'to', 'search', 'tag',
];
for (const key of allowed) {
if (params[key] !== undefined && params[key] !== '' && params[key] !== null) {
qs.set(key, String(params[key]));
}
}
const path = `/api/v1/images${qs.toString() ? '?' + qs.toString() : ''}`;
return apiJson(path);
}
export async function getImage(id) {
return apiJson(`/api/v1/images/${id}`);
}
export async function refreshImage(id) {
return apiJson(`/api/v1/images/${id}/refresh`, { method: 'POST' });
}
export async function exportImage(id, { signal } = {}) {
// 1. Enqueue the export (POST returns 202 immediately).
await apiFetch(`/api/v1/images/${id}/export`, { method: 'POST', signal });
// 2. Poll GET /full until the JPEG is ready (up to 120 s).
const settings = getSettings();
const token = await getToken();
const deadline = Date.now() + 120_000;
while (Date.now() < deadline) {
if (signal?.aborted) throw new ApiError(0, 'Cancelled');
await new Promise(resolve => setTimeout(resolve, 2000));
if (signal?.aborted) throw new ApiError(0, 'Cancelled');
const res = await fetch(`${settings.baseUrl}/api/v1/images/${id}/full`, {
headers: { Authorization: `Bearer ${token}` },
signal,
});
if (res.ok) return res.blob();
if (res.status !== 202) {
const text = await res.text().catch(() => '');
throw new ApiError(res.status, text || res.statusText);
}
// 202 → still generating, loop again
}
throw new ApiError(504, 'Export timed out after 120 s');
}
// ── Modules ───────────────────────────────────────────────────────────────────
export async function listModules(imageId) {
return apiJson(`/api/v1/images/${imageId}/modules`);
}
export async function getModule(imageId, op) {
return apiJson(`/api/v1/images/${imageId}/modules/${op}`);
}
/**
* Patch a module and optionally request a preview render.
* Returns { preview: blobUrl } when previewSize is set and the server responds
* with image/jpeg, or { data: json } for plain JSON responses.
*
* The PATCH with preview can take up to 30 seconds.
*/
export async function patchModule(imageId, op, body, previewSize = null) {
const settings = getSettings();
if (!settings) throw new ApiError(0, 'Not configured.');
const token = await getToken();
let path = `/api/v1/images/${imageId}/modules/${op}`;
if (previewSize) path += `?preview=${previewSize}`;
const url = `${settings.baseUrl}${path}`;
const res = await fetch(url, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
Accept: 'application/json, image/jpeg',
},
body: JSON.stringify(body),
// 35s timeout implemented via AbortController below
});
if (!res.ok) {
const text = await res.text().catch(() => '');
throw new ApiError(res.status, text || res.statusText);
}
const contentType = res.headers.get('Content-Type') ?? '';
if (contentType.includes('image/jpeg') || contentType.includes('image/')) {
const blob = await res.blob();
const url = URL.createObjectURL(blob);
return { previewUrl: url };
}
const data = await res.json();
return { data };
}
// ── Tags & Films ──────────────────────────────────────────────────────────────
export async function listTags() {
return apiJson('/api/v1/tags');
}
export async function listFilms() {
return apiJson('/api/v1/films');
}
// ── Health ────────────────────────────────────────────────────────────────────
export async function checkHealth(baseUrl) {
const url = `${baseUrl}/health`;
const res = await fetch(url, { method: 'GET' });
if (!res.ok) throw new ApiError(res.status, `Health check failed: ${res.statusText}`);
return res.json();
}
/**
* Test the full connection: health check + token fetch.
* Returns { ok: true } or throws ApiError.
*/
export async function testConnection(settings) {
await checkHealth(settings.baseUrl);
await fetchToken(settings);
return { ok: true };
}

View File

@@ -0,0 +1,235 @@
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { listFilms, ApiError } from '../api.js';
const SORT_OPTIONS = [
{ value: 'datetime_taken:desc', label: 'Newest first' },
{ value: 'datetime_taken:asc', label: 'Oldest first' },
{ value: 'filename:asc', label: 'Filename A→Z' },
{ value: 'filename:desc', label: 'Filename Z→A' },
{ value: 'rating:desc', label: 'Top rated' },
];
const STAR_OPTIONS = [
{ value: '', label: 'Any rating' },
{ value: '1', label: '★ and up' },
{ value: '2', label: '★★ and up' },
{ value: '3', label: '★★★ and up' },
{ value: '4', label: '★★★★ and up' },
{ value: '5', label: '★★★★★ only' },
];
export default function FilterBar({ filters, onChange }) {
const [films, setFilms] = useState([]);
const [filmsError, setFilmsError] = useState(null);
const [expanded, setExpanded] = useState(false);
const searchRef = useRef(null);
const searchTimer = useRef(null);
useEffect(() => {
listFilms()
.then(data => setFilms(Array.isArray(data) ? data : (data.items ?? [])))
.catch(err => {
if (err instanceof ApiError && err.status === 0) return; // not configured yet
setFilmsError('Could not load film rolls');
});
}, []);
const handleSearchChange = useCallback((e) => {
const value = e.target.value;
// Debounce search by 400ms
clearTimeout(searchTimer.current);
searchTimer.current = setTimeout(() => {
onChange({ ...filters, search: value, offset: 0 });
}, 400);
}, [filters, onChange]);
const handleSortChange = useCallback((e) => {
const [sort_by, sort_dir] = e.target.value.split(':');
onChange({ ...filters, sort_by, sort_dir, offset: 0 });
}, [filters, onChange]);
const handleRatingChange = useCallback((e) => {
onChange({ ...filters, rating_min: e.target.value, offset: 0 });
}, [filters, onChange]);
const handleFilmChange = useCallback((e) => {
onChange({ ...filters, film_id: e.target.value, offset: 0 });
}, [filters, onChange]);
const currentSort = `${filters.sort_by ?? 'datetime_taken'}:${filters.sort_dir ?? 'desc'}`;
const activeFilterCount = [
filters.search,
filters.rating_min,
filters.film_id,
].filter(Boolean).length;
return (
<div style={styles.root}>
{/* Search row */}
<div style={styles.searchRow}>
<div style={styles.searchWrap}>
<span style={styles.searchIcon}>⌕</span>
<input
ref={searchRef}
type="search"
className="form-input"
placeholder="Search images…"
defaultValue={filters.search ?? ''}
onChange={handleSearchChange}
style={{ paddingLeft: 36, height: 40 }}
aria-label="Search images"
/>
</div>
<button
className="btn btn-ghost"
style={{
height: 40,
padding: '0 12px',
fontSize: '0.8125rem',
gap: 6,
color: expanded || activeFilterCount > 0 ? 'var(--color-accent)' : undefined,
position: 'relative',
}}
onClick={() => setExpanded(x => !x)}
aria-expanded={expanded}
aria-label="Toggle filters"
>
<span>⚙</span>
<span>Filters</span>
{activeFilterCount > 0 && (
<span style={styles.badge}>{activeFilterCount}</span>
)}
</button>
</div>
{/* Expanded filters */}
{expanded && (
<div style={styles.filterRow}>
<div style={{ flex: 1, minWidth: 140 }}>
<label className="form-label" style={{ marginBottom: 4, display: 'block', fontSize: '0.75rem' }}>
Sort by
</label>
<select
className="form-select"
style={{ height: 38, fontSize: '0.875rem' }}
value={currentSort}
onChange={handleSortChange}
aria-label="Sort order"
>
{SORT_OPTIONS.map(o => (
<option key={o.value} value={o.value}>{o.label}</option>
))}
</select>
</div>
<div style={{ flex: 1, minWidth: 130 }}>
<label className="form-label" style={{ marginBottom: 4, display: 'block', fontSize: '0.75rem' }}>
Min rating
</label>
<select
className="form-select"
style={{ height: 38, fontSize: '0.875rem' }}
value={filters.rating_min ?? ''}
onChange={handleRatingChange}
aria-label="Minimum star rating"
>
{STAR_OPTIONS.map(o => (
<option key={o.value} value={o.value}>{o.label}</option>
))}
</select>
</div>
{films.length > 0 && (
<div style={{ flex: 1, minWidth: 150 }}>
<label className="form-label" style={{ marginBottom: 4, display: 'block', fontSize: '0.75rem' }}>
Film roll
</label>
<select
className="form-select"
style={{ height: 38, fontSize: '0.875rem' }}
value={filters.film_id ?? ''}
onChange={handleFilmChange}
aria-label="Film roll"
>
<option value="">All rolls</option>
{films.map(f => (
<option key={f.id} value={f.id}>
{f.folder ?? f.id}
</option>
))}
</select>
</div>
)}
{activeFilterCount > 0 && (
<div style={{ alignSelf: 'flex-end', paddingBottom: 0 }}>
<button
className="btn btn-ghost"
style={{ height: 38, padding: '0 12px', fontSize: '0.8125rem', color: 'var(--color-danger)' }}
onClick={() => onChange({ ...filters, search: '', rating_min: '', film_id: '', offset: 0 })}
>
Clear
</button>
</div>
)}
</div>
)}
</div>
);
}
const styles = {
root: {
background: 'var(--color-surface)',
borderBottom: '1px solid var(--color-border)',
padding: '10px 12px',
display: 'flex',
flexDirection: 'column',
gap: 10,
position: 'sticky',
top: 'var(--header-height)',
zIndex: 'var(--z-filter)',
},
searchRow: {
display: 'flex',
gap: 8,
alignItems: 'center',
},
searchWrap: {
flex: 1,
position: 'relative',
},
searchIcon: {
position: 'absolute',
left: 10,
top: '50%',
transform: 'translateY(-50%)',
color: 'var(--color-text-muted)',
fontSize: '1.1rem',
pointerEvents: 'none',
lineHeight: 1,
},
filterRow: {
display: 'flex',
flexWrap: 'wrap',
gap: 10,
alignItems: 'flex-end',
paddingTop: 4,
},
badge: {
position: 'absolute',
top: 6,
right: 4,
minWidth: 16,
height: 16,
borderRadius: '9999px',
background: 'var(--color-accent)',
color: '#0d0d0d',
fontSize: '0.625rem',
fontWeight: 700,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
padding: '0 3px',
},
};

View File

@@ -0,0 +1,246 @@
import React, { useEffect, useRef, useState } from 'react';
import { getPreviewBlob, releaseBlobUrl } from '../api.js';
const COLOR_LABEL_COLORS = {
red: '#e05252',
yellow: '#f4c842',
green: '#52c06e',
blue: '#5299e0',
purple: '#a052c0',
};
function StarRating({ rating }) {
if (!rating || rating < 1) return null;
return (
<div style={{
color: 'var(--color-accent)',
fontSize: '0.6875rem',
lineHeight: 1,
textShadow: '0 1px 3px rgba(0,0,0,0.8)',
}}>
{'★'.repeat(Math.min(5, rating))}
</div>
);
}
function ColorDots({ labels }) {
if (!labels || labels.length === 0) return null;
return (
<div style={{ display: 'flex', gap: 3 }}>
{labels.map(label => (
<span
key={label}
style={{
width: 8,
height: 8,
borderRadius: '50%',
background: COLOR_LABEL_COLORS[label] ?? '#aaa',
display: 'inline-block',
}}
title={label}
/>
))}
</div>
);
}
export default function ImageCard({ image, onClick }) {
const [blobUrl, setBlobUrl] = useState(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(false);
const [generating, setGenerating] = useState(false);
const blobKeyRef = useRef(null);
const isMounted = useRef(true);
const retriesRef = useRef(0);
const retryTimerRef = useRef(null);
useEffect(() => {
isMounted.current = true;
retriesRef.current = 0;
setLoading(true);
setError(false);
setGenerating(false);
function loadPreview() {
getPreviewBlob(image.id, 'thumb')
.then((result) => {
if (!isMounted.current) {
if (result.key) releaseBlobUrl(result.key);
return;
}
if (result.generating) {
setLoading(false);
setGenerating(true);
if (retriesRef.current < 15) {
retriesRef.current += 1;
retryTimerRef.current = setTimeout(loadPreview, (result.retryAfter ?? 4) * 1000);
} else {
setGenerating(false);
setError(true);
}
return;
}
if (blobKeyRef.current) releaseBlobUrl(blobKeyRef.current);
blobKeyRef.current = result.key;
setBlobUrl(result.url);
setLoading(false);
setGenerating(false);
})
.catch(() => {
if (isMounted.current) {
setLoading(false);
setGenerating(false);
setError(true);
}
});
}
loadPreview();
return () => {
isMounted.current = false;
if (retryTimerRef.current) clearTimeout(retryTimerRef.current);
if (blobKeyRef.current) {
releaseBlobUrl(blobKeyRef.current);
blobKeyRef.current = null;
}
};
}, [image.id]);
// Compute aspect ratio for the thumbnail placeholder
const aspect = image.width && image.height
? Math.min(1.5, Math.max(0.6, image.height / image.width))
: 1;
return (
<button
onClick={onClick}
style={{
display: 'block',
background: 'var(--color-surface)',
border: '1px solid var(--color-border)',
borderRadius: 'var(--radius-md)',
overflow: 'hidden',
cursor: 'pointer',
textAlign: 'left',
transition: 'transform var(--transition-fast), box-shadow var(--transition-fast)',
width: '100%',
padding: 0,
WebkitTapHighlightColor: 'transparent',
}}
aria-label={`Open ${image.filename}`}
type="button"
>
{/* Thumbnail container — padding-bottom trick for aspect ratio */}
<div style={{
position: 'relative',
width: '100%',
paddingBottom: `${aspect * 100}%`,
background: 'var(--color-surface-2)',
}}>
{(loading || generating) && (
<div style={{
position: 'absolute', inset: 0,
display: 'flex', flexDirection: 'column',
alignItems: 'center', justifyContent: 'center',
gap: 4,
}}>
<span className="spinner" />
{generating && (
<span style={{ fontSize: '0.625rem', color: 'var(--color-text-muted)', opacity: 0.7 }}>
Generating…
</span>
)}
</div>
)}
{error && !loading && !generating && (
<div style={{
position: 'absolute', inset: 0,
display: 'flex', alignItems: 'center', justifyContent: 'center',
}}>
<span style={{ fontSize: '1.5rem', opacity: 0.4 }}>⊘</span>
</div>
)}
{blobUrl && !error && (
<img
src={blobUrl}
alt={image.filename}
style={{
position: 'absolute',
inset: 0,
width: '100%',
height: '100%',
objectFit: 'cover',
}}
/>
)}
{/* Bottom overlay: stars + color dots */}
<div style={{
position: 'absolute',
bottom: 4,
left: 4,
right: 4,
display: 'flex',
alignItems: 'flex-end',
justifyContent: 'space-between',
gap: 4,
pointerEvents: 'none',
}}>
<StarRating rating={image.rating} />
<ColorDots labels={image.color_labels} />
</div>
{/* RAW badge */}
{image.is_raw && (
<div style={{
position: 'absolute',
top: 4,
right: 4,
background: 'rgba(0,0,0,0.65)',
color: 'var(--color-accent)',
fontSize: '0.625rem',
fontWeight: 700,
padding: '1px 5px',
borderRadius: 3,
letterSpacing: '0.04em',
}}>
RAW
</div>
)}
</div>
{/* Caption */}
<div style={{ padding: '6px 8px', display: 'flex', flexDirection: 'column', gap: 2 }}>
<span style={{
fontSize: '0.75rem',
color: 'var(--color-text)',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
display: 'block',
}}>
{image.filename}
</span>
{image.datetime_taken && (
<span style={{ fontSize: '0.6875rem', color: 'var(--color-text-muted)' }}>
{formatDate(image.datetime_taken)}
</span>
)}
</div>
</button>
);
}
function formatDate(dt) {
if (!dt) return '';
try {
return new Date(dt).toLocaleDateString(undefined, {
year: 'numeric',
month: 'short',
day: 'numeric',
});
} catch {
return dt;
}
}

View File

@@ -0,0 +1,71 @@
import React, { useEffect, useState } from 'react';
import { listModules, ApiError } from '../api.js';
import ModulePanel from './ModulePanel.jsx';
export default function ModuleList({ imageId, onPreviewUpdate }) {
const [modules, setModules] = useState(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
useEffect(() => {
if (!imageId) return;
setLoading(true);
setError(null);
setModules(null);
listModules(imageId)
.then(data => {
// API may return an array or { items: [] }
const list = Array.isArray(data) ? data : (data.items ?? data.modules ?? []);
setModules(list);
setLoading(false);
})
.catch(err => {
const msg = err instanceof ApiError ? err.message : String(err);
setError(msg);
setLoading(false);
});
}, [imageId]);
if (loading) {
return (
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 32 }}>
<span className="spinner spinner-lg" />
</div>
);
}
if (error) {
return (
<div className="error-banner" style={{ margin: '0 0 8px' }}>
<span>⚠</span>
<span>Modules: {error}</span>
</div>
);
}
if (!modules || modules.length === 0) {
return (
<div className="empty-state" style={{ padding: '24px' }}>
<span className="empty-state-icon">◻</span>
<p className="text-sm text-muted">No development modules found</p>
</div>
);
}
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
<h3 style={{ fontSize: '0.875rem', color: 'var(--color-text-muted)', marginBottom: 4 }}>
Development modules ({modules.length})
</h3>
{modules.map((mod, idx) => (
<ModulePanel
key={`${mod.operation}-${mod.history_num ?? idx}`}
imageId={imageId}
module={mod}
onPreviewUpdate={onPreviewUpdate}
/>
))}
</div>
);
}

View File

@@ -0,0 +1,401 @@
import React, { useCallback, useEffect, useReducer, useRef, useState } from 'react';
import { patchModule, ApiError } from '../api.js';
import { useToast } from './Toast.jsx';
// ── Known param schemas ───────────────────────────────────────────────────────
// Provides type and range hints for well-known module parameters.
// Fallback: treat everything as a generic number / string.
const MODULE_PARAMS = {
exposure: {
exposure: { type: 'float', min: -18, max: 18, step: 0.01, label: 'Exposure (EV)' },
black: { type: 'float', min: -1, max: 1, step: 0.001, label: 'Black point' },
mode: { type: 'int', label: 'Mode' },
},
temperature: {
red: { type: 'float', min: 0.1, max: 8, step: 0.01, label: 'Red' },
green: { type: 'float', min: 0.1, max: 8, step: 0.01, label: 'Green' },
blue: { type: 'float', min: 0.1, max: 8, step: 0.01, label: 'Blue' },
g2: { type: 'float', min: 0.1, max: 8, step: 0.01, label: 'Green2' },
},
filmicrgb: {
grey_point_source: { type: 'float', min: 0.1, max: 36, step: 0.01, label: 'Grey point src (%)' },
black_point_source: { type: 'float', min: -16, max: -0.1, step: 0.01, label: 'Black point src (EV)' },
white_point_source: { type: 'float', min: 0.1, max: 16, step: 0.01, label: 'White point src (EV)' },
contrast: { type: 'float', min: 0, max: 5, step: 0.01, label: 'Contrast' },
saturation: { type: 'float', min: 0, max: 4, step: 0.01, label: 'Saturation' },
balance: { type: 'float', min: -50, max: 50, step: 0.1, label: 'Shadows↔Highlights' },
output_power: { type: 'float', min: 0, max: 10, step: 0.01, label: 'Output power' },
latitude: { type: 'float', min: 0.01, max: 99, step: 0.1, label: 'Latitude (%)' },
noise_level: { type: 'float', min: 0, max: 0.5, step: 0.001, label: 'Noise level' },
},
highlights: {
mode: { type: 'int', label: 'Mode' },
strength: { type: 'float', min: 0, max: 1, step: 0.01, label: 'Strength' },
clip: { type: 'float', min: 0, max: 1, step: 0.001, label: 'Clip' },
noise_level: { type: 'float', min: 0, max: 1, step: 0.001, label: 'Noise level' },
iterations: { type: 'int', label: 'Iterations' },
},
channelmixerrgb: {
temperature: { type: 'float', min: 1667, max: 25000, step: 10, label: 'Temperature (K)' },
illuminant: { type: 'int', label: 'Illuminant' },
adaptation: { type: 'int', label: 'Adaptation' },
},
flip: {
orientation: { type: 'int', label: 'Orientation' },
},
gamma: {
gamma: { type: 'float', min: 0, max: 1, step: 0.001, label: 'Gamma' },
linear: { type: 'float', min: 0, max: 1, step: 0.001, label: 'Linear' },
},
rawprepare: {
left: { type: 'int', label: 'Left crop (px)' },
top: { type: 'int', label: 'Top crop (px)' },
right: { type: 'int', label: 'Right crop (px)' },
bottom: { type: 'int', label: 'Bottom crop (px)' },
raw_white_point: { type: 'int', label: 'Raw white point' },
},
demosaic: {
demosaicing_method: { type: 'int', label: 'Method' },
green_eq: { type: 'int', label: 'Green equalization' },
median_thrs: { type: 'float', min: 0, max: 1, step: 0.001, label: 'Median threshold' },
},
};
// ── Helpers ───────────────────────────────────────────────────────────────────
function inferType(key, value, opName) {
const schema = MODULE_PARAMS[opName]?.[key];
if (schema) return schema;
const numVal = Number(value);
if (typeof value === 'boolean') return { type: 'bool' };
if (!isNaN(numVal)) {
const isFloat = String(value).includes('.') || (Number.isFinite(numVal) && !Number.isInteger(numVal));
return isFloat
? { type: 'float', min: -100, max: 100, step: 0.01, label: key }
: { type: 'int', label: key };
}
return { type: 'string', label: key };
}
// ── ParamField ────────────────────────────────────────────────────────────────
function ParamField({ paramKey, value, schema, onChange }) {
const label = schema?.label ?? paramKey;
if (schema?.type === 'bool' || typeof value === 'boolean') {
return (
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 36 }}>
<span style={{ fontSize: '0.875rem', color: 'var(--color-text-muted)' }}>{label}</span>
<label className="toggle">
<input
type="checkbox"
checked={!!value}
onChange={e => onChange(paramKey, e.target.checked)}
/>
<span className="toggle-track" />
</label>
</div>
);
}
if (schema?.type === 'float' && schema.min !== undefined && schema.max !== undefined) {
const numVal = Number(value);
const displayVal = Number.isNaN(numVal) ? 0 : numVal;
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline' }}>
<span style={{ fontSize: '0.8125rem', color: 'var(--color-text-muted)' }}>{label}</span>
<span style={{ fontSize: '0.8125rem', fontFamily: 'var(--font-mono)', color: 'var(--color-text)' }}>
{displayVal.toFixed(schema.step < 0.01 ? 4 : schema.step < 0.1 ? 3 : 2)}
</span>
</div>
<input
type="range"
className="param-slider"
min={schema.min}
max={schema.max}
step={schema.step ?? 0.01}
value={displayVal}
onChange={e => onChange(paramKey, parseFloat(e.target.value))}
/>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ fontSize: '0.625rem', color: 'var(--color-text-faint)' }}>{schema.min}</span>
<span style={{ fontSize: '0.625rem', color: 'var(--color-text-faint)' }}>{schema.max}</span>
</div>
</div>
);
}
// int / string — text input
return (
<div style={{ display: 'flex', alignItems: 'center', gap: 12, minHeight: 36 }}>
<span style={{ fontSize: '0.8125rem', color: 'var(--color-text-muted)', flex: 1 }}>{label}</span>
<input
type="number"
className="form-input"
style={{ width: 90, height: 32, padding: '0 8px', fontSize: '0.8125rem' }}
value={value ?? ''}
step={schema?.type === 'float' ? (schema.step ?? 0.01) : 1}
onChange={e => {
const raw = e.target.value;
const num = Number(raw);
onChange(paramKey, Number.isNaN(num) ? raw : num);
}}
/>
</div>
);
}
// ── ModulePanel ───────────────────────────────────────────────────────────────
function paramsReducer(state, action) {
switch (action.type) {
case 'RESET':
return { ...action.params };
case 'SET':
return { ...state, [action.key]: action.value };
default:
return state;
}
}
export default function ModulePanel({ imageId, module: mod, onPreviewUpdate }) {
const { toast } = useToast();
const [open, setOpen] = useState(false);
const [enabled, setEnabled] = useState(mod.enabled ?? true);
const [params, dispatchParams] = useReducer(paramsReducer, mod.params ?? {});
const [dirty, setDirty] = useState(false);
const [applying, setApplying] = useState(false);
const [renderState, setRenderState] = useState(null); // null | 'rendering' | 'done' | 'error'
const [previewUrl, setPreviewUrl] = useState(null);
const previewUrlRef = useRef(null);
// Sync when module prop changes (e.g., after gallery refresh)
useEffect(() => {
setEnabled(mod.enabled ?? true);
dispatchParams({ type: 'RESET', params: mod.params ?? {} });
setDirty(false);
}, [mod]);
// Cleanup preview blob URL on unmount
useEffect(() => {
return () => {
if (previewUrlRef.current) URL.revokeObjectURL(previewUrlRef.current);
};
}, []);
function handleParamChange(key, value) {
dispatchParams({ type: 'SET', key, value });
setDirty(true);
}
function handleEnabledChange(newEnabled) {
setEnabled(newEnabled);
setDirty(true);
}
async function handleApply() {
setApplying(true);
setRenderState('rendering');
const body = {
enabled,
params,
};
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 35_000);
try {
const result = await patchModule(imageId, mod.operation, body, 'medium');
clearTimeout(timeoutId);
if (result.previewUrl) {
// Revoke previous preview blob
if (previewUrlRef.current) URL.revokeObjectURL(previewUrlRef.current);
previewUrlRef.current = result.previewUrl;
setPreviewUrl(result.previewUrl);
onPreviewUpdate?.(result.previewUrl);
setRenderState('done');
toast(`${mod.operation}: applied`, 'success');
} else {
setRenderState('done');
toast(`${mod.operation}: applied (no preview)`, 'success');
}
setDirty(false);
} catch (err) {
clearTimeout(timeoutId);
if (err.name === 'AbortError') {
setRenderState('error');
toast(`${mod.operation}: render timed out`, 'error');
} else {
const msg = err instanceof ApiError ? err.message : String(err);
setRenderState('error');
toast(`${mod.operation}: ${msg}`, 'error');
}
} finally {
setApplying(false);
}
}
const paramEntries = Object.entries(params);
return (
<div style={{
border: '1px solid var(--color-border)',
borderRadius: 'var(--radius-md)',
overflow: 'hidden',
background: 'var(--color-surface-2)',
}}>
{/* Header row — always visible */}
<button
type="button"
onClick={() => setOpen(o => !o)}
style={{
width: '100%',
display: 'flex',
alignItems: 'center',
gap: 10,
padding: '10px 14px',
background: 'none',
border: 'none',
cursor: 'pointer',
textAlign: 'left',
minHeight: 44,
}}
aria-expanded={open}
>
{/* Enabled toggle — stop propagation so clicking it doesn't toggle open */}
<span
role="none"
onClick={e => {
e.stopPropagation();
handleEnabledChange(!enabled);
}}
style={{ flexShrink: 0, display: 'flex', alignItems: 'center' }}
title={enabled ? 'Disable module' : 'Enable module'}
>
<label className="toggle" style={{ pointerEvents: 'none' }}>
<input type="checkbox" readOnly checked={enabled} tabIndex={-1} />
<span className="toggle-track" />
</label>
</span>
<span style={{ flex: 1, fontSize: '0.9rem', fontWeight: 500, color: enabled ? 'var(--color-text)' : 'var(--color-text-muted)' }}>
{mod.multi_name ? `${mod.operation} · ${mod.multi_name}` : mod.operation}
</span>
{dirty && (
<span style={{
fontSize: '0.6875rem',
color: 'var(--color-accent)',
background: 'var(--color-accent-dim)',
padding: '1px 7px',
borderRadius: '9999px',
fontWeight: 600,
}}>
modified
</span>
)}
<span style={{
fontSize: '0.75rem',
color: 'var(--color-text-faint)',
transform: open ? 'rotate(180deg)' : 'rotate(0)',
transition: 'transform var(--transition-fast)',
display: 'inline-block',
}}>
▾
</span>
</button>
{/* Expanded body */}
{open && (
<div style={{ padding: '4px 14px 14px', display: 'flex', flexDirection: 'column', gap: 14 }}>
<div style={{ height: 1, background: 'var(--color-border)' }} />
{/* Module info row */}
<div style={{ display: 'flex', gap: 16, flexWrap: 'wrap' }}>
{mod.history_num !== undefined && (
<span style={{ fontSize: '0.75rem', color: 'var(--color-text-faint)' }}>
history #{mod.history_num}
</span>
)}
{mod.module_version !== undefined && (
<span style={{ fontSize: '0.75rem', color: 'var(--color-text-faint)' }}>
v{mod.module_version}
</span>
)}
</div>
{/* Param fields */}
{paramEntries.length > 0 ? (
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
{paramEntries.map(([key, value]) => {
const schema = inferType(key, value, mod.operation);
return (
<ParamField
key={key}
paramKey={key}
value={value}
schema={schema}
onChange={handleParamChange}
/>
);
})}
</div>
) : (
<p style={{ fontSize: '0.8125rem', color: 'var(--color-text-faint)' }}>
No editable parameters
</p>
)}
{/* Apply button + render state */}
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
<button
type="button"
className="btn btn-primary"
style={{ width: '100%', height: 40, fontSize: '0.875rem' }}
onClick={handleApply}
disabled={applying || (!dirty && renderState !== null)}
>
{applying ? (
<>
<span className="spinner" style={{ width: 16, height: 16 }} />
Rendering…
</>
) : 'Apply'}
</button>
{renderState === 'rendering' && (
<p style={{ fontSize: '0.75rem', color: 'var(--color-text-muted)', textAlign: 'center' }}>
Waiting for preview render (up to 30 s)…
</p>
)}
{renderState === 'error' && (
<p style={{ fontSize: '0.75rem', color: 'var(--color-danger)', textAlign: 'center' }}>
Render failed or timed out.
</p>
)}
</div>
{/* Inline preview after apply */}
{previewUrl && renderState === 'done' && (
<div style={{ borderRadius: 'var(--radius-md)', overflow: 'hidden', border: '1px solid var(--color-border)' }}>
<img
src={previewUrl}
alt="Module preview"
style={{ width: '100%', height: 'auto', display: 'block' }}
/>
<p style={{ fontSize: '0.6875rem', color: 'var(--color-text-faint)', textAlign: 'center', padding: '4px 0' }}>
Preview after {mod.operation}
</p>
</div>
)}
</div>
)}
</div>
);
}

View File

@@ -0,0 +1,133 @@
import React, { createContext, useCallback, useContext, useReducer, useRef } from 'react';
// ── Context ───────────────────────────────────────────────────────────────────
const ToastContext = createContext(null);
let nextId = 0;
function reducer(state, action) {
switch (action.type) {
case 'ADD':
return [...state, action.toast];
case 'REMOVE':
return state.filter(t => t.id !== action.id);
default:
return state;
}
}
export function ToastProvider({ children }) {
const [toasts, dispatch] = useReducer(reducer, []);
const timers = useRef({});
const dismiss = useCallback((id) => {
clearTimeout(timers.current[id]);
delete timers.current[id];
dispatch({ type: 'REMOVE', id });
}, []);
const toast = useCallback((message, type = 'info', duration = 4000) => {
const id = ++nextId;
dispatch({ type: 'ADD', toast: { id, message, type } });
if (duration > 0) {
timers.current[id] = setTimeout(() => dismiss(id), duration);
}
return id;
}, [dismiss]);
return (
<ToastContext.Provider value={{ toast, dismiss }}>
{children}
<ToastContainer toasts={toasts} dismiss={dismiss} />
</ToastContext.Provider>
);
}
export function useToast() {
const ctx = useContext(ToastContext);
if (!ctx) throw new Error('useToast must be used within ToastProvider');
return ctx;
}
// ── Rendering ─────────────────────────────────────────────────────────────────
const ICONS = {
info: 'ℹ',
success: '✓',
warning: '⚠',
error: '✕',
};
function ToastContainer({ toasts, dismiss }) {
if (toasts.length === 0) return null;
return (
<div style={{
position: 'fixed',
bottom: 'max(80px, calc(env(safe-area-inset-bottom, 0px) + 80px))',
left: '50%',
transform: 'translateX(-50%)',
zIndex: 'var(--z-toast)',
display: 'flex',
flexDirection: 'column',
gap: '8px',
alignItems: 'center',
width: 'min(calc(100vw - 32px), 400px)',
pointerEvents: 'none',
}}>
{toasts.map(t => (
<ToastItem key={t.id} toast={t} dismiss={dismiss} />
))}
</div>
);
}
function ToastItem({ toast, dismiss }) {
const colorMap = {
info: 'var(--color-text)',
success: 'var(--color-success)',
warning: 'var(--color-warning)',
error: 'var(--color-danger)',
};
return (
<div
role="alert"
aria-live="polite"
style={{
display: 'flex',
alignItems: 'flex-start',
gap: '10px',
padding: '12px 16px',
background: 'var(--color-surface-2)',
border: '1px solid var(--color-border)',
borderRadius: 'var(--radius-lg)',
boxShadow: 'var(--shadow-lg)',
fontSize: '0.9rem',
pointerEvents: 'all',
animation: 'toastIn 200ms ease',
maxWidth: '100%',
cursor: 'pointer',
userSelect: 'none',
}}
onClick={() => dismiss(toast.id)}
>
<span style={{ color: colorMap[toast.type] ?? colorMap.info, fontSize: '1rem', flexShrink: 0, lineHeight: 1.5 }}>
{ICONS[toast.type] ?? ICONS.info}
</span>
<span style={{ flex: 1, color: 'var(--color-text)', lineHeight: 1.5, wordBreak: 'break-word' }}>
{toast.message}
</span>
</div>
);
}
// Keyframe injected once
const style = document.createElement('style');
style.textContent = `
@keyframes toastIn {
from { opacity: 0; transform: translateY(12px) scale(0.96); }
to { opacity: 1; transform: translateY(0) scale(1); }
}
`;
document.head.appendChild(style);

View File

@@ -0,0 +1,456 @@
/* ── CSS Custom Properties ───────────────────────────────────────────────── */
:root {
--color-bg: #0d0d0d;
--color-surface: #1a1a1a;
--color-surface-2: #242424;
--color-surface-3: #2e2e2e;
--color-border: #333333;
--color-accent: #f4a22d;
--color-accent-dim: rgba(244, 162, 45, 0.15);
--color-accent-hover: #f8b84a;
--color-text: #e0e0e0;
--color-text-muted: #888888;
--color-text-faint: #555555;
--color-danger: #e05252;
--color-success: #52c06e;
--color-warning: #f4a22d;
--radius-sm: 4px;
--radius-md: 8px;
--radius-lg: 12px;
--radius-xl: 16px;
--radius-full: 9999px;
--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
--shadow-md: 0 4px 12px rgba(0, 0, 0, 0.6);
--shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.7);
--font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
--font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
--tap-target: 44px;
--header-height: 56px;
--filter-height: 56px;
--transition-fast: 150ms ease;
--transition-med: 250ms ease;
--transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
--z-header: 100;
--z-filter: 90;
--z-backdrop: 200;
--z-sheet: 210;
--z-toast: 300;
}
/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
height: 100%;
font-size: 16px;
-webkit-text-size-adjust: 100%;
scroll-behavior: smooth;
}
body {
height: 100%;
background-color: var(--color-bg);
color: var(--color-text);
font-family: var(--font-sans);
line-height: 1.5;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
overscroll-behavior: none;
}
#root {
height: 100%;
display: flex;
flex-direction: column;
}
img {
display: block;
max-width: 100%;
}
button {
font-family: inherit;
cursor: pointer;
border: none;
background: none;
color: inherit;
}
input, select, textarea {
font-family: inherit;
font-size: inherit;
color: inherit;
}
a {
color: var(--color-accent);
text-decoration: none;
}
/* ── Typography ─────────────────────────────────────────────────────────── */
h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.25rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1rem; font-weight: 600; }
h4 { font-size: 0.875rem; font-weight: 600; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--color-text-muted); }
.text-accent { color: var(--color-accent); }
.text-mono { font-family: var(--font-mono); }
/* ── Utility classes ────────────────────────────────────────────────────── */
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
/* ── Shared component styles ─────────────────────────────────────────────── */
/* Buttons */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 6px;
min-height: var(--tap-target);
padding: 0 18px;
border-radius: var(--radius-md);
font-size: 0.9375rem;
font-weight: 500;
transition: background-color var(--transition-fast), opacity var(--transition-fast);
user-select: none;
white-space: nowrap;
cursor: pointer;
border: none;
}
.btn:disabled {
opacity: 0.45;
cursor: not-allowed;
}
.btn-primary {
background-color: var(--color-accent);
color: #0d0d0d;
font-weight: 700;
}
.btn-primary:hover:not(:disabled) {
background-color: var(--color-accent-hover);
}
.btn-secondary {
background-color: var(--color-surface-3);
color: var(--color-text);
border: 1px solid var(--color-border);
}
.btn-secondary:hover:not(:disabled) {
background-color: var(--color-surface-2);
}
.btn-ghost {
background-color: transparent;
color: var(--color-text-muted);
}
.btn-ghost:hover:not(:disabled) {
background-color: var(--color-surface-2);
color: var(--color-text);
}
.btn-danger {
background-color: var(--color-danger);
color: white;
}
.btn-icon {
padding: 0;
width: var(--tap-target);
height: var(--tap-target);
border-radius: var(--radius-md);
}
/* Form controls */
.form-group {
display: flex;
flex-direction: column;
gap: 6px;
}
.form-label {
font-size: 0.875rem;
font-weight: 500;
color: var(--color-text-muted);
}
.form-input {
height: var(--tap-target);
padding: 0 12px;
background-color: var(--color-surface-2);
border: 1px solid var(--color-border);
border-radius: var(--radius-md);
color: var(--color-text);
font-size: 0.9375rem;
transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
width: 100%;
}
.form-input:focus {
outline: none;
border-color: var(--color-accent);
box-shadow: 0 0 0 3px var(--color-accent-dim);
}
.form-input::placeholder {
color: var(--color-text-faint);
}
.form-select {
height: var(--tap-target);
padding: 0 32px 0 12px;
background-color: var(--color-surface-2);
border: 1px solid var(--color-border);
border-radius: var(--radius-md);
color: var(--color-text);
font-size: 0.9375rem;
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 12px center;
cursor: pointer;
width: 100%;
}
.form-select:focus {
outline: none;
border-color: var(--color-accent);
box-shadow: 0 0 0 3px var(--color-accent-dim);
}
/* Card */
.card {
background-color: var(--color-surface);
border: 1px solid var(--color-border);
border-radius: var(--radius-lg);
overflow: hidden;
}
/* Spinner */
.spinner {
display: inline-block;
width: 20px;
height: 20px;
border: 2px solid var(--color-border);
border-top-color: var(--color-accent);
border-radius: 50%;
animation: spin 0.7s linear infinite;
flex-shrink: 0;
}
.spinner-lg {
width: 36px;
height: 36px;
border-width: 3px;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* Divider */
.divider {
height: 1px;
background-color: var(--color-border);
margin: 0;
}
/* Tag pill */
.tag-pill {
display: inline-flex;
align-items: center;
padding: 2px 8px;
border-radius: var(--radius-full);
font-size: 0.75rem;
background-color: var(--color-surface-3);
color: var(--color-text-muted);
border: 1px solid var(--color-border);
}
/* Star display */
.stars {
display: inline-flex;
gap: 2px;
color: var(--color-accent);
font-size: 0.875rem;
}
/* Empty state */
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 12px;
padding: 48px 24px;
color: var(--color-text-muted);
text-align: center;
}
.empty-state-icon {
font-size: 3rem;
opacity: 0.4;
}
/* Error state */
.error-banner {
display: flex;
align-items: flex-start;
gap: 10px;
padding: 12px 16px;
background-color: rgba(224, 82, 82, 0.12);
border: 1px solid rgba(224, 82, 82, 0.3);
border-radius: var(--radius-md);
color: #f08080;
font-size: 0.875rem;
}
/* Toggle switch */
.toggle {
position: relative;
display: inline-block;
width: 44px;
height: 24px;
flex-shrink: 0;
}
.toggle input {
opacity: 0;
width: 0;
height: 0;
position: absolute;
}
.toggle-track {
position: absolute;
inset: 0;
background-color: var(--color-surface-3);
border-radius: var(--radius-full);
border: 1px solid var(--color-border);
transition: background-color var(--transition-fast), border-color var(--transition-fast);
cursor: pointer;
}
.toggle input:checked + .toggle-track {
background-color: var(--color-accent);
border-color: var(--color-accent);
}
.toggle-track::after {
content: '';
position: absolute;
top: 2px;
left: 2px;
width: 18px;
height: 18px;
background-color: white;
border-radius: 50%;
transition: transform var(--transition-fast);
}
.toggle input:checked + .toggle-track::after {
transform: translateX(20px);
}
/* Slider */
.param-slider {
-webkit-appearance: none;
appearance: none;
width: 100%;
height: 4px;
border-radius: 2px;
background: var(--color-surface-3);
outline: none;
cursor: pointer;
}
.param-slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 18px;
height: 18px;
border-radius: 50%;
background: var(--color-accent);
cursor: pointer;
border: 2px solid #0d0d0d;
box-shadow: 0 0 0 2px rgba(244, 162, 45, 0.3);
}
.param-slider::-moz-range-thumb {
width: 18px;
height: 18px;
border-radius: 50%;
background: var(--color-accent);
cursor: pointer;
border: 2px solid #0d0d0d;
}
/* Scrollbar */
::-webkit-scrollbar {
width: 4px;
height: 4px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: var(--color-surface-3);
border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--color-border);
}
/* Safe area insets for notched phones */
.safe-bottom {
padding-bottom: env(safe-area-inset-bottom, 0px);
}

View File

@@ -0,0 +1,11 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import './index.css';
import App from './App.jsx';
const root = createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);

View File

@@ -0,0 +1,368 @@
import React, {
useCallback,
useEffect,
useReducer,
useRef,
useState,
} from 'react';
import { listImages, ApiError } from '../api.js';
import { useApp } from '../App.jsx';
import { useToast } from '../components/Toast.jsx';
import FilterBar from '../components/FilterBar.jsx';
import ImageCard from '../components/ImageCard.jsx';
import ImageDetail from './ImageDetail.jsx';
const PAGE_SIZE = 50;
// ── State machine for the image list ─────────────────────────────────────────
const initialListState = {
items: [],
total: 0,
loading: false,
loadingMore: false,
error: null,
offset: 0,
hasMore: true,
};
function listReducer(state, action) {
switch (action.type) {
case 'LOAD_START':
return { ...state, loading: true, error: null };
case 'LOAD_MORE_START':
return { ...state, loadingMore: true, error: null };
case 'LOAD_SUCCESS':
return {
...state,
loading: false,
loadingMore: false,
items: action.replace ? action.items : [...state.items, ...action.items],
total: action.total,
offset: action.offset + action.items.length,
hasMore: action.offset + action.items.length < action.total,
error: null,
};
case 'LOAD_ERROR':
return { ...state, loading: false, loadingMore: false, error: action.error };
case 'RESET':
return { ...initialListState };
default:
return state;
}
}
const defaultFilters = {
sort_by: 'datetime_taken',
sort_dir: 'desc',
search: '',
rating_min: '',
film_id: '',
};
// ── Pull-to-refresh ───────────────────────────────────────────────────────────
const PTR_THRESHOLD = 70; // px to trigger refresh
// ── Gallery ───────────────────────────────────────────────────────────────────
export default function Gallery() {
const { goSettings } = useApp();
const { toast } = useToast();
const [listState, dispatch] = useReducer(listReducer, initialListState);
const [filters, setFilters] = useState(defaultFilters);
const [selectedImage, setSelectedImage] = useState(null);
// Pull-to-refresh state
const [ptrY, setPtrY] = useState(0);
const [ptrActive, setPtrActive] = useState(false);
const touchStartY = useRef(null);
const scrollRef = useRef(null);
// Sentinel element for IntersectionObserver (infinite scroll)
const sentinelRef = useRef(null);
const observerRef = useRef(null);
// Current active fetch abort controller
const fetchControllerRef = useRef(null);
// ── Data loading ────────────────────────────────────────────────────────────
const loadPage = useCallback(async (currentOffset, replace) => {
// Cancel any previous fetch
if (fetchControllerRef.current) fetchControllerRef.current.abort();
const controller = new AbortController();
fetchControllerRef.current = controller;
dispatch({ type: replace ? 'LOAD_START' : 'LOAD_MORE_START' });
try {
const params = {
limit: PAGE_SIZE,
offset: currentOffset,
sort_by: filters.sort_by,
sort_dir: filters.sort_dir,
};
if (filters.search) params.search = filters.search;
if (filters.rating_min) params.rating_min = filters.rating_min;
if (filters.film_id) params.film_id = filters.film_id;
const data = await listImages(params);
if (controller.signal.aborted) return;
const items = Array.isArray(data) ? data : (data.items ?? []);
const total = data.total ?? items.length;
dispatch({
type: 'LOAD_SUCCESS',
items,
total,
offset: currentOffset,
replace,
});
} catch (err) {
if (controller.signal.aborted) return;
const msg = err instanceof ApiError ? err.message : String(err);
dispatch({ type: 'LOAD_ERROR', error: msg });
toast(msg, 'error');
}
}, [filters, toast]);
// Initial load and when filters change
useEffect(() => {
dispatch({ type: 'RESET' });
loadPage(0, true);
// Scroll to top
scrollRef.current?.scrollTo({ top: 0 });
}, [filters]); // eslint-disable-line react-hooks/exhaustive-deps
// Note: we intentionally omit loadPage from deps to avoid double-fires;
// filters change triggers reset + load, which is correct.
// ── IntersectionObserver for infinite scroll ────────────────────────────────
useEffect(() => {
observerRef.current?.disconnect();
observerRef.current = new IntersectionObserver(
(entries) => {
if (
entries[0].isIntersecting &&
!listState.loading &&
!listState.loadingMore &&
listState.hasMore
) {
loadPage(listState.offset, false);
}
},
{ rootMargin: '200px' }
);
if (sentinelRef.current) {
observerRef.current.observe(sentinelRef.current);
}
return () => observerRef.current?.disconnect();
}, [listState.loading, listState.loadingMore, listState.hasMore, listState.offset, loadPage]);
// ── Pull-to-refresh touch handlers ─────────────────────────────────────────
function handleTouchStart(e) {
if (scrollRef.current?.scrollTop === 0) {
touchStartY.current = e.touches[0].clientY;
}
}
function handleTouchMove(e) {
if (touchStartY.current === null) return;
const dy = e.touches[0].clientY - touchStartY.current;
if (dy > 0) {
setPtrY(Math.min(dy * 0.5, PTR_THRESHOLD + 20));
}
}
function handleTouchEnd() {
if (ptrY >= PTR_THRESHOLD) {
setPtrActive(true);
dispatch({ type: 'RESET' });
loadPage(0, true).finally(() => {
setPtrActive(false);
setPtrY(0);
});
} else {
setPtrY(0);
}
touchStartY.current = null;
}
// ── Filter handler ──────────────────────────────────────────────────────────
const handleFiltersChange = useCallback((newFilters) => {
setFilters(newFilters);
}, []);
// ── Render ──────────────────────────────────────────────────────────────────
const showEmpty = !listState.loading && !listState.error && listState.items.length === 0;
const showError = !!listState.error && listState.items.length === 0;
return (
<div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
{/* Fixed header */}
<header style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
padding: '0 12px',
height: 'var(--header-height)',
background: 'var(--color-surface)',
borderBottom: '1px solid var(--color-border)',
flexShrink: 0,
position: 'sticky',
top: 0,
zIndex: 'var(--z-header)',
}}>
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
<img src="/icon.svg" alt="" style={{ width: 28, height: 28, borderRadius: 6 }} />
<span style={{ fontWeight: 700, fontSize: '1rem', color: 'var(--color-accent)' }}>
darktable
</span>
{listState.total > 0 && (
<span style={{ fontSize: '0.8125rem', color: 'var(--color-text-muted)' }}>
{listState.total.toLocaleString()} images
</span>
)}
</div>
<button
type="button"
className="btn btn-ghost btn-icon"
onClick={goSettings}
aria-label="Settings"
title="Settings"
style={{ fontSize: '1.25rem' }}
>
⚙
</button>
</header>
{/* Filter bar */}
<FilterBar filters={filters} onChange={handleFiltersChange} />
{/* Scrollable gallery area */}
<div
ref={scrollRef}
style={{ flex: 1, overflowY: 'auto', overscrollBehavior: 'contain', position: 'relative' }}
onTouchStart={handleTouchStart}
onTouchMove={handleTouchMove}
onTouchEnd={handleTouchEnd}
>
{/* Pull-to-refresh indicator */}
{ptrY > 10 && (
<div style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
height: Math.min(ptrY, PTR_THRESHOLD + 20),
color: ptrY >= PTR_THRESHOLD ? 'var(--color-accent)' : 'var(--color-text-muted)',
fontSize: '0.875rem',
gap: 8,
transition: ptrActive ? 'height var(--transition-med)' : 'none',
}}>
{ptrActive
? <><span className="spinner" style={{ width: 16, height: 16 }} /> Refreshing…</>
: (ptrY >= PTR_THRESHOLD ? '↑ Release to refresh' : '↓ Pull to refresh')
}
</div>
)}
{/* Initial loading */}
{listState.loading && listState.items.length === 0 && (
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 64, gap: 12 }}>
<span className="spinner spinner-lg" />
</div>
)}
{/* Error (no items) */}
{showError && (
<div style={{ padding: '24px 16px' }}>
<div className="error-banner">
<span>⚠</span>
<div>
<p>{listState.error}</p>
<button
type="button"
className="btn btn-secondary"
style={{ marginTop: 10, height: 36, fontSize: '0.875rem' }}
onClick={() => loadPage(0, true)}
>
Retry
</button>
</div>
</div>
</div>
)}
{/* Empty state */}
{showEmpty && (
<div className="empty-state">
<span className="empty-state-icon">◻</span>
<p>No images found</p>
<p className="text-sm text-muted">Try adjusting your filters</p>
</div>
)}
{/* Image grid */}
{listState.items.length > 0 && (
<div style={{
display: 'grid',
gridTemplateColumns: 'repeat(2, 1fr)',
gap: 6,
padding: 6,
}}>
{listState.items.map(img => (
<ImageCard
key={img.id}
image={img}
onClick={() => setSelectedImage(img)}
/>
))}
</div>
)}
{/* Infinite scroll sentinel */}
<div
ref={sentinelRef}
style={{ height: 1 }}
aria-hidden="true"
/>
{/* Load-more spinner */}
{listState.loadingMore && (
<div style={{ display: 'flex', justifyContent: 'center', padding: '20px 0' }}>
<span className="spinner" />
</div>
)}
{/* End-of-list indicator */}
{!listState.hasMore && listState.items.length > 0 && (
<p style={{
textAlign: 'center',
padding: '16px 0',
fontSize: '0.8125rem',
color: 'var(--color-text-faint)',
}}>
All {listState.total.toLocaleString()} images loaded
</p>
)}
</div>
{/* Image detail bottom sheet */}
{selectedImage && (
<ImageDetail
image={selectedImage}
onClose={() => setSelectedImage(null)}
/>
)}
</div>
);
}

View File

@@ -0,0 +1,443 @@
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { getPreviewBlob, releaseBlobUrl, refreshImage, exportImage, ApiError } from '../api.js';
import { useToast } from '../components/Toast.jsx';
import ModuleList from '../components/ModuleList.jsx';
const PREVIEW_SIZES = ['thumb', 'small', 'medium', 'large', 'xlarge'];
// ── EXIF metadata rows ────────────────────────────────────────────────────────
function MetaRow({ label, value }) {
if (!value && value !== 0) return null;
return (
<div style={{ display: 'flex', gap: 8, padding: '5px 0' }}>
<span style={{ fontSize: '0.8125rem', color: 'var(--color-text-muted)', minWidth: 120, flexShrink: 0 }}>
{label}
</span>
<span style={{ fontSize: '0.8125rem', color: 'var(--color-text)', wordBreak: 'break-word' }}>
{String(value)}
</span>
</div>
);
}
// ── Preview area ──────────────────────────────────────────────────────────────
function PreviewImage({ imageId, size, onModulePreview, modulePreviewUrl }) {
const [blobUrl, setBlobUrl] = useState(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(false);
const blobKeyRef = useRef(null);
const isMounted = useRef(true);
useEffect(() => {
isMounted.current = true;
setLoading(true);
setError(false);
getPreviewBlob(imageId, size)
.then(({ url, key }) => {
if (!isMounted.current) { releaseBlobUrl(key); return; }
if (blobKeyRef.current) releaseBlobUrl(blobKeyRef.current);
blobKeyRef.current = key;
setBlobUrl(url);
setLoading(false);
})
.catch(() => {
if (isMounted.current) { setLoading(false); setError(true); }
});
return () => {
isMounted.current = false;
if (blobKeyRef.current) { releaseBlobUrl(blobKeyRef.current); blobKeyRef.current = null; }
};
}, [imageId, size]);
const displayUrl = modulePreviewUrl ?? blobUrl;
return (
<div style={{
width: '100%',
minHeight: 200,
background: '#111',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
position: 'relative',
}}>
{loading && !displayUrl && (
<span className="spinner spinner-lg" />
)}
{error && !displayUrl && (
<div style={{ textAlign: 'center', color: 'var(--color-text-muted)' }}>
<div style={{ fontSize: '2rem', marginBottom: 8 }}>⊘</div>
<p className="text-sm">Preview unavailable</p>
</div>
)}
{displayUrl && (
<img
src={displayUrl}
alt="Image preview"
style={{ maxWidth: '100%', maxHeight: '60vh', objectFit: 'contain', display: 'block' }}
/>
)}
{modulePreviewUrl && (
<div style={{
position: 'absolute',
top: 8, right: 8,
background: 'rgba(244, 162, 45, 0.9)',
color: '#000',
fontSize: '0.6875rem',
fontWeight: 700,
padding: '2px 8px',
borderRadius: '9999px',
}}>
MODULE PREVIEW
</div>
)}
</div>
);
}
// ── Main component ────────────────────────────────────────────────────────────
export default function ImageDetail({ image, onClose }) {
const { toast } = useToast();
const [previewSizeIdx, setPreviewSizeIdx] = useState(2); // 'medium'
const [tab, setTab] = useState('info'); // 'info' | 'modules'
const [actionBusy, setActionBusy] = useState(null); // 'refresh' | 'export' | null
const [modulePreviewUrl, setModulePreviewUrl] = useState(null);
const modulePreviewUrlRef = useRef(null);
// Animate in
const [visible, setVisible] = useState(false);
useEffect(() => {
const t = requestAnimationFrame(() => setVisible(true));
return () => cancelAnimationFrame(t);
}, []);
// Cleanup module preview blob
useEffect(() => {
return () => {
if (modulePreviewUrlRef.current) URL.revokeObjectURL(modulePreviewUrlRef.current);
};
}, []);
function cyclePreviewSize() {
setPreviewSizeIdx(i => (i + 1) % PREVIEW_SIZES.length);
setModulePreviewUrl(null); // clear module preview when switching size
}
function handleModulePreview(url) {
if (modulePreviewUrlRef.current) URL.revokeObjectURL(modulePreviewUrlRef.current);
modulePreviewUrlRef.current = url;
setModulePreviewUrl(url);
}
async function handleRefresh() {
setActionBusy('refresh');
try {
await refreshImage(image.id);
toast('Thumbnails regenerated', 'success');
} catch (err) {
toast(err instanceof ApiError ? err.message : String(err), 'error');
} finally {
setActionBusy(null);
}
}
const exportAbortRef = useRef(null);
async function handleExport() {
// Cancel any in-progress export if the button is clicked again.
exportAbortRef.current?.abort();
const controller = new AbortController();
exportAbortRef.current = controller;
setActionBusy('export');
try {
const blob = await exportImage(image.id, { signal: controller.signal });
const stem = image.filename?.replace(/\.[^.]+$/, '') ?? 'export';
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `${stem}.jpg`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
toast('Export downloaded', 'success');
} catch (e) {
if (e instanceof ApiError && e.message === 'Cancelled') return;
toast(e instanceof ApiError ? e.message : String(e), 'error');
} finally {
setActionBusy(null);
}
}
function handleBackdropClick(e) {
if (e.target === e.currentTarget) onClose();
}
const currentSize = PREVIEW_SIZES[previewSizeIdx];
const meta = image.metadata ?? {};
return (
<>
{/* Backdrop */}
<div
onClick={handleBackdropClick}
style={{
position: 'fixed',
inset: 0,
background: 'rgba(0,0,0,0.7)',
zIndex: 'var(--z-backdrop)',
transition: 'opacity var(--transition-slow)',
opacity: visible ? 1 : 0,
}}
aria-hidden="true"
/>
{/* Bottom sheet */}
<div
role="dialog"
aria-modal="true"
aria-label={image.filename}
style={{
position: 'fixed',
left: 0,
right: 0,
bottom: 0,
zIndex: 'var(--z-sheet)',
background: 'var(--color-surface)',
borderRadius: 'var(--radius-xl) var(--radius-xl) 0 0',
boxShadow: 'var(--shadow-lg)',
maxHeight: '92dvh',
display: 'flex',
flexDirection: 'column',
transform: visible ? 'translateY(0)' : 'translateY(100%)',
transition: 'transform var(--transition-slow)',
overflowY: 'hidden',
}}
>
{/* Drag handle */}
<div style={{ display: 'flex', justifyContent: 'center', padding: '12px 0 4px' }}>
<div style={{
width: 40, height: 4,
borderRadius: 2,
background: 'var(--color-border)',
}} />
</div>
{/* Sheet header */}
<div style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
padding: '4px 16px 12px',
borderBottom: '1px solid var(--color-border)',
gap: 12,
flexShrink: 0,
}}>
<div style={{ flex: 1, minWidth: 0 }}>
<h2 style={{
fontSize: '1rem',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
}}>
{image.filename}
</h2>
{image.path && (
<p style={{
fontSize: '0.75rem',
color: 'var(--color-text-muted)',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
marginTop: 2,
}}>
{image.path}
</p>
)}
</div>
<button
type="button"
className="btn btn-ghost btn-icon"
onClick={onClose}
aria-label="Close"
style={{ flexShrink: 0 }}
>
✕
</button>
</div>
{/* Scrollable content */}
<div style={{ flex: 1, overflowY: 'auto', overscrollBehavior: 'contain' }}>
{/* Preview image — tap to cycle sizes */}
<button
type="button"
onClick={cyclePreviewSize}
title={`Preview size: ${currentSize} (tap to cycle)`}
style={{
display: 'block',
width: '100%',
background: '#0a0a0a',
border: 'none',
cursor: 'pointer',
padding: 0,
position: 'relative',
}}
>
<PreviewImage
imageId={image.id}
size={currentSize}
modulePreviewUrl={modulePreviewUrl}
/>
<div style={{
position: 'absolute',
bottom: 8,
right: 8,
background: 'rgba(0,0,0,0.65)',
color: 'var(--color-text-muted)',
fontSize: '0.6875rem',
padding: '2px 8px',
borderRadius: '9999px',
pointerEvents: 'none',
}}>
{currentSize} · tap to cycle
</div>
</button>
{/* Action buttons */}
<div style={{ display: 'flex', gap: 10, padding: '12px 16px' }}>
<button
type="button"
className="btn btn-secondary"
style={{ flex: 1, height: 40, fontSize: '0.875rem' }}
onClick={handleRefresh}
disabled={actionBusy !== null}
>
{actionBusy === 'refresh'
? <><span className="spinner" style={{ width: 14, height: 14 }} /> Refreshing…</>
: '↺ Refresh'}
</button>
<button
type="button"
className="btn btn-secondary"
style={{ flex: 1, height: 40, fontSize: '0.875rem' }}
onClick={handleExport}
disabled={actionBusy !== null}
>
{actionBusy === 'export'
? <><span className="spinner" style={{ width: 14, height: 14 }} /> Exporting…</>
: '⬇ Export'}
</button>
</div>
{/* Tab switcher */}
<div style={{
display: 'flex',
borderBottom: '1px solid var(--color-border)',
padding: '0 16px',
gap: 4,
}}>
{['info', 'modules'].map(t => (
<button
key={t}
type="button"
onClick={() => setTab(t)}
style={{
background: 'none',
border: 'none',
borderBottom: `2px solid ${tab === t ? 'var(--color-accent)' : 'transparent'}`,
padding: '10px 16px',
fontSize: '0.9rem',
fontWeight: tab === t ? 600 : 400,
color: tab === t ? 'var(--color-accent)' : 'var(--color-text-muted)',
cursor: 'pointer',
transition: 'color var(--transition-fast), border-color var(--transition-fast)',
minHeight: 44,
}}
>
{t === 'info' ? 'Info' : 'Modules'}
</button>
))}
</div>
{/* Tab content */}
<div style={{ padding: '16px' }}>
{tab === 'info' && (
<InfoTab image={image} meta={meta} />
)}
{tab === 'modules' && (
<ModuleList
imageId={image.id}
onPreviewUpdate={handleModulePreview}
/>
)}
</div>
{/* Safe area bottom padding */}
<div style={{ height: 'max(16px, env(safe-area-inset-bottom, 16px))' }} />
</div>
</div>
</>
);
}
// ── Info tab ──────────────────────────────────────────────────────────────────
function InfoTab({ image, meta }) {
const stars = image.rating > 0 ? '★'.repeat(image.rating) : '—';
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
{/* Tags */}
{image.tags && image.tags.length > 0 && (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 6, paddingBottom: 12 }}>
{image.tags.map(tag => (
<span key={tag} className="tag-pill">{tag}</span>
))}
</div>
)}
<div style={{ height: 1, background: 'var(--color-border)', margin: '4px 0 8px' }} />
<MetaRow label="Rating" value={stars} />
<MetaRow label="Date taken" value={image.datetime_taken} />
<MetaRow label="Dimensions" value={image.width && image.height ? `${image.width} × ${image.height}` : null} />
<MetaRow label="Camera" value={[image.maker, image.model].filter(Boolean).join(' ')} />
<MetaRow label="Type" value={image.is_raw ? 'RAW' : 'JPEG/other'} />
<MetaRow label="Film roll" value={image.film_name ?? image.film_id} />
{/* Color labels */}
{image.color_labels && image.color_labels.length > 0 && (
<div style={{ display: 'flex', gap: 8, padding: '5px 0', alignItems: 'center' }}>
<span style={{ fontSize: '0.8125rem', color: 'var(--color-text-muted)', minWidth: 120 }}>
Color labels
</span>
<div style={{ display: 'flex', gap: 6 }}>
{image.color_labels.map(l => (
<span key={l} className="tag-pill" style={{ textTransform: 'capitalize' }}>{l}</span>
))}
</div>
</div>
)}
{/* Extra metadata fields from image.metadata object */}
{Object.keys(meta).length > 0 && (
<>
<div style={{ height: 1, background: 'var(--color-border)', margin: '8px 0 4px' }} />
<p style={{ fontSize: '0.75rem', color: 'var(--color-text-faint)', marginBottom: 4 }}>
Additional metadata
</p>
{Object.entries(meta).map(([key, value]) => (
<MetaRow key={key} label={key} value={value} />
))}
</>
)}
</div>
);
}

View File

@@ -0,0 +1,267 @@
import React, { useEffect, useReducer } from 'react';
import { useApp } from '../App.jsx';
import { getSettings, saveSettings, testConnection, ApiError } from '../api.js';
import { useToast } from '../components/Toast.jsx';
const initialForm = {
baseUrl: '',
clientId: '',
clientSecret: '',
};
function formReducer(state, action) {
switch (action.type) {
case 'SET_FIELD':
return { ...state, [action.field]: action.value };
case 'LOAD':
return { ...action.data };
default:
return state;
}
}
const statusIdle = { kind: 'idle' };
const statusTesting = { kind: 'testing' };
const statusOk = { kind: 'ok' };
const statusErr = (msg) => ({ kind: 'error', msg });
export default function Settings() {
const { goGallery } = useApp();
const { toast } = useToast();
const [form, dispatchForm] = useReducer(formReducer, initialForm);
const [status, setStatus] = React.useState(statusIdle);
useEffect(() => {
const s = getSettings();
if (s) {
dispatchForm({
type: 'LOAD',
data: {
baseUrl: s.baseUrl ?? '',
clientId: s.clientId ?? '',
clientSecret: s.clientSecret ?? '',
},
});
}
}, []);
function setField(field) {
return (e) => dispatchForm({ type: 'SET_FIELD', field, value: e.target.value });
}
async function handleTest(e) {
e.preventDefault();
setStatus(statusTesting);
const settings = {
baseUrl: form.baseUrl.replace(/\/$/, ''),
clientId: form.clientId.trim(),
clientSecret: form.clientSecret.trim(),
};
try {
await testConnection(settings);
setStatus(statusOk);
toast('Connection successful', 'success');
} catch (err) {
const msg = err instanceof ApiError ? err.message : String(err);
setStatus(statusErr(msg));
}
}
async function handleSave(e) {
e.preventDefault();
setStatus(statusTesting);
const settings = {
baseUrl: form.baseUrl.replace(/\/$/, ''),
clientId: form.clientId.trim(),
clientSecret: form.clientSecret.trim(),
};
try {
await testConnection(settings);
saveSettings(settings);
setStatus(statusOk);
toast('Settings saved', 'success');
goGallery();
} catch (err) {
const msg = err instanceof ApiError ? err.message : String(err);
setStatus(statusErr(msg));
}
}
const isBusy = status.kind === 'testing';
const isValid = form.baseUrl.trim() && form.clientId.trim() && form.clientSecret.trim();
return (
<div style={styles.root}>
{/* Header */}
<header style={styles.header}>
<div style={styles.logoRow}>
<img src="/icon.svg" alt="" style={styles.logo} />
<div>
<h1 style={{ fontSize: '1.25rem' }}>darktable Gallery</h1>
<p style={{ fontSize: '0.8125rem', color: 'var(--color-text-muted)', marginTop: 2 }}>
API connection settings
</p>
</div>
</div>
</header>
{/* Form */}
<main style={styles.main}>
<form onSubmit={handleSave} style={styles.form} noValidate>
<div className="card" style={{ padding: '24px', display: 'flex', flexDirection: 'column', gap: '20px' }}>
<div className="form-group">
<label className="form-label" htmlFor="baseUrl">
API Base URL
</label>
<input
id="baseUrl"
className="form-input"
type="url"
placeholder="http://localhost:8080"
value={form.baseUrl}
onChange={setField('baseUrl')}
autoCapitalize="none"
autoCorrect="off"
spellCheck={false}
/>
<p className="text-xs text-muted">
Leave empty to use same-origin (when served by the Lua server)
</p>
</div>
<div className="form-group">
<label className="form-label" htmlFor="clientId">
Client ID
</label>
<input
id="clientId"
className="form-input"
type="text"
placeholder="my-client"
value={form.clientId}
onChange={setField('clientId')}
autoCapitalize="none"
autoCorrect="off"
spellCheck={false}
/>
</div>
<div className="form-group">
<label className="form-label" htmlFor="clientSecret">
Client Secret
</label>
<input
id="clientSecret"
className="form-input"
type="password"
placeholder="••••••••"
value={form.clientSecret}
onChange={setField('clientSecret')}
/>
</div>
{status.kind === 'error' && (
<div className="error-banner">
<span>⚠</span>
<span>{status.msg}</span>
</div>
)}
{status.kind === 'ok' && (
<div style={{
display: 'flex', alignItems: 'center', gap: 8,
padding: '12px 16px',
background: 'rgba(82, 192, 110, 0.1)',
border: '1px solid rgba(82, 192, 110, 0.3)',
borderRadius: 'var(--radius-md)',
color: 'var(--color-success)',
fontSize: '0.875rem',
}}>
<span>✓</span>
<span>Connection verified</span>
</div>
)}
</div>
<div style={{ display: 'flex', gap: 12 }}>
<button
type="button"
className="btn btn-secondary"
style={{ flex: 1 }}
onClick={handleTest}
disabled={isBusy || !isValid}
>
{isBusy ? (
<>
<span className="spinner" style={{ width: 16, height: 16 }} />
Testing…
</>
) : 'Test Connection'}
</button>
<button
type="submit"
className="btn btn-primary"
style={{ flex: 1 }}
disabled={isBusy || !isValid}
>
{isBusy ? (
<>
<span className="spinner" style={{ width: 16, height: 16 }} />
Saving…
</>
) : 'Save & Connect'}
</button>
</div>
<p className="text-xs text-muted" style={{ textAlign: 'center', lineHeight: 1.6 }}>
Credentials are stored only in your browser's localStorage and
are never sent anywhere except the configured API URL.
</p>
</form>
</main>
</div>
);
}
const styles = {
root: {
flex: 1,
display: 'flex',
flexDirection: 'column',
minHeight: 0,
overflowY: 'auto',
},
header: {
padding: '24px 20px 0',
},
logoRow: {
display: 'flex',
alignItems: 'center',
gap: 14,
marginBottom: 32,
},
logo: {
width: 48,
height: 48,
borderRadius: 12,
},
main: {
flex: 1,
padding: '0 20px 32px',
maxWidth: 480,
width: '100%',
margin: '0 auto',
},
form: {
display: 'flex',
flexDirection: 'column',
gap: 20,
},
};

View File

@@ -0,0 +1,81 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { VitePWA } from 'vite-plugin-pwa';
export default defineConfig({
root: '.',
build: {
outDir: 'build',
emptyOutDir: true,
},
plugins: [
react(),
VitePWA({
registerType: 'autoUpdate',
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
runtimeCaching: [
{
urlPattern: /^.*\/api\/v1\/images\?/,
handler: 'NetworkFirst',
options: {
cacheName: 'api-images-list',
expiration: {
maxEntries: 50,
maxAgeSeconds: 60 * 5,
},
networkTimeoutSeconds: 10,
},
},
{
urlPattern: /^.*\/api\/v1\/images\/\d+\/preview/,
handler: 'CacheFirst',
options: {
cacheName: 'image-previews',
expiration: {
maxEntries: 500,
maxAgeSeconds: 60 * 60 * 24,
},
},
},
{
urlPattern: /^.*\/api\/v1\/(tags|films)/,
handler: 'NetworkFirst',
options: {
cacheName: 'api-metadata',
expiration: {
maxEntries: 20,
maxAgeSeconds: 60 * 10,
},
networkTimeoutSeconds: 10,
},
},
],
},
manifest: {
name: 'darktable Gallery',
short_name: 'darktable',
description: 'darktable REST API web interface',
theme_color: '#0d0d0d',
background_color: '#0d0d0d',
display: 'standalone',
orientation: 'any',
start_url: '/',
icons: [
{
src: 'icon.svg',
sizes: 'any',
type: 'image/svg+xml',
purpose: 'any maskable',
},
],
},
devOptions: {
enabled: false,
},
}),
],
server: {
port: 5173,
},
});

334
contrib/dbmaint.lua Normal file
View File

@@ -0,0 +1,334 @@
--[[
dbmaint.lua - perform database maintenance
Copyright (C) 2024 Bill Ferguson <wpferguson@gamil.com>.
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
]]
--[[
dbmaint - perform database maintenance
Perform database maintenance to clean up missing images and filmstrips.
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
None
USAGE
* start dbmaint from script_manager
* scan for missing film rolls or missing images
* look at the results and choose to delete or not
BUGS, COMMENTS, SUGGESTIONS
Bill Ferguson <wpferguson@gamil.com>
CHANGES
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local log = require "lib/dtutils.log"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- C O N S T A N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
local MODULE <const> = "dbmaint"
local DEFAULT_LOG_LEVEL <const> = log.error
local PS <const> = dt.configuration.running_os == "windows" and "\\" or "/"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- A P I C H E C K
-- - - - - - - - - - - - - - - - - - - - - - - -
du.check_min_api_version("7.0.0", MODULE) -- choose the minimum version that contains the features you need
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- I 1 8 N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- S C R I P T M A N A G E R I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local script_data = {}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
script_data.metadata = {
name = _("db maintenance"),
purpose = _("perform database maintenance"),
author = "Bill Ferguson <wpferguson@gamil.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/dbmaint/"
}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- L O G L E V E L
-- - - - - - - - - - - - - - - - - - - - - - - -
log.log_level(DEFAULT_LOG_LEVEL)
-- - - - - - - - - - - - - - - - - - - - - - - -
-- N A M E S P A C E
-- - - - - - - - - - - - - - - - - - - - - - - -
local dbmaint = {}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- G L O B A L V A R I A B L E S
-- - - - - - - - - - - - - - - - - - - - - - - -
dbmaint.main_widget = nil
-- - - - - - - - - - - - - - - - - - - - - - - -
-- A L I A S E S
-- - - - - - - - - - - - - - - - - - - - - - - -
local namespace = dbmaint
-- - - - - - - - - - - - - - - - - - - - - - - -
-- F U N C T I O N S
-- - - - - - - - - - - - - - - - - - - - - - - -
-------------------
-- helper functions
-------------------
local function set_log_level(level)
local old_log_level = log.log_level()
log.log_level(level)
return old_log_level
end
local function restore_log_level(level)
log.log_level(level)
end
local function scan_film_rolls()
local missing_films = {}
for _, filmroll in ipairs(dt.films) do
if not df.check_if_file_exists(filmroll.path) then
table.insert(missing_films, filmroll)
end
end
return missing_films
end
local function scan_images(film)
local old_log_level = set_log_level(DEFAULT_LOG_LEVEL)
local missing_images = {}
if film then
for i = 1, #film do
local image = film[i]
log.msg(log.debug, "checking " .. image.filename)
if not df.check_if_file_exists(image.path .. PS .. image.filename) then
log.msg(log.info, image.filename .. " not found")
table.insert(missing_images, image)
end
end
end
restore_log_level(old_log_level)
return missing_images
end
local function remove_missing_film_rolls(list)
for _, filmroll in ipairs(list) do
filmroll:delete(true)
end
end
-- force the lighttable to reload
local function refresh_lighttable(film)
local rules = dt.gui.libs.collect.filter()
dt.gui.libs.collect.filter(rules)
end
local function remove_missing_images(list)
local film = list[1].film
for _, image in ipairs(list) do
image:delete()
end
refresh_lighttable(film)
end
local function install_module()
if not namespace.module_installed then
dt.register_lib(
MODULE, -- Module name
_("DB maintenance"), -- Visible name
true, -- expandable
true, -- resetable
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER", 0}}, -- containers
namespace.main_widget,
nil,-- view_enter
nil -- view_leave
)
namespace.module_installed = true
end
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- U S E R I N T E R F A C E
-- - - - - - - - - - - - - - - - - - - - - - - -
dbmaint.list_widget = dt.new_widget("text_view"){
editable = false,
reset_callback = function(this)
this.text = ""
end
}
dbmaint.chooser = dt.new_widget("combobox"){
label = _("scan for"),
selected = 1,
_("film rolls"), _("images"),
reset_callback = function(this)
this.selected = 1
end
}
dbmaint.scan_button = dt.new_widget("button"){
label = _("scan"),
tooltip = _("click to scan for missing film rolls/files"),
clicked_callback = function(this)
local found = nil
local found_text = ""
local old_log_level = set_log_level(DEFAULT_LOG_LEVEL)
log.msg(log.debug, "Button clicked")
if dbmaint.chooser.selected == 1 then -- film rolls
found = scan_film_rolls()
if #found > 0 then
for _, film in ipairs(found) do
local dir_name = du.split(film.path, PS)
found_text = found_text .. dir_name[#dir_name] .. "\n"
end
end
else
log.msg(log.debug, "checking path " .. dt.collection[1].path .. " for missing files")
found = scan_images(dt.collection[1].film)
if #found > 0 then
for _, image in ipairs(found) do
found_text = found_text .. image.filename .. "\n"
end
end
end
if #found > 0 then
log.msg(log.debug, "found " .. #found .. " missing items")
dbmaint.list_widget.text = found_text
dbmaint.found = found
dbmaint.remove_button.sensitive = true
else
log.msg(log.debug, "no missing items found")
end
restore_log_level(old_log_level)
end,
reset_callback = function(this)
dbmaint.found = nil
end
}
dbmaint.remove_button = dt.new_widget("button"){
label = _("remove"),
tooltip = _("remove missing film rolls/images"),
sensitive = false,
clicked_callback = function(this)
if dbmaint.chooser.selected == 1 then -- film rolls
remove_missing_film_rolls(dbmaint.found)
else
remove_missing_images(dbmaint.found)
end
dbmaint.found = nil
dbmaint.list_widget.text = ""
this.sensitive = false
end,
reset_callback = function(this)
this.sensitive = false
end
}
dbmaint.main_widget = dt.new_widget("box"){
orientation = "vertical",
dt.new_widget("section_label"){label = _("missing items")},
dbmaint.list_widget,
dt.new_widget("label"){label = ""},
dbmaint.chooser,
dt.new_widget("label"){label = ""},
dbmaint.scan_button,
dbmaint.remove_button
}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- D A R K T A B L E I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - -
local function destroy()
dt.gui.libs[MODULE].visible = false
if namespace.event_registered then
dt.destroy_event(MODULE, "view-changed")
end
return
end
local function restart()
dt.gui.libs[MODULE].visible = true
return
end
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = restart
-- - - - - - - - - - - - - - - - - - - - - - - -
-- E V E N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
if dt.gui.current_view().id == "lighttable" then
install_module()
else
if not namespace.event_registered then
dt.register_event(MODULE, "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
namespace.event_registered = true
end
end
return script_data

1175
contrib/enfuseAdvanced.lua Normal file

File diff suppressed because it is too large Load Diff

204
contrib/exportLUT.lua Normal file
View File

@@ -0,0 +1,204 @@
--[[
This file is part of darktable,
copyright (c) 2020 Noah Clarke
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/>.
]]
--[[
Add the following line to .config/darktable/luarc to enable this lightable module:
require "contrib/exportLut"
Given a haldCLUT identity file this script generates haldCLUTS from all the user's
styles and exports them to a location of their choosing.
Warning: during export if a naming collision occurs the older file is automatically
overwritten silently.
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require("lib/dtutils.file")
local ds = require("lib/dtutils.system")
du.check_min_api_version("7.0.0", "exportLUT")
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("export LUT"),
purpose = _("export a style as a LUT"),
author = "Noah Clarke",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/exportLUT"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
du.check_min_api_version("5.0.0", "exportLUT")
local eL = {}
eL.module_installed = false
eL.event_registered = false
eL.widgets = {}
-- Thanks Kevin Ertel for this bit
local os_path_seperator = '/'
if dt.configuration.running_os == 'windows' then os_path_seperator = '\\' end
local mkdir_command = 'mkdir -p '
if dt.configuration.running_os == 'windows' then mkdir_command = 'mkdir ' end
local file_chooser_button = dt.new_widget("file_chooser_button"){
title = _("choose the identity file"),
value = "",
is_directory = false
}
local export_chooser_button = dt.new_widget("file_chooser_button"){
title = _("choose the export location"),
value = "",
is_directory = true
}
local identity_label = dt.new_widget("label"){
label = _("choose the identity haldclut file")
}
local output_label = dt.new_widget("label"){
label = _("choose the output location")
}
local warning_label = dt.new_widget("label"){
label = _("WARNING: files may be silently overwritten")
}
local function end_job(job)
job.valid = false
end
local function output_path(style_name, job)
local output_location = export_chooser_button.value .. os_path_seperator .. style_name .. ".png"
output_location = string.gsub(output_location, "|", os_path_seperator)
local output_dir = string.reverse(output_location)
output_dir = string.gsub(output_dir, ".-" .. os_path_seperator, os_path_seperator, 1)
output_dir = string.reverse(output_dir)
if(output_dir ~= "") then
df.mkdir(df.sanitize_filename(output_dir))
end
return output_location
end
local function export_luts()
local identity = dt.database.import(file_chooser_button.value)
if(type(identity) ~= "userdata") then
dt.print(_("invalid identity lut file"))
else
local job = dt.gui.create_job(_('exporting styles as haldCLUTs'), true, end_job)
local size = 1
for style_num, style in ipairs(dt.styles) do
size = size + 1
end
local count = 0
for style_num, style in ipairs(dt.styles) do
identity:reset()
dt.styles.apply(style, identity)
local io_lut = dt.new_format("png")
io_lut.bpp = 8
io_lut:write_image(identity, output_path(style.name, job))
count = count + 1
job.percent = count / size
dt.print(string.format(_("exported: %s"), output_path(style.name, job)))
end
dt.print(_("done exporting haldCLUTs"))
job.valid = false
identity:reset()
end
end
local function install_module()
if not eL.module_installed then
dt.register_lib(
"export haldclut",
_("export haldclut"),
true,
false,
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}},
dt.new_widget("box")
{
orientation = "vertical",
table.unpack(eL.widgets),
},
nil,
nil
)
eL.module_installed = true
end
end
local function destroy()
dt.gui.libs["export haldclut"].visible = false
end
local function restart()
dt.gui.libs["export haldclut"].visible = true
end
local export_button = dt.new_widget("button"){
label = _("export"),
clicked_callback = export_luts
}
table.insert(eL.widgets, identity_label)
table.insert(eL.widgets, file_chooser_button)
table.insert(eL.widgets, output_label)
table.insert(eL.widgets, export_chooser_button)
table.insert(eL.widgets, warning_label)
table.insert(eL.widgets, export_button)
if dt.gui.current_view().id == "lighttable" then
install_module()
else
if not eL.event_registered then
dt.register_event(
"exportLUT", "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
eL.event_registered = true
end
end
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = restart
return script_data

515
contrib/ext_editor.lua Normal file
View File

@@ -0,0 +1,515 @@
--[[
ext_editor.lua - edit images with external editors
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/>.
]]
--[[
ext_editor.lua - edit images with external editors
This script provides helpers to edit image files with programs external to darktable. It adds:
- a new target storage "collection". Image exported will be reimported to collection for further edit with external programs
- a new module "external editors", visible in lightable and darkroom, to select a program from a list
- of up to 9 external editors and run it on a selected image (adjust this limit by changing MAX_EDITORS)
- a set of lua preferences in order to configure name and path of up to 9 external editors
- a set of lua shortcuts in order to quick launch the external editors
USAGE
* require this script from main lua file
-- setup --
* in "preferences/lua options" configure name and path/command of external programs
* note that if a program name is left empty, that and all following entries will be ignored
* in "preferences/shortcuts/lua" configure shortcuts for external programs (optional)
* whenever programs preferences are changed, in external editors GUI, press "update list"
-- use --
* in the export dialog choose "collection" and select the format and bit depth for the
exported image
* press "export"
* the exported image will be imported into collection and grouped with the original image
* in lighttable, select an image for editing with en external program
* (or in darkroom for the image being edited):
* in external editors GUI, select program and press "edit"
* edit the image with the external editor, overwite the file, quit the external program
* the selected image will be updated
or
* in external editors GUI, select program and press "edit a copy"
* edit the image with the external editor, overwite the file, quit the external program
* a copy of the selected image will be created and updated
or
* use the shortcut to edit the current image with the corresponding external editor
* overwite the file, quit the external program
* the image will be updated
* warning: mouseover on lighttable/filmstrip will prevail on current image
* this is the default DT behavior, not a bug of this script
CAVEATS
* MAC compatibility not tested
BUGS, COMMENTS, SUGGESTIONS
* send to Marco Carrarini, marco.carrarini@gmail.com
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
-- module name
local MODULE_NAME = "ext_editor"
du.check_min_api_version("7.0.0", MODULE_NAME)
-- translation
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("external editors"),
purpose = _("edit images with external editors"),
author = "Marco Carrarini, marco.carrarini@gmail.com",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/ext_editor"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- OS compatibility
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
-- namespace
local ee = {}
ee.module_installed = false
ee.event_registered = false
ee.widgets = {}
-- maximum number of external programs, can be increased to necessity
local MAX_EDITORS = 9
-- number of valid entries in the list of external programs
local n_entries
-- allowed file extensions for external editors
local allowed_file_types = {"JPG", "jpg", "JPEG", "jpeg", "TIF", "tif", "TIFF", "tiff", "EXR", "exr", "PNG", "png"}
-- last used editor initialization
if not dt.preferences.read(MODULE_NAME, "initialized", "bool") then
dt.preferences.write(MODULE_NAME, "lastchoice", "integer", 0)
dt.preferences.write(MODULE_NAME, "initialized", "bool", true)
end
local lastchoice = 0
-- update lists of program names and paths, as well as combobox ---------------
local function UpdateProgramList(combobox, button_edit, button_edit_copy, update_button_pressed)
-- initialize lists
program_names = {}
program_paths = {}
-- build lists from preferences
local name
local last = false
n_entries = 0
for i = 1, MAX_EDITORS do
name = dt.preferences.read(MODULE_NAME, "program_name_"..i, "string")
if (name == "" or name == nil) then last = true end
if last then
if combobox[n_entries + 1] then combobox[n_entries + 1] = nil end -- remove extra combobox entries
else
combobox[i] = i..": "..name
program_names[i] = name
program_paths[i] = df.sanitize_filename(dt.preferences.read(MODULE_NAME, "program_path_"..i, "string"))
n_entries = i
end
end
lastchoice = dt.preferences.read(MODULE_NAME, "lastchoice", "integer")
if lastchoice == 0 and n_entries > 0 then lastchoice = 1 end
if lastchoice > n_entries then lastchoice = n_entries end
dt.preferences.write(MODULE_NAME, "lastchoice", "integer", lastchoice)
-- widgets enabled if there is at least one program configured
combobox.selected = lastchoice
local active = n_entries > 0
combobox.sensitive = active
button_edit.sensitive = active
button_edit_copy.sensitive = active
if update_button_pressed then dt.print(string.format(_("%d editors configured"), n_entries)) end
end
-- callback for buttons "edit" and "edit a copy" ------------------------------
local function OpenWith(images, choice, copy)
-- check choice is valid, return if not
if choice > n_entries then
dt.print(_("not a valid choice"))
return
end
-- check if one image is selected, return if not
if #images ~= 1 then
dt.print(_("please select one image"))
return
end
local bin = program_paths[choice]
local friendly_name = program_names[choice]
if dt.configuration.running_os == "macos" then bin = "open -W -a "..bin end
-- image to be edited
local image
i, image = next(images)
local name = image.path..PS..image.filename
-- check if image format is allowed
local file_ext = df.get_filetype(image.filename)
local allowed = false
for i,v in pairs(allowed_file_types) do
if v == file_ext then
allowed = true
break
end
end
if not allowed then
dt.print(_("file type not allowed"))
return
end
-- save image tags, rating and color
local tags = {}
for i, tag in ipairs(dt.tags.get_tags(image)) do
if not (string.sub(tag.name, 1, 9) == "darktable") then table.insert(tags, tag) end
end
local rating = image.rating
local red = image.red
local blue = image.blue
local green = image.green
local yellow = image.yellow
local purple = image.purple
-- new image
local new_name = name
local new_image = image
if copy then
-- create unique filename
new_name = df.create_unique_filename(new_name)
-- physical copy, check result, return if error
local copy_success = df.file_copy(name, new_name)
if not copy_success then
dt.print(string.format(_("error copying file %s"), name))
return
end
end
-- launch the external editor, check result, return if error
local run_cmd = bin.." "..df.sanitize_filename(new_name)
dt.print(string.format(_("launching %s..."), friendly_name))
local result = dtsys.external_command(run_cmd)
if result ~= 0 then
dt.print(string.format(_("error launching %s"), friendly_name))
return
end
if copy then
-- import in database and group
new_image = dt.database.import(new_name)
new_image:group_with(image)
else
-- refresh the image view
-- note that only image:drop_cache() is not enough to refresh view in darkroom mode
-- therefore image must be deleted and reimported to force refresh
-- find the grouping status
local image_leader = image.group_leader
local group_members = image:get_group_members()
local new_leader
local index = nil
local found = false
-- membership status, three different cases
if image_leader == image then
if #group_members > 1 then
-- case 1: image is leader in a group with more members
while not found do
index, new_leader = next(group_members, index)
if new_leader ~= image_leader then found = true end
end
new_leader:make_group_leader()
image:delete()
if image.local_copy then image:drop_cache() end -- to fix fail to allocate cache error
new_image = dt.database.import(name)
new_image:group_with(new_leader)
new_image:make_group_leader()
else
-- case 2: image is the only member in group
image:delete()
if image.local_copy then image:drop_cache() end -- to fix fail to allocate cache error
new_image = dt.database.import(name)
new_image:group_with()
end
else
-- case 3: image is in a group but is not leader
image:delete()
if image.local_copy then image:drop_cache() end -- to fix fail to allocate cache error
new_image = dt.database.import(name)
new_image:group_with(image_leader)
end
end
-- restore image tags, rating and color
for i, tag in ipairs(tags) do dt.tags.attach(tag, new_image) end
new_image.rating = rating
new_image.red = red
new_image.blue = blue
new_image.green = green
new_image.yellow = yellow
new_image.purple = purple
-- select the new image
local selection = {}
table.insert(selection, new_image)
dt.gui.selection(selection)
-- refresh darkroom view
if dt.gui.current_view().id == "darkroom" then
dt.gui.views.darkroom.display_image(new_image)
end
end
-- callback function for shortcuts --------------------------------------------
local function program_shortcut(event, shortcut)
OpenWith(dt.gui.action_images, tonumber(string.sub(shortcut, -2)), false)
end
-- export images and reimport in collection -----------------------------------
local function export2collection(storage, image_table, extra_data)
local temp_name, new_name, new_image, move_success
for image, temp_name in pairs(image_table) do
-- images are first exported in temp folder then moved to collection folder
-- create unique filename
new_name = image.path..PS..df.get_filename(temp_name)
new_name = df.create_unique_filename(new_name)
-- move image to collection folder, check result, return if error
move_success = df.file_move(temp_name, new_name)
if not move_success then
dt.print(string.format(_("error moving file %s"), temp_name))
return
end
-- import in database and group
new_image = dt.database.import(new_name)
new_image:group_with(image.group_leader)
end
dt.print(_("finished exporting"))
end
-- install the module in the UI -----------------------------------------------
local function install_module(dr)
local views = {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 90}}
if dr then
views = {[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 90},
[dt.gui.views.darkroom] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER", 100}}
end
if not ee.module_installed then
-- register new module "external editors" in lighttable and darkroom ----
dt.register_lib(
MODULE_NAME,
_("external editors"),
true, -- expandable
false, -- resetable
views,
dt.new_widget("box") {
orientation = "vertical",
table.unpack(ee.widgets),
},
nil, -- view_enter
nil -- view_leave
)
ee.module_installed = true
end
end
local function destroy()
for i = 1, MAX_EDITORS do
dt.destroy_event(MODULE_NAME .. i, "shortcut")
end
dt.destroy_storage("exp2coll")
dt.gui.libs[MODULE_NAME].visible = false
end
local function restart()
for i = 1, MAX_EDITORS do
dt.register_event(MODULE_NAME .. i, "shortcut",
program_shortcut, string.format(_("edit with program %02d"), i))
end
dt.register_storage("exp2coll", _("collection"), nil, export2collection)
dt.gui.libs[MODULE_NAME].visible = true
end
local function show()
dt.gui.libs[MODULE_NAME].visible = true
end
-- combobox, with variable number of entries ----------------------------------
local combobox = dt.new_widget("combobox") {
label = _("choose program"),
tooltip = _("select the external editor from the list"),
changed_callback = function(self)
dt.preferences.write(MODULE_NAME, "lastchoice", "integer", self.selected)
end,
""
}
-- button edit ----------------------------------------------------------------
local button_edit = dt.new_widget("button") {
label = _("edit"),
tooltip = _("open the selected image in external editor"),
--sensitive = false,
clicked_callback = function()
OpenWith(dt.gui.action_images, combobox.selected, false)
end
}
-- button edit a copy ---------------------------------------------------------
local button_edit_copy = dt.new_widget("button") {
label = _("edit a copy"),
tooltip = _("create a copy of the selected image and open it in external editor"),
clicked_callback = function()
OpenWith(dt.gui.action_images, combobox.selected, true)
end
}
-- button update list ---------------------------------------------------------
local button_update_list = dt.new_widget("button") {
label = _("update list"),
tooltip = _("update list of programs if lua preferences are changed"),
clicked_callback = function()
UpdateProgramList(combobox, button_edit, button_edit_copy, true)
end
}
-- box for the buttons --------------------------------------------------------
-- it doesn't seem there is a way to make the buttons equal in size
local box1 = dt.new_widget("box") {
orientation = "horizontal",
button_edit,
button_edit_copy,
button_update_list
}
-- table with all the widgets --------------------------------------------------
table.insert(ee.widgets, combobox)
table.insert(ee.widgets, box1)
-- register new module, but only when in lighttable ----------------------------
local show_dr = dt.preferences.read(MODULE_NAME, "show_in_darkrooom", "bool")
if dt.gui.current_view().id == "lighttable" then
install_module(show_dr)
else
if not ee.event_registered then
dt.register_event(
MODULE_NAME, "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module(show_dr)
end
end
)
ee.event_registered = true
end
end
-- initialize list of programs and widgets ------------------------------------
UpdateProgramList(combobox, button_edit, button_edit_copy, false)
-- register new storage -------------------------------------------------------
dt.register_storage("exp2coll", _("collection"), nil, export2collection)
-- register the new preferences -----------------------------------------------
for i = MAX_EDITORS, 1, -1 do
dt.preferences.register(MODULE_NAME, "program_path_"..i, "file",
string.format(_("executable for external editor %d"), i),
_("select executable for external editor") , _("(none)"))
dt.preferences.register(MODULE_NAME, "program_name_"..i, "string",
string.format(_("name of external editor %d"), i),
_("friendly name of external editor"), "")
end
dt.preferences.register(MODULE_NAME, "show_in_darkrooom", "bool",
_("show external editors in darkroom"),
_("check to show external editors module also in darkroom (requires restart)"), false)
-- register the new shortcuts -------------------------------------------------
for i = 1, MAX_EDITORS do
dt.register_event(MODULE_NAME .. i, "shortcut",
program_shortcut, string.format(_("edit with program %02d"), i))
end
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = show
return script_data
-- end of script --------------------------------------------------------------
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
-- kate: hl Lua;

View File

@@ -0,0 +1,540 @@
--[[
Face recognition for darktable
Copyright (c) 2017 Sebastian Witt
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/>.
]]
--[[
face_recognition
Add a new storage option to send images to face_recognition.
Images are exported to darktable tmp dir first.
A directory with known faces must exist, the image name are the
tag names which will be used.
Multiple images for one face can exist, add a number to it, the
number will be removed from the tag, for example:
People|IknowYou1.jpg
People|IknowYou2.jpg
People|Another.jpg
People|Youtoo.jpg
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
* https://github.com/ageitgey/face_recognition
* https://github.com/darktable-org/lua-scripts/tree/master/lib
USAGE
* require this file from your main luarc config file.
This plugin will add a new storage option and calls face_recognition after export.
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
-- constants
local MODULE = "face_recognition"
local PS = dt.configuration.running_os == "windows" and '\\' or '/'
local OUTPUT = dt.configuration.tmp_dir .. PS .. "facerecognition.txt"
du.check_min_api_version("7.0.0", MODULE)
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("face recognition"),
purpose = _("use facial recognition to tag images"),
author = "Sebastian Witt",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/face_recognition"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- namespace
local fc = {}
fc.module_installed = false
fc.event_registered = false
local function build_image_table(images)
local image_table = {}
local file_extension = ""
local tmp_dir = dt.configuration.tmp_dir .. PS
local ff = fc.export_format.value
local cnt = 0
-- check for plugin-data and direct_edit and build image table accordingly
if string.match(ff, "JPEG") then
file_extension = ".jpg"
elseif string.match(ff, "PNG") then
file_extension = ".png"
elseif string.match(ff, "TIFF") then
file_extension = ".tif"
end
for _,img in ipairs(images) do
if img ~= nil then
image_table[tmp_dir .. df.get_basename(img.filename) .. file_extension] = img
cnt = cnt + 1
end
end
return image_table, cnt
end
local function stop_job(job)
job.valid = false
end
local function do_export(img_tbl, images)
local exporter = nil
local upsize = false
local ff = fc.export_format.value
local height = dt.preferences.read(MODULE, "max_height", "integer")
local width = dt.preferences.read(MODULE, "max_width", "integer")
-- get the export format parameters
if string.match(ff, "JPEG") then
exporter = dt.new_format("jpeg")
exporter.quality = 80
elseif string.match(ff, "PNG") then
exporter = dt.new_format("png")
exporter.bpp = 8
elseif string.match(ff, "TIFF") then
exporter = dt.new_format("tiff")
exporter.bpp = 8
end
exporter.max_height = height
exporter.max_width = width
-- export the images
local job = dt.gui.create_job(_("export images"), true, stop_job)
local exp_cnt = 0
local percent_step = 1.0 / images
job.percent = 0.0
for export,img in pairs(img_tbl) do
exp_cnt = exp_cnt + 1
dt.print(string.format(_("exporting image %i of %i images"), exp_cnt, images))
exporter:write_image(img, export, upsize)
job.percent = job.percent + percent_step
end
job.valid = false
-- return success, or not
return true
end
local function save_preferences()
dt.preferences.write(MODULE, "unknown_tag", "string", fc.unknown_tag.text)
dt.preferences.write(MODULE, "no_persons_found_tag", "string", fc.no_persons_found_tag.text)
dt.preferences.write(MODULE, "ignore_tags", "string", fc.ignore_tags.text)
dt.preferences.write(MODULE, "category_tags", "string", fc.category_tags.text)
dt.preferences.write(MODULE, "known_image_path", "directory", fc.known_image_path.value)
local val = fc.tolerance.value
val = string.gsub(tostring(val), ",", ".")
dt.preferences.write(MODULE, "tolerance", "float", tonumber(val))
dt.preferences.write(MODULE, "num_cores", "integer", fc.num_cores.value)
dt.preferences.write(MODULE, "export_format", "integer", fc.export_format.selected)
dt.preferences.write(MODULE, "max_width", "integer", tonumber(fc.width.text))
dt.preferences.write(MODULE, "max_height", "integer", tonumber(fc.height.text))
end
local function reset_preferences()
fc.unknown_tag.text = "unknown_person"
fc.no_persons_found_tag.text = "no_persons_found"
fc.ignore_tags.text = ""
fc.category_tags.text = ""
fc.known_image_path.value = dt.configuration.config_dir .. "/face_recognition"
fc.tolerance.value = 0.6
fc.num_cores.value = -1
fc.export_format.selected = 1
fc.width.text = 1000
fc.height.text = 1000
save_preferences()
end
-- Check if image has ignored tag attached
local function ignoreByTag (image, ignoreTags)
local tags = image:get_tags ()
local ignoreImage = false
-- For each image tag
for _,t in ipairs (tags) do
-- Check if it contains a ignore tag
for _,it in ipairs (ignoreTags) do
if string.find (t.name, it, 1, true) then
-- The image has ignored tag attached
ignoreImage = true
dt.print_log ("Face recognition: Ignored tag: " .. it .. " found in " .. image.id .. ":" .. t.name)
end
end
end
return ignoreImage
end
local function cleanup(img_list)
for _, img in ipairs(img_list) do
os.remove(img)
end
os.remove(OUTPUT)
end
local function face_recognition ()
local bin_path = df.check_if_bin_exists("face_recognition")
if not bin_path then
dt.print(_("face recognition not found"))
return
end
save_preferences()
-- Get preferences
local knownPath = dt.preferences.read(MODULE, "known_image_path", "directory")
local nrCores = dt.preferences.read(MODULE, "num_cores", "integer")
local ignoreTagString = dt.preferences.read(MODULE, "ignore_tags", "string")
local categoryTagString = dt.preferences.read(MODULE, "category_tags", "string")
local unknownTag = dt.preferences.read(MODULE, "unknown_tag", "string")
local nonpersonsfoundTag = dt.preferences.read(MODULE, "no_persons_found_tag", "string")
-- face_recognition uses -1 for all cores, we use 0 in preferences
if nrCores < 1 then
nrCores = -1
end
-- Split ignore tags (if any)
ignoreTags = {}
for tag in string.gmatch(ignoreTagString, '([^,]+)') do
table.insert (ignoreTags, tag)
dt.print_log ("Face recognition: Ignore tag: " .. tag)
end
-- list of exported images
local image_table, cnt = build_image_table(dt.gui.action_images)
if cnt > 0 then
local success = do_export(image_table, cnt)
if success then
-- do the face recognition
local img_list = {}
for v,_ in pairs(image_table) do
table.insert (img_list, v)
end
-- Get path of exported images
local path = df.get_path (img_list[1])
dt.print_log ("Face recognition: Path to known faces: " .. knownPath)
dt.print_log ("Face recognition: Path to unknown images: " .. path)
dt.print_log ("Face recognition: Tag used for unknown faces: " .. unknownTag)
dt.print_log ("Face recognition: Tag used if non person is found: " .. nonpersonsfoundTag)
os.setlocale("C")
local tolerance = dt.preferences.read(MODULE, "tolerance", "float")
local command = bin_path .. " --cpus " .. nrCores .. " --tolerance " .. tolerance .. " " .. knownPath .. " " .. path .. " > " .. OUTPUT
os.setlocale()
dt.print_log("Face recognition: Running command: " .. command)
dt.print(_("starting face recognition..."))
dtsys.external_command(command)
-- Open output file
local f = io.open(OUTPUT, "rb")
if not f then
dt.print(_("face recognition failed"))
else
dt.print(_("face recognition finished"))
f:close ()
end
-- Read output
dt.print(_("processing results..."))
local result = {}
local tags_list = {}
local tag_object = {}
for line in io.lines(OUTPUT) do
if not string.match(line, "^WARNING:") and line ~= "" and line ~= nil then
local file, tag = string.match (line, "(.*),(.*)$")
tag = string.gsub (tag, "%d*$", "")
dt.print_log ("File:"..file .." Tag:".. tag)
tag_object = {}
if result[file] == nil then
tag_object[tag] = true
result[file] = tag_object
else
tag_object = result[file]
tag_object[tag] = true
result[file] = tag_object
end
end
end
-- Attach tags
local result_index = 0
for file,tags in pairs(result) do
result_index = result_index +1
-- Find image in table
img = image_table[file]
if img == nil then
dt.print_log("Face recognition: Ignoring face recognition entry: " .. file)
else
for t,_ in pairs (tags) do
-- Check if image is ignored
if ignoreByTag (img, ignoreTags) then
dt.print_log("Face recognition: Ignoring image with ID " .. img.id)
else
-- Check of unrecognized unknown_person
if t == "unknown_person" then
t = unknownTag
end
-- Check of unrecognized no_persons_found
if t == "no_persons_found" then
t = nonpersonsfoundTag
end
if t ~= "" and t ~= nil then
if categoryTagString ~= "" and t ~= nonpersonsfoundTag then
t = categoryTagString .. "|" .. t
end
dt.print_log ("ImgId:" .. img.id .. " Tag:".. t)
-- Create tag if it does not exist
if tags_list[t] == nil then
tag = dt.tags.create (t)
tags_list[t] = tag
else
tag = tags_list[t]
end
img:attach_tag (tag)
end
end
end
end
end
cleanup(img_list)
dt.print_log("img_list cleaned-up")
dt.print_log("face recognition complete")
dt.print(_("face recognition complete"))
else
dt.print(_("image export failed"))
return
end
else
dt.print(_("no images selected"))
return
end
end
local function install_module()
if not fc.module_installed then
dt.register_lib(
MODULE, -- Module name
_("face recognition"), -- Visible name
true, -- expandable
true, -- resetable
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 300}}, -- containers
fc.widget,
nil,-- view_enter
nil -- view_leave
)
fc.module_installed = true
end
end
local function destroy()
dt.gui.libs[MODULE].visible = false
end
local function restart()
dt.gui.libs[MODULE].visible = true
end
-- build the interface
fc.unknown_tag = dt.new_widget("entry"){
text = dt.preferences.read(MODULE, "unknown_tag", "string"),
tooltip = _("tag to be used for unknown person"),
editable = true,
}
fc.no_persons_found_tag = dt.new_widget("entry"){
text = dt.preferences.read(MODULE, "no_persons_found_tag", "string"),
tooltip = _("tag to be used when no persons are found"),
editable = true,
}
fc.ignore_tags = dt.new_widget("entry"){
text = dt.preferences.read(MODULE, "ignore_tags", "string"),
tooltip = _("tags of images to ignore"),
editable = true,
}
fc.category_tags = dt.new_widget("entry"){
text = dt.preferences.read(MODULE, "category_tags", "string"),
tooltip = _("tag category"),
editable = true,
}
fc.tolerance = dt.new_widget("slider"){
label = _("tolerance"),
tooltip = _("detection tolerance - 0.6 default - lower if too many faces detected"),
soft_min = 0.0,
hard_min = 0.0,
soft_max = 1.0,
soft_min = 1.0,
step = 0.1,
digits = 1,
value = 0.0,
}
fc.num_cores = dt.new_widget("slider"){
label = _("processor cores"),
tooltip = _("number of processor cores to use, 0 for all"),
soft_min = 0,
soft_max = 16,
hard_min = 0,
hard_max = 64,
step = 1,
digits = 0,
value = dt.preferences.read(MODULE, "num_cores", "integer"),
}
fc.known_image_path = dt.new_widget("file_chooser_button"){
title = _("known image directory"),
tooltip = _("face data directory"),
value = dt.preferences.read(MODULE, "known_image_path", "directory"),
is_directory = true,
changed_callback = function(this)
dt.preferences.write(MODULE, "known_image_path", "directory", this.value)
end
}
fc.export_format = dt.new_widget("combobox"){
label = _("export image format"),
tooltip = _("format for exported images"),
selected = dt.preferences.read(MODULE, "export_format", "integer"),
changed_callback = function(this)
dt.preferences.write(MODULE, "export_format", "integer", this.selected)
end,
"JPEG", "PNG", "TIFF",
}
fc.width = dt.new_widget("entry"){
text = tostring(dt.preferences.read(MODULE, "max_width", "integer")),
tooltip = _("maximum exported image width"),
editable = true,
}
fc.height = dt.new_widget("entry"){
text = tostring(dt.preferences.read(MODULE, "max_height", "integer")),
tooltip = _("maximum exported image height"),
editable = true,
}
fc.execute = dt.new_widget("button"){
label = "detect faces",
clicked_callback = function(this)
face_recognition()
end
}
local widgets = {
dt.new_widget("label"){ label = _("unknown person tag")},
fc.unknown_tag,
dt.new_widget("label"){ label = _("no persons found tag")},
fc.no_persons_found_tag,
dt.new_widget("label"){ label = _("tags of images to ignore")},
fc.ignore_tags,
dt.new_widget("label"){ label = _("tag category")},
fc.category_tags,
dt.new_widget("label"){ label = _("face data directory")},
fc.known_image_path,
}
if dt.configuration.running_os == "windows" or dt.configuration.running_os == "macos" then
table.insert(widgets, df.executable_path_widget({"face_recognition"}))
end
table.insert(widgets, dt.new_widget("section_label"){ label = _("processing options")})
table.insert(widgets, fc.tolerance)
table.insert(widgets, fc.num_cores)
table.insert(widgets, fc.export_format)
table.insert(widgets, dt.new_widget("box"){
orientation = "horizontal",
dt.new_widget("label"){ label = _("width")},
fc.width,
})
table.insert(widgets, dt.new_widget("box"){
orientation = "horizontal",
dt.new_widget("label"){ label = _("height")},
fc.height,
})
table.insert(widgets, fc.execute)
fc.widget = dt.new_widget("box"){
orientation = vertical,
reset_callback = function(this)
reset_preferences()
end,
table.unpack(widgets),
}
if dt.gui.current_view().id == "lighttable" then
install_module()
else
if not fc.event_registered then
dt.register_event(
MODULE, "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
fc.event_registered = true
end
end
fc.tolerance.value = dt.preferences.read(MODULE, "tolerance", "float")
-- preferences
if not dt.preferences.read(MODULE, "initialized", "bool") then
reset_preferences()
save_preferences()
dt.preferences.write(MODULE, "initialized", "bool", true)
end
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = restart
return script_data
--
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua

View File

@@ -0,0 +1,156 @@
--[[ fujifilm_dynamic_range-0.1
Compensate for Fujifilm raw files made using "dynamic range".
Copyright (C) 2021, 2022 Dan Torop <dant@pnym.net>
This program 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 2 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
]]
--[[About this Plugin
Support for adjusting darktable exposure by Fujifilm raw exposure
bias. This corrects for a DR100/DR200/DR400 "dynamic range" setting.
Dependencies:
- exiftool (https://www.sno.phy.queensu.ca/~phil/exiftool/)
Based upon fujifilm_ratings by Ben Mendis
The relevant tag is RawExposureBias (0x9650). This appears to
represent the shift in EV for the chosen DR setting (whether manual or
automatic). Note that even at 100DR ("standard") there is an EV shift:
100 DR -> -0.72 EV
200 DR -> -1.72 EV
400 DR -> -2.72 EV
The ideal would be to use exiv2 to read this tag, as this is the same
code which darktable import uses. Unfortunately, exiv2 as of v0.27.3
can't read this tag. As it is encoded as a 4-byte ratio of two signed
shorts -- a novel data type -- it will require some attention to fix
this.
There is an exiv2-readable DevelopmentDynamicRange tag which maps to
RawExposureBias as above. DevelopmentDynamicRange is only present
when tag DynamicRangeSetting (0x1402) is Manual/Raw (0x0001). When it
is Auto (0x0000), the equivalent data is tag AutoDynamicRange
(0x140b). But exiv2 currently can't read that tag either.
Hence for now this code uses exiftool to read RawExposureBias, as a
more general solution. As exiftool is approx. 10x slower than exiv2
(Perl vs. C++), this may slow large imports.
These tags have been checked on a Fujifilm X100S and X100V. Other
cameras may behave in other ways.
--]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
du.check_min_api_version("7.0.0", "fujifilm_dynamic_range")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("fujifilm dynamic range"),
purpose = _("compensate for Fujifilm raw files made using \"dynamic range\""),
author = "Dan Torop <dant@pnym.net>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/fujifilm_dynamic_range"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local function detect_dynamic_range(event, image)
if image.exif_maker ~= "FUJIFILM" then
dt.print_log("[fujifilm_dynamic_range] ignoring non-Fujifilm image")
return
end
-- it would be nice to check image.is_raw but this appears to not yet be set
if not string.match(image.filename, "%.RAF$") then
dt.print_log("[fujifilm_dynamic_range] ignoring non-raw image")
return
end
local command = df.check_if_bin_exists("exiftool")
if not command then
dt.print_error("[fujifilm_dynamic_range] exiftool not found")
return
end
local RAF_filename = df.sanitize_filename(tostring(image))
-- without -n flag, exiftool will round to the nearest tenth
command = command .. " -RawExposureBias -n -t " .. RAF_filename
dt.print_log(command)
output = io.popen(command)
local raf_result = output:read("*all")
output:close()
if #raf_result == 0 then
dt.print_error("[fujifilm_dynamic_range] no output returned by exiftool")
return
end
raf_result = string.match(raf_result, "\t(.*)")
if not raf_result then
dt.print_error("[fujifilm_dynamic_range] could not parse exiftool output")
return
end
if image.exif_exposure_bias ~= image.exif_exposure_bias then
-- is NAN (this is unlikely as RAFs should have ExposureBiasValue set)
image.exif_exposure_bias = 0
end
-- this should be auto-applied if plugins/darkroom/workflow is scene-referred
-- note that scene-referred workflow exposure preset also pushes exposure up by 0.5 EV
image.exif_exposure_bias = image.exif_exposure_bias + tonumber(raf_result)
dt.print_log("[fujifilm_dynamic_range] raw exposure bias " .. tostring(raf_result))
-- handle any duplicates
if #image:get_group_members() > 1 then
local basename = df.get_basename(image.filename)
local grouped_images = image:get_group_members()
for _, img in ipairs(grouped_images) do
if string.match(img.filename, basename) and img.duplicate_index > 0 then
-- its a duplicate
img.exif_exposure_bias = img.exif_exposure_bias + tonumber(raf_result)
end
end
end
end
local function destroy()
dt.destroy_event("fujifilm_dr", "post-import-image")
end
if not df.check_if_bin_exists("exiftool") then
dt.print_log("Please install exiftool to use fujifilm_dynamic_range")
error "[fujifilm_dynamic_range] exiftool not found"
end
dt.register_event("fujifilm_dr", "post-import-image",
detect_dynamic_range)
dt.print_log("[fujifilm_dynamic_range] loaded")
script_data.destroy = destroy
return script_data

View File

@@ -24,47 +24,72 @@ Dependencies:
--]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local gettext = dt.gettext
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
dt.configuration.check_version(..., {4,0,0})
gettext.bindtextdomain("fujifilm_ratings", dt.configuration.config_dir.."/lua/locale/")
du.check_min_api_version("7.0.0", "fujifilm_ratings")
local function _(msgid)
return gettext.dgettext("fujifilm_ratings", msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("fujifilm ratings"),
purpose = _("import Fujifilm in-camera ratings"),
author = "Ben Mendis <ben.mendis@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/fujifilm_ratings"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local function detect_rating(event, image)
if not df.check_if_bin_exists("exiftool") then
dt.print_error(_("exiftool not found"))
if not string.match(image.filename, "%.RAF$") and not string.match(image.filename, "%.raf$") then
return
end
local RAF_filename = tostring(image)
if not df.check_if_bin_exists("exiftool") then
dt.print_error("exiftool not found")
return
end
local RAF_filename = df.sanitize_filename(tostring(image))
local JPEG_filename = string.gsub(RAF_filename, "%.RAF$", ".JPG")
local command = "exiftool -Rating " .. JPEG_filename
dt.print_error(command)
dt.print_log(command)
local output = io.popen(command)
local jpeg_result = output:read("*all")
output:close()
if string.len(jpeg_result) > 0 then
jpeg_result = string.gsub(jpeg_result, "^Rating.*(%d)", "%1")
image.rating = tonumber(jpeg_result)
dt.print_error(_("Using JPEG Rating: ") .. tostring(jpeg_result))
dt.print_log("using JPEG rating: " .. jpeg_result)
return
end
command = "exiftool -Rating " .. RAF_filename
dt.print_error(command)
dt.print_log(command)
output = io.popen(command)
local raf_result = output:read("*all")
output:close()
if string.len(raf_result) > 0 then
raf_result = string.gsub(raf_result, "^Rating.*(%d)", "%1")
image.rating = tonumber(raf_result)
dt.print_error(_("Using RAF Rating: ") .. tostring(raf_result))
dt.print_log("using RAF rating: " .. raf_result)
end
end
dt.register_event("post-import-image", detect_rating)
local function destroy()
dt.destroy_event("fujifilm_rat", "post-import-image")
end
print(_("fujifilm_ratings loaded."))
dt.register_event("fujifilm_rat", "post-import-image",
detect_rating)
script_data.destroy = destroy
return script_data

View File

@@ -33,19 +33,33 @@ USAGE
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
require "official/yield"
local gettext = dt.gettext
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("geoJSON_export",dt.configuration.config_dir.."/lua/locale/")
du.check_min_api_version("7.0.0", "geoJSON_export")
local function _(msgid)
return gettext.dgettext("geoJSON_export", msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("geoJSON export"),
purpose = _("export a geoJSON file from geo data"),
author = "Tobias Jakobs",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/geoJSON_export"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- Sort a table
local function spairs(_table, order) -- Code copied from http://stackoverflow.com/questions/15706270/sort-a-table-in-lua
-- collect the keys
@@ -71,24 +85,24 @@ local function spairs(_table, order) -- Code copied from http://stackoverflow.co
end
local function show_status(storage, image, format, filename, number, total, high_quality, extra_data)
dt.print(string.format(_("Export Image %i/%i"), number, total))
dt.print(string.format(_("export image %i/%i"), number, total))
end
local function create_geoJSON_file(storage, image_table, extra_data)
if not df.check_if_bin_exists("mkdir") then
dt.print_error(_("mkdir not found"))
dt.print_error("mkdir not found")
return
end
if not df.check_if_bin_exists("convert") then
dt.print_error(_("convert not found"))
dt.print_error("convert not found")
return
end
if not df.check_if_bin_exists("xdg-open") then
dt.print_error(_("xdg-open not found"))
dt.print_error("xdg-open not found")
return
end
if not df.check_if_bin_exists("xdg-user-dir") then
dt.print_error(_("xdg-user-dir not found"))
dt.print_error("xdg-user-dir not found")
return
end
@@ -279,7 +293,7 @@ local function create_geoJSON_file(storage, image_table, extra_data)
file:write(geoJSON_file)
file:close()
dt.print("geoJSON file created in "..exportDirectory)
dt.print(string.format(_("%s file created in %s"), "geoJSON", exportDirectory))
-- Open the file with the standard programm
if ( dt.preferences.read("geoJSON_export","OpengeoJSONFile","bool") == true ) then
@@ -291,24 +305,28 @@ local function create_geoJSON_file(storage, image_table, extra_data)
end
local function destroy()
dt.destroy_storage("geoJSON_export")
end
-- Preferences
dt.preferences.register("geoJSON_export",
"CreateMapBoxHTMLFile",
"bool",
_("geoJSON export: Create an additional HTML file"),
_("Creates a HTML file, that loads the geoJASON file. (Needs a MapBox key"),
"geoJSON export: ".._("Create an additional HTML file"),
_("creates an HTML file that loads the geoJSON file. (needs a MapBox key"),
false )
dt.preferences.register("geoJSON_export",
"mapBoxKey",
"string",
_("geoJSON export: MapBox Key"),
_("https://www.mapbox.com/studio/account/tokens"),
"geoJSON export: MapBox " .. _("key"),
"https://www.mapbox.com/studio/account/tokens",
'' )
dt.preferences.register("geoJSON_export",
"OpengeoJSONFile",
"bool",
_("geoJSON export: Open geoJSON file after export"),
_("Opens the geoJSON file after the export with the standard program for geoJSON files"),
"geoJSON export: " .. _("open geoJSON file after export"),
_("opens the geoJSON file after the export with the standard program for geoJSON files"),
false )
local handle = io.popen("xdg-user-dir DESKTOP")
@@ -320,9 +338,13 @@ end
dt.preferences.register("geoJSON_export",
"ExportDirectory",
"directory",
_("geoJSON export: Export directory"),
_("A directory that will be used to export the geoJSON files"),
_("geoJSON export: export directory"),
_("a directory that will be used to export the geoJSON files"),
result )
-- Register
dt.register_storage("geoJSON_export", "geoJSON Export", nil, create_geoJSON_file)
script_data.destroy = destroy
return script_data

View File

@@ -1,6 +1,7 @@
--[[
This file is part of darktable,
copyright (c) 2016 Tobias Jakobs
copyright (c) 2025 Balázs Dura-Kovács
darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -26,38 +27,70 @@ require "geoToolbox"
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
require "official/yield"
local gettext = dt.gettext
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("geoToolbox",dt.configuration.config_dir.."/lua/locale/")
du.check_min_api_version("7.0.0", "geoToolbox")
local function _(msgid)
return gettext.dgettext("geoToolbox", msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("geo toolbox"),
purpose = _("geodata tools"),
author = "Tobias Jakobs",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/geoToolbox"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local gT = {}
gT.module_installed = false
gT.event_registered = false
-- <GUI>
local labelDistance = dt.new_widget("label")
labelDistance.label = _("Distance:")
labelDistance.label = _("distance:")
local label_copy_gps_lat = dt.new_widget("check_button")
local checkbox_copy_gps_lat = dt.new_widget("check_button")
{
label = _("latitude:"),
value = true
}
local label_copy_gps_lon = dt.new_widget("check_button")
local entry_gps_lat = dt.new_widget("entry")
{
tooltip = _("latitude (editable)"),
placeholder = _("latitude")
}
local checkbox_copy_gps_lon = dt.new_widget("check_button")
{
label = _("longitude:"),
value = true
}
local label_copy_gps_ele = dt.new_widget("check_button")
local entry_gps_lon = dt.new_widget("entry")
{
tooltip = _("longitude (editable)"),
placeholder = _("longitude")
}
local checkbox_copy_gps_ele = dt.new_widget("check_button")
{
label = _("elevation:"),
value = true
}
local entry_gps_ele = dt.new_widget("entry")
{
tooltip = _("elevation (editable)"),
placeholder = _("elevation")
}
-- </GUI>
local function select_with_gps()
@@ -147,7 +180,7 @@ local function get_first_coordinate()
first_elevation = ''
first_image_date = 0
for _,image in ipairs(sel_images) do
for jj,image in ipairs(sel_images) do
if not image then
first_have_data = false
else
@@ -186,7 +219,7 @@ local function get_second_coordinate()
second_elevation = ''
second_image_date = 0
for _,image in ipairs(sel_images) do
for jj,image in ipairs(sel_images) do
if not image then
second_have_data = false
else
@@ -222,7 +255,7 @@ local calc_in_between_slider = dt.new_widget("slider")
--ToDo: this needs more love
local function calc_in_between()
local sel_images = dt.gui.action_images
for _,image in ipairs(sel_images) do
for jj,image in ipairs(sel_images) do
if image then
image_date = make_time_stamp(image.exif_datetime_taken)
if (first_have_data and second_have_data) then
@@ -269,25 +302,25 @@ local function copy_gps()
copy_gps_longitude = ''
copy_gps_elevation = ''
for _,image in ipairs(sel_images) do
for jj,image in ipairs(sel_images) do
if not image then
copy_gps_have_data = false
else
copy_gps_have_data = true
if (image.latitude and label_copy_gps_lat.value) then
if (image.latitude and checkbox_copy_gps_lat.value) then
copy_gps_latitude = image.latitude
end
if (image.longitude and label_copy_gps_lon.value) then
if (image.longitude and checkbox_copy_gps_lon.value) then
copy_gps_longitude = image.longitude
end
if (image.elevation and label_copy_gps_ele.value) then
if (image.elevation and checkbox_copy_gps_ele.value) then
copy_gps_elevation = image.elevation
end
end
label_copy_gps_lat.label = _("latitude: ") .. copy_gps_latitude
label_copy_gps_lon.label = _("longitude: ") ..copy_gps_longitude
label_copy_gps_ele.label = _("elevation: ") .. copy_gps_elevation
entry_gps_lat.text = copy_gps_latitude
entry_gps_lon.text = copy_gps_longitude
entry_gps_ele.text = copy_gps_elevation
return
end
@@ -296,15 +329,15 @@ end
local function paste_gps(image)
local sel_images = dt.gui.action_images
for _,image in ipairs(sel_images) do
if (label_copy_gps_lat.value) then
image.latitude = copy_gps_latitude
for jj,image in ipairs(sel_images) do
if (checkbox_copy_gps_lat.value) then
image.latitude = entry_gps_lat.text
end
if (label_copy_gps_lon.value) then
image.longitude = copy_gps_longitude
if (checkbox_copy_gps_lon.value) then
image.longitude = entry_gps_lon.text
end
if (label_copy_gps_ele.value) then
image.elevation = copy_gps_elevation
if (checkbox_copy_gps_ele.value) then
image.elevation = entry_gps_ele.text
end
end
end
@@ -323,7 +356,7 @@ local function open_location_in_gnome_maps()
local i = 0;
-- Use the first image with geo information
for _,image in ipairs(sel_images) do
for jj,image in ipairs(sel_images) do
if ((image.longitude and image.latitude) and
(image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data
) then
@@ -350,12 +383,12 @@ end
local function reverse_geocode()
if not df.check_if_bin_exists("curl") then
dt.print_error(_("curl not found"))
dt.print_error("curl not found")
return
end
if not df.check_if_bin_exists("jq") then
dt.print_error(_("jq not found"))
dt.print_error("jq not found")
return
end
@@ -366,7 +399,7 @@ local function reverse_geocode()
local i = 0;
-- Use the first image with geo information
for _,image in ipairs(sel_images) do
for jj,image in ipairs(sel_images) do
if ((image.longitude and image.latitude) and
(image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data
) then
@@ -416,7 +449,7 @@ local function get_distance(lat1, lon1, ele1, lat2, lon2, ele2)
math.cos(math.rad(lat1)) * math.cos(math.rad(lat2)) *
math.sin(dLon/2) * math.sin(dLon/2)
;
local angle = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a));
local angle = 2 * math.atan(math.sqrt(a), math.sqrt(1-a));
local distance = earthRadius * angle; -- Distance in km
-- Add the elevation to the calculation
@@ -441,7 +474,7 @@ local function calc_distance()
local sel_images = dt.gui.selection()
for _,image in ipairs(sel_images) do
for jj,image in ipairs(sel_images) do
if ((image.longitude and image.latitude) and
(image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data
) then
@@ -473,12 +506,12 @@ local function calc_distance()
if (distance < 1) then
distance = distance * 1000
distanceUnit = _("m")
distanceUnit = "m"
else
distanceUnit = _("km")
distanceUnit = "km"
end
return string.format(_("Distance: %.2f %s"), distance, distanceUnit)
return string.format(_("distance: %.2f %s"), distance, distanceUnit)
end
local function print_calc_distance()
@@ -501,12 +534,12 @@ local altitude_filename = dt.new_widget("entry")
text = "altitude.csv",
placeholder = "altitude.csv",
editable = true,
tooltip = _("Name of the exported file"),
tooltip = _("name of the exported file"),
reset_callback = function(self) self.text = "text" end
}
local function altitude_profile()
dt.print(_("Start export"))
dt.print(_("start export"))
local sel_images = dt.gui.action_images
local lat1 = 0;
@@ -525,7 +558,7 @@ local function altitude_profile()
local elevationAdd = 0;
local sel_images = dt.gui.action_images
for _,image in ipairs(sel_images) do
for jj,image in ipairs(sel_images) do
if ((not isnan(image.longitude) and not isnan(image.latitude) and not isnan(image.elevation) and image.elevation) and
(image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data
) then
@@ -567,10 +600,53 @@ local function altitude_profile()
file = io.open(exportDirectory.."/"..exportFilename, "w")
file:write(csv_file)
file:close()
dt.print(_("File created in ")..exportDirectory)
dt.print(string.format(_("file created in %s"), exportDirectory))
end
local function install_module()
if not gT.module_installed then
dt.register_lib(
"geoToolbox", -- Module name
_("geo toolbox"), -- name
true, -- expandable
false, -- resetable
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers
gT.widget,
nil,-- view_enter
nil -- view_leave
)
gT.module_installed = true
end
end
local function destroy()
dt.gui.libs["geoToolbox"].visible = false
dt.destroy_event("geoToolbox_cd", "shortcut")
dt.destroy_event("geoToolbox", "mouse-over-image-changed")
dt.destroy_event("geoToolbox_wg", "shortcut")
dt.destroy_event("geoToolbox_ng", "shortcut")
end
local function restart()
dt.register_event("geoToolbox_cd", "shortcut",
print_calc_distance, _("calculate the distance from latitude and longitude in km"))
dt.register_event("geoToolbox", "mouse-over-image-changed",
toolbox_calc_distance)
dt.register_event("geoToolbox_wg", "shortcut",
select_with_gps, _("select all images with GPS information"))
dt.register_event("geoToolbox_ng", "shortcut",
select_without_gps, _("select all images without GPS information"))
dt.gui.libs["geoToolbox"].visible = true
end
local function show()
dt.gui.libs["geoToolbox"].visible = true
end
local separator = dt.new_widget("separator"){}
local separator2 = dt.new_widget("separator"){}
@@ -578,41 +654,47 @@ local separator3 = dt.new_widget("separator"){}
local separator4 = dt.new_widget("separator"){}
local separator5 = dt.new_widget("separator"){}
dt.register_lib(
"geoToolbox", -- Module name
"geo toolbox", -- name
true, -- expandable
false, -- resetable
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers
dt.new_widget("box")
gT.widget = dt.new_widget("box")
{
orientation = "vertical",
dt.new_widget("button")
{
label = _("select geo images"),
tooltip = _("Select all images with GPS information"),
tooltip = _("select all images with GPS information"),
clicked_callback = select_with_gps
},
dt.new_widget("button")
{
label = _("select non-geo images"),
tooltip = _("Select all images without GPS information"),
tooltip = _("select all images without GPS information"),
clicked_callback = select_without_gps
},
separator,--------------------------------------------------------
dt.new_widget("button")
{
label = _("copy GPS data"),
tooltip = _("Copy GPS data"),
tooltip = _("copy GPS data"),
clicked_callback = copy_gps
},
label_copy_gps_lat,
label_copy_gps_lon,
label_copy_gps_ele,
dt.new_widget("box"){
orientation = "horizontal",
checkbox_copy_gps_lat,
entry_gps_lat
},
dt.new_widget("box"){
orientation = "horizontal",
checkbox_copy_gps_lon,
entry_gps_lon
},
dt.new_widget("box"){
orientation = "horizontal",
checkbox_copy_gps_ele,
entry_gps_ele
},
dt.new_widget("button")
{
label = _("paste GPS data"),
tooltip = _("Paste GPS data"),
label = _("apply GPS data to image"),
tooltip = _("apply GPS data to image"),
clicked_callback = paste_gps
},
separator2,--------------------------------------------------------
@@ -642,14 +724,14 @@ dt.register_lib(
dt.new_widget("button")
{
label = _("open in Gnome Maps"),
tooltip = _("Open location in Gnome Maps"),
tooltip = _("open location in Gnome Maps"),
clicked_callback = open_location_in_gnome_maps
},
separator4,--------------------------------------------------------
dt.new_widget("button")
{
label = _("reverse geocode"),
tooltip = _("This just shows the name of the location, but doesn't add it as tag"),
tooltip = _("this just shows the name of the location, but doesn't add it as tag"),
clicked_callback = reverse_geocode
},
separator5,--------------------------------------------------------
@@ -659,29 +741,53 @@ dt.register_lib(
dt.new_widget("button")
{
label = _("export altitude CSV file"),
tooltip = _("Create an altitude profile using the GPS data in the metadata"),
tooltip = _("create an altitude profile using the GPS data in the metadata"),
clicked_callback = altitude_profile
},
labelDistance
},
nil,-- view_enter
nil -- view_leave
}
if dt.gui.current_view().id == "lighttable" then
install_module()
else
if not gT.event_registered then
dt.register_event(
"geoToolbox", "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
gT.event_registered = true
end
end
-- Preferences
dt.preferences.register("geoToolbox",
"mapBoxKey",
"string",
_("geoToolbox export: MapBox Key"),
_("https://www.mapbox.com/studio/account/tokens"),
"https://www.mapbox.com/studio/account/tokens",
'' )
-- Register
dt.register_event("shortcut", print_calc_distance, _("Calculate the distance from latitude and longitude in km"))
dt.register_event("mouse-over-image-changed", toolbox_calc_distance)
dt.register_event("geoToolbox_cd", "shortcut",
print_calc_distance, _("calculate the distance from latitude and longitude in km"))
dt.register_event("geoToolbox", "mouse-over-image-changed",
toolbox_calc_distance)
dt.register_event("shortcut", select_with_gps, _("Select all images with GPS information"))
dt.register_event("shortcut", select_without_gps, _("Select all images without GPS information"))
dt.register_event("geoToolbox_wg", "shortcut",
select_with_gps, _("select all images with GPS information"))
dt.register_event("geoToolbox_ng", "shortcut",
select_without_gps, _("select all images without GPS information"))
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = show
return script_data
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
-- kate: hl Lua;

View File

@@ -41,7 +41,9 @@
* require this script from your main lua file
* select an image or images for editing with GIMP
* in the export dialog select "Edit with GIMP" and select the format and bit depth for the
exported image
exported image. Check the "run_detached" button to run GIMP in detached mode. Images
will not be returned to darktable in this mode, but additional images can be sent to
GIMP without stopping it.
* Press "export"
* Edit the image with GIMP then save the changes with File->Overwrite....
* Exit GIMP
@@ -64,181 +66,75 @@
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
require "official/yield"
local gettext = dt.gettext
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
local gimp_widget = nil
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("gimp",dt.configuration.config_dir.."/lua/locale/")
local function split_filepath(str)
local result = {}
-- Thank you Tobias Jakobs for the awesome regular expression, which I tweaked a little
result["path"], result["filename"], result["basename"], result["filetype"] = string.match(str, "(.-)(([^\\/]-)%.?([^%.\\/]*))$")
return result
end
local function get_path(str)
local parts = split_filepath(str)
return parts["path"]
end
local function get_filename(str)
local parts = split_filepath(str)
return parts["filename"]
end
local function get_basename(str)
local parts = split_filepath(str)
return parts["basename"]
end
local function get_filetype(str)
local parts = split_filepath(str)
return parts["filetype"]
end
du.check_min_api_version("7.0.0", "gimp")
local function _(msgid)
return gettext.dgettext("gimp", msgid)
return gettext(msgid)
end
-- Thanks Tobias Jakobs for the idea and the correction
function checkIfFileExists(filepath)
local file = io.open(filepath,"r")
local ret
if file ~= nil then
io.close(file)
dt.print_error("true checkIfFileExists: "..filepath)
ret = true
else
dt.print_error(filepath.." not found")
ret = false
end
return ret
end
-- return data structure for script_manager
local function filename_increment(filepath)
local script_data = {}
-- break up the filepath into parts
local path = get_path(filepath)
local basename = get_basename(filepath)
local filetype = get_filetype(filepath)
script_data.metadata = {
name = _("edit with GIMP"),
purpose = _("export and edit with GIMP"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/gimp"
}
-- check to see if we've incremented before
local increment = string.match(basename, "_(%d-)$")
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
if increment then
-- we do 2 digit increments so make sure we didn't grab part of the filename
if string.len(increment) > 2 then
-- we got the filename so set the increment to 01
increment = "01"
else
increment = string.format("%02d", tonumber(increment) + 1)
basename = string.gsub(basename, "_(%d-)$", "")
end
else
increment = "01"
end
local incremented_filepath = path .. basename .. "_" .. increment .. "." .. filetype
dt.print_error("original file was " .. filepath)
dt.print_error("incremented file is " .. incremented_filepath)
return incremented_filepath
end
local function groupIfNotMember(img, new_img)
local function group_if_not_member(img, new_img)
local image_table = img:get_group_members()
local is_member = false
for _,image in ipairs(image_table) do
dt.print_error(image.filename .. " is a member")
dt.print_log(image.filename .. " is a member")
if image.filename == new_img.filename then
is_member = true
dt.print_error("Already in group")
dt.print_log("Already in group")
end
end
if not is_member then
dt.print_error("group leader is "..img.group_leader.filename)
dt.print_log("group leader is "..img.group_leader.filename)
new_img:group_with(img.group_leader)
dt.print_error("Added to group")
dt.print_log("Added to group")
end
end
local function sanitize_filename(filepath)
local path = get_path(filepath)
local basename = get_basename(filepath)
local filetype = get_filetype(filepath)
local sanitized = string.gsub(basename, " ", "\\ ")
return path .. sanitized .. "." .. filetype
end
local function show_status(storage, image, format, filename,
number, total, high_quality, extra_data)
dt.print(string.format(_("Export Image %i/%i"), number, total))
end
local function fileCopy(fromFile, toFile)
local result = nil
-- if cp exists, use it
if df.check_if_bin_exists("cp") then
result = os.execute("cp '" .. fromFile .. "' '" .. toFile .. "'")
end
-- if cp was not present, or if cp failed, then a pure lua solution
if not result then
local fileIn, err = io.open(fromFile, 'rb')
if fileIn then
local fileOut, errr = io.open(toFile, 'w')
if fileOut then
local content = fileIn:read(4096)
while content do
fileOut:write(content)
content = fileIn:read(4096)
end
result = true
fileIn:close()
fileOut:close()
else
dt.print_error("fileCopy Error: " .. errr)
end
else
dt.print_error("fileCopy Error: " .. err)
end
end
return result
end
local function fileMove(fromFile, toFile)
local success = os.rename(fromFile, toFile)
if not success then
-- an error occurred, so let's try using the operating system function
if df.check_if_bin_exists("mv") then
success = os.execute("mv '" .. fromFile .. "' '" .. toFile .. "'")
end
-- if the mv didn't exist or succeed, then...
if not success then
-- pure lua solution
success = fileCopy(fromFile, toFile)
if success then
os.remove(fromFile)
else
dt.print_error("fileMove Error: Unable to move " .. fromFile .. " to " .. toFile .. ". Leaving " .. fromFile .. " in place.")
dt.print(string.format(_("Unable to move edited file into collection. Leaving it as %s"), fromFile))
end
end
end
return success -- nil on error, some value if success
dt.print(string.format(_("export image %i/%i"), number, total))
end
local function gimp_edit(storage, image_table, extra_data) --finalize
if not df.check_if_bin_exists("gimp") then
dt.print_error(_("GIMP not found"))
local run_detached = dt.preferences.read("gimp", "run_detached", "bool")
local gimp_executable = df.check_if_bin_exists("gimp")
if not gimp_executable then
dt.print_error("GIMP not found")
return
end
if dt.configuration.running_os == "macos" then
if run_detached then
gimp_executable = "open -a " .. gimp_executable
else
gimp_executable = "open -W -a " .. gimp_executable
end
end
-- list of exported images
local img_list
@@ -246,18 +142,28 @@ local function gimp_edit(storage, image_table, extra_data) --finalize
img_list = ""
for _,exp_img in pairs(image_table) do
exp_img = sanitize_filename(exp_img)
exp_img = df.sanitize_filename(exp_img)
img_list = img_list ..exp_img.. " "
end
dt.print(_("Launching GIMP..."))
dt.print(_("launching GIMP..."))
local gimpStartCommand
gimpStartCommand = "gimp "..img_list
gimpStartCommand = gimp_executable .. " " .. img_list
dt.print_error(gimpStartCommand)
if run_detached then
if dt.configuration.running_os == "windows" then
gimpStartCommand = "start /b \"\" " .. gimpStartCommand
else
gimpStartCommand = gimpStartCommand .. " &"
end
end
dt.control.execute( gimpStartCommand)
dt.print_log(gimpStartCommand)
dtsys.external_command(gimpStartCommand)
if not run_detached then
-- for each of the image, exported image pairs
-- move the exported image into the directory with the original
@@ -266,37 +172,54 @@ local function gimp_edit(storage, image_table, extra_data) --finalize
for image,exported_image in pairs(image_table) do
local myimage_name = image.path .. "/" .. get_filename(exported_image)
local myimage_name = image.path .. "/" .. df.get_filename(exported_image)
while checkIfFileExists(myimage_name) do
myimage_name = filename_increment(myimage_name)
while df.check_if_file_exists(myimage_name) do
myimage_name = df.filename_increment(myimage_name)
-- limit to 99 more exports of the original export
if string.match(get_basename(myimage_name), "_(d-)$") == "99" then
if string.match(df.get_basename(myimage_name), "_(d-)$") == "99" then
break
end
end
dt.print_error("moving " .. exported_image .. " to " .. myimage_name)
local result = fileMove(exported_image, myimage_name)
dt.print_log("moving " .. exported_image .. " to " .. myimage_name)
local result = df.file_move(exported_image, myimage_name)
if result then
dt.print_error("importing file")
dt.print_log("importing file")
local myimage = dt.database.import(myimage_name)
groupIfNotMember(image, myimage)
group_if_not_member(image, myimage)
for _,tag in pairs(dt.tags.get_tags(image)) do
if not (string.sub(tag.name,1,9) == "darktable") then
dt.print_error("attaching tag")
dt.print_log("attaching tag")
dt.tags.attach(tag,myimage)
end
end
end
end
end
end
local function destroy()
dt.destroy_storage("module_gimp")
end
-- Register
dt.register_storage("module_gimp", _("Edit with GIMP"), show_status, gimp_edit)
gimp_widget = dt.new_widget("check_button"){
label = _("run detached"),
tooltip = _("don't import resulting image back into darktable"),
value = dt.preferences.read("gimp", "run_detached", "bool"),
clicked_callback = function(this)
dt.preferences.write("gimp", "run_detached", "bool", this.value)
end
}
dt.register_storage("module_gimp", _("edit with GIMP"), show_status, gimp_edit, nil, nil, gimp_widget)
--
script_data.destroy = destroy
return script_data

213
contrib/gpx_export.lua Normal file
View File

@@ -0,0 +1,213 @@
--[[
This file is part of darktable,
copyright (c) 2017 Jannis_V
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/>.
]]
--[[
Simple darktable GPX generator script
This script generates a GPX track from all images having GPS latitude
and longitude information.
For each source folder, a separate <trk> is generated in the gpx file.
]]
local dt = require "darktable"
local df = require "lib/dtutils.file"
local dl = require "lib/dtutils"
local gettext = dt.gettext.gettext
dl.check_min_api_version("7.0.0", "gpx_export")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("gpx export"),
purpose = _("export gpx information to a file"),
author = "Jannis_V",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/gpx_export"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local gpx = {}
gpx.module_installed = false
gpx.event_registered = false
local path_entry = dt.new_widget("entry")
{
text = dt.preferences.read("gpx_exporter", "gpxExportPath", "string"),
editable=true,
reset_callback = function(self)
self.text = "~/darktable.gpx"
dt.preferences.write("gpx_exporter", "gpxExportPath", "string", self.text)
end,
tooltip = _("gpx file path"),
}
local function stop_job(job)
job.valid = false
end
local function create_gpx_file()
dt.preferences.write("gpx_exporter", "gpxExportPath", "string", path_entry.text)
path = path_entry.text:gsub("^~", os.getenv("HOME")) -- Expand ~ to home
path = path:gsub("//", "/")
dt.print(_("exporting gpx file..."))
job = dt.gui.create_job(_("gpx export"), true, stop_job)
local sel_images = dt.gui.action_images
local segments = {}
for key,image in dl.spairs(sel_images, function(t, a, b) return t[b].path > t[a].path end) do
print(image.path)
if (job.valid) then
job.percent = (key - 1) / #sel_images
if ((image.longitude and image.latitude) and
(image.longitude ~= 0 and image.latitude ~= 90) -- Just in case
) then
if (segments[image.path] == nil) then
segments[image.path] = {}
end
if (image.exif_datetime_taken == "") then
dt.print(image.path.."/"..image.filename.._(" does not have date information and won't be processed"))
print(image.path.."/"..image.filename.._(" does not have date information and won't be processed")) -- Also print to terminal
else
segments[image.path][image.filename] = image
end
end
else
break
end
end
local gpx_file = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n"
gpx_file = gpx_file.."<gpx xmlns=\"http://www.topografix.com/GPX/1/1\" creator=\"Darktable GPX Exporter\"\n"
gpx_file = gpx_file.."version=\"1.1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
gpx_file = gpx_file.."xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n"
for key, folder in dl.spairs(segments) do
gpx_file = gpx_file.."\t<trk>\n"
gpx_file = gpx_file.."\t\t<name>"..key.."</name>\n";
gpx_file = gpx_file.."\t\t<trkseg>\n";
for key2, image in dl.spairs(folder, function(t, a, b) return t[b].exif_datetime_taken > t[a].exif_datetime_taken end) do
date_format = "(%d+):(%d+):(%d+) (%d+):(%d+):(%d+)"
my_year, my_month, my_day, my_hour, my_min, my_sec = image.exif_datetime_taken:match(date_format)
local my_timestamp = os.time({year=my_year, month=my_month, day=my_day, hour=my_hour, min=my_min, sec=my_sec})
gpx_file = gpx_file.."\t\t\t<trkpt lat=\""..string.gsub(tostring(image.latitude), ",", ".").."\" lon=\""..string.gsub(tostring(image.longitude), ",", ".").."\">\n"
gpx_file = gpx_file.."\t\t\t\t<time>"..os.date("!%Y-%m-%dT%H:%M:%SZ", my_timestamp).."</time>\n"
gpx_file = gpx_file.."\t\t\t\t<name>"..image.path.."/"..image.filename.."</name>\n"
gpx_file = gpx_file.."\t\t\t</trkpt>\n"
end
gpx_file = gpx_file.."\t\t</trkseg>\n";
gpx_file = gpx_file.."\t</trk>\n";
end
job.valid = false
gpx_file = gpx_file.."</gpx>\n";
local file = io.open(path, "w")
if (file == nil) then
dt.print(string.format(_("invalid path: %s"), path))
else
file:write(gpx_file)
file:close()
dt.print(string.format(_("gpx file created: "), path))
end
end
local function install_module()
if not gpx.module_installed then
dt.register_lib(
"gpx_exporter",
_("gpx export"),
true, -- expandable
true, -- resetable
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers
gpx.widget,
nil,-- view_enter
nil -- view_leave
)
gpx.module_installed = true
end
end
local function destroy()
dt.gui.libs["gpx_exporter"].visible = false
end
local function restart()
dt.gui.libs["gpx_exporter"].visible = true
end
gpx.widget = dt.new_widget("box")
{
orientation = "vertical",
dt.new_widget("button")
{
label = _("export"),
tooltip = _("export gpx file"),
clicked_callback = create_gpx_file
},
dt.new_widget("box")
{
orientation = "horizontal",
dt.new_widget("label")
{
label = _("file:"),
},
path_entry
},
}
if dt.gui.current_view().id == "lighttable" then
install_module()
else
if not gpx.event_registered then
dt.register_event(
"gpx_export", "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
gpx.event_registered = true
end
end
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = restart
return script_data

View File

@@ -0,0 +1,97 @@
--[[
harmonic artmature 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/>.
]]
--[[
HARMONIC ARMATURE GUIDE
Harmonic Armature (also known as 14 line armature)
INSTALLATION
* copy this file in $CONFIGDIR/lua/contrib where CONFIGDIR is your darktable configuration directory
* add the following line in the file $CONFIGDIR/luarc
require "contrib/harmonic_armature_guide"
USAGE
* when using guides, select "harmonic armature" as guide
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local gettext = dt.gettext.gettext
du.check_min_api_version("2.0.0", "harmonic_armature_guide")
local function _(msgid)
return gettext(msgid)
end
local script_data = {}
script_data.metadata = {
name = _("harmonic armature guide"),
purpose = _("harmonic artmature guide"),
author = "Hubert Kowalski",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/harmonic_armature_guide"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
dt.guides.register_guide("harmonic armature",
-- 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:restore()
end,
-- gui
function()
return dt.new_widget("label"){label = _("harmonic armature"), halign = "start"}
end
)
local function destroy()
-- nothing to destroy
end
script_data.destroy = destroy
return script_data

View File

@@ -0,0 +1,200 @@
--[[
hif_group_leader.lua - Make hif image group leader
Copyright (C) 2024 Bill Ferguson <wpferguson@gmail.com>.
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
]]
--[[
hif_group_leader - Make hif image group leader
After a film roll is imported, check for RAW-JPG image groups
and make the JPG image the group leader. This is on by default
but can be disabled in preferences.
Shortcuts are included to filter existing collections or
selections of images and make the hif the group leader.
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
None
USAGE
Start script from script_manager
Assign keys to the shortcuts
BUGS, COMMENTS, SUGGESTIONS
Bill Ferguson <wpferguson@gmail.com>
CHANGES
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- C O N S T A N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
local MODULE = "hif_group_leader"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- A P I C H E C K
-- - - - - - - - - - - - - - - - - - - - - - - -
du.check_min_api_version("7.0.0", MODULE)
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- I 1 8 N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- S C R I P T M A N A G E R I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local script_data = {}
script_data.metadata = {
name = _("HIF group leader"),
purpose = _("make hif image group leader"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/hif_group_leader"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- - - - - - - - - - - - - - - - - - - - - - - -
-- P R E F E R E N C E S
-- - - - - - - - - - - - - - - - - - - - - - - -
dt.preferences.register(MODULE, "on_import", "bool", _("make hif group leader on import"), _("automatically make the hif file the group leader when raw + hif are imported"), true)
-- - - - - - - - - - - - - - - - - - - - - - - -
-- N A M E S P A C E
-- - - - - - - - - - - - - - - - - - - - - - - -
local jgloi = {}
jgloi.images = {}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- F U N C T I O N S
-- - - - - - - - - - - - - - - - - - - - - - - -
local function toggle_global_toolbox_grouping()
dt.gui.libs.global_toolbox.grouping = false
dt.gui.libs.global_toolbox.grouping = true
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- M A I N P R O G R A M
-- - - - - - - - - - - - - - - - - - - - - - - -
local function make_hif_group_leader(images)
-- if the image is part of a group, make it the leader
for _, image in ipairs(images) do
if #image:get_group_members() > 1 then
image:make_group_leader()
end
end
if dt.gui.libs.global_toolbox.grouping then
-- toggle the grouping to make the new leader show
toggle_global_toolbox_grouping()
end
end
local function make_existing_hif_group_leader(images)
for _, image in ipairs(images) do
if string.lower(df.get_filetype(image.filename)) == "hif" then
if #image:get_group_members() > 1 then
image:make_group_leader()
end
end
end
if dt.gui.libs.global_toolbox.grouping then
-- toggle the grouping to make the new leader show
toggle_global_toolbox_grouping()
end
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- D A R K T A B L E I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - -
local function destroy()
if dt.preferences.read(MODULE, "on_import", "bool") then
dt.destroy_event(MODULE, "post-import-film")
dt.destroy_event(MODULE, "post-import-image")
end
dt.destroy_event(MODULE .. "_collect", "shortcut")
dt.destroy_event(MODULE .. "_select", "shortcut")
end
script_data.destroy = destroy
-- - - - - - - - - - - - - - - - - - - - - - - -
-- E V E N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
if dt.preferences.read(MODULE, "on_import", "bool") then
dt.register_event(MODULE, "post-import-film",
function(event, film_roll)
-- ignore the film roll, it contains all the images, not just the imported
local images = jgloi.images
if #images > 0 then
jgloi.images = {}
make_hif_group_leader(images)
end
end
)
dt.register_event(MODULE, "post-import-image",
function(event, image)
if string.lower(df.get_filetype(image.filename)) == "hif" then
table.insert(jgloi.images, image)
end
end
)
end
dt.register_event(MODULE .. "_collect", "shortcut",
function(event, shortcut)
-- ignore the film roll, it contains all the images, not just the imported
local images = dt.collection
make_existing_hif_group_leader(images)
end,
_("make hif group leader for collection")
)
dt.register_event(MODULE .. "_select", "shortcut",
function(event, shortcut)
local images = dt.gui.selection()
make_existing_hif_group_leader(images)
end,
_("make hif group leader for selection")
)
return script_data

View File

@@ -28,85 +28,221 @@ ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
* hugin
USAGE
* require this file from your main luarc config file.
* require this file from your main luarc config file
* set the hugin tool paths (on some platforms)
* if hugin gui mode is used, save the final result in the tmp directory with the first file name and _pano as suffix for the image to be automatically imported to DT afterwards
This plugin will add a new storage option and calls hugin after export.
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
require "official/yield"
local gettext = dt.gettext
local log = require "lib/dtutils.log"
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
-- works with darktable API version from 2.0.0 to 5.0.0
dt.configuration.check_version(...,{2,0,0},{3,0,0},{4,0,0},{5,0,0})
local namespace = 'module_hugin'
local user_pref_str = 'prefer_gui'
local user_prefer_gui = dt.preferences.read(namespace, user_pref_str, "bool")
log.msg(log.info, "user_prefer_gui set to ", user_prefer_gui)
local hugin_widget = nil
local exec_widget = nil
local executable_table = {"hugin", "hugin_executor", "pto_gen"}
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("hugin",dt.configuration.config_dir.."/lua/locale/")
-- get the proper path quoting quote
local PQ = dt.configuration.running_os == "windows" and '"' or "'"
-- works with darktable API version from 5.0.0 on
du.check_min_api_version("7.0.0", "hugin")
local function _(msgid)
return gettext.dgettext("hugin", msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("hugin"),
purpose = _("stitch images into a panorama"),
author = "Wolfgang Goetz",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/hugin"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local function user_preference_changed(widget)
user_prefer_gui = widget.value
dt.preferences.write(namespace, user_pref_str, "bool", user_prefer_gui)
end
local function show_status(storage, image, format, filename,
number, total, high_quality, extra_data)
dt.print("Export to Hugin "..tostring(number).."/"..tostring(total))
dt.print(string.format(_("exporting to hugin: %d / %d"), number, total))
end
local function create_panorama(storage, image_table, extra_data) --finalize
if not df.check_if_bin_exists("hugin") then
dt.print_error(_("hugin not found"))
return
end
-- Since Hugin 2015.0.0 hugin provides a command line tool to start the assistant
-- http://wiki.panotools.org/Hugin_executor
-- We need pto_gen to create pto file for hugin_executor
-- http://hugin.sourceforge.net/docs/manual/Pto_gen.html
local hugin_executor = false
if (df.check_if_bin_exists("hugin_executor") and df.check_if_bin_exists("pto_gen")) then
hugin_executor = true
-- save the current log level and set log level to
-- log.error for normal operations
-- log.info for more insight about what is happening
-- log.debug for even more information
local saved_log_level = log.log_level()
log.log_level(log.error)
local hugin = df.check_if_bin_exists("hugin")
log.msg(log.info, "hugin set to ", hugin)
local hugin_executor = df.check_if_bin_exists("hugin_executor")
log.msg(log.info, "hugin_executor set to ", hugin_executor)
local pto_gen = df.check_if_bin_exists("pto_gen")
log.msg(log.info, "pto_gen set to ", pto_gen)
local gui_available = false
if hugin then
gui_available = true
else
dt.print(_("hugin is not found, did you set the path?"))
log.msg(log.error, "hugin executable not found. Check if the executable is installed.")
log.msg(log.error, "If the executable is installed, check that the path is set correctly.")
return
end
local cmd_line_available = false
if hugin_executor and pto_gen then
cmd_line_available = true
end
-- list of exported images
local img_list
local img_list = ""
local img_set = {}
-- reset and create image list
img_list = ""
for _,v in pairs(image_table) do
img_list = img_list ..v.. " "
for k,v in pairs(image_table) do
log.msg(log.debug, "k is ", k, " and v is ", v)
img_list = img_list .. PQ .. v .. PQ .. ' ' -- surround the filename with single quotes to handle spaces
table.insert(img_set, k)
end
dt.print(_("Will try to stitch now"))
log.msg(log.info, "img_list is ", img_list)
local huginStartCommand
if (hugin_executor) then
huginStartCommand = "pto_gen "..img_list.." -o "..dt.configuration.tmp_dir.."/project.pto"
dt.print(_("Creating pto file"))
dt.control.execute( huginStartCommand)
-- use first file as basename for output file
table.sort(img_set, function(a,b) return a.filename<b.filename end);
local first_file
for _, k in ipairs(img_set) do
first_file = k
break
end
dt.print(_("Running Assistent"))
huginStartCommand = "hugin_executor --assistant "..dt.configuration.tmp_dir.."/project.pto"
dt.control.execute( huginStartCommand)
if first_file == nil then
dt.print(_("no file selected"))
return
end
huginStartCommand = "hugin "..dt.configuration.tmp_dir.."/project.pto"
local pto_path = dt.configuration.tmp_dir..'/project.pto'
log.msg(log.info, "pto_path is ", pto_path)
local filepath = df.split_filepath(first_file.filename)
log.msg(log.info, "filepath is ", filepath)
local tmp_filename = filepath['basename'].."_pano.tif"
log.msg(log.info, "tmp_filename is ", tmp_filename)
-- some versions of hugin_executor don't seem to output the result
-- to the --prefix location, so assume we are working in the tmp
-- directory and then move the file to the original file location afterwards
local src_path = dt.configuration.tmp_dir.."/"..tmp_filename
log.msg(log.info, "src_path is ", src_path)
local dst_path = first_file.path..'/'..tmp_filename
log.msg(log.info, "dst_path is ", dst_path)
if df.check_if_file_exists(dst_path) then
dst_path = df.create_unique_filename(dst_path)
log.msg(log.info, "dst_path updated to ", dts_path)
end
dt.print(_("will try to stitch now"))
local huginStartCommand = nil
if (cmd_line_available and not user_prefer_gui) then
log.msg(log.info, "using the command line tools to create panorama")
huginStartCommand = pto_gen.." "..img_list.." -o "..pto_path
dt.print(_("creating pto file"))
log.msg(log.info, "pto creation command is ", huginStartCommand)
dtsys.external_command(huginStartCommand)
dt.print(_("running assistant"))
huginStartCommand = hugin_executor.." --assistant "..pto_path
dtsys.external_command(huginStartCommand)
huginStartCommand = hugin_executor..' --stitching --prefix=' .. "'" .. src_path .. "'" .. ' ' .. pto_path
log.msg(log.info, "command line huginStartCommand is ", huginStartCommand)
elseif gui_available then
if (user_prefer_gui) then
dt.print(_("launching hugin"))
else
huginStartCommand = "hugin "..img_list
dt.print(_("unable to find command line tools, launching hugin"))
end
-- the gui produces a differnt output filename than the command line
src_path = dt.configuration.tmp_dir .. "/" .. df.get_basename(img_set[1].filename) .. " - " .. df.get_basename(img_set[#img_set].filename) .. ".tif"
log.msg(log.info, "set src_path to ", src_path)
huginStartCommand = hugin..' '..img_list
log.msg(log.info, "gui huginStartCommand is ", huginStartCommand)
else
dt.print(_("hugin isn't available."))
end
dt.print_error(huginStartCommand)
if not dt.control.execute(huginStartCommand)
then
dt.print(_("Command hugin failed ..."))
if not (huginStartCommand==nil) then
if not dtsys.external_command(huginStartCommand) then
dt.print(_("hugin failed ..."))
log.msg(log.error, huginStartCommand, " failed")
else
if df.check_if_file_exists(src_path) then
log.msg(log.debug, "found ", src_path, " importing to ", dst_path)
df.file_move(src_path, dst_path)
dt.print(string.format(_("importing file %s"), dst_path))
dt.database.import(dst_path)
end
end
log.log_level(saved_log_level)
end
-- cleanup the temp files
for k,v in pairs(image_table) do
os.remove(v)
end
end
local function destroy()
dt.destroy_storage(namespace)
end
-- Register
dt.register_storage("module_hugin", _("Hugin Panorama"), show_status, create_panorama)
if dt.configuration.running_os ~= "linux" then
exec_widget = df.executable_path_widget(executable_table)
end
hugin_widget = dt.new_widget("box") {
orientation = "vertical",
dt.new_widget("check_button")
{
label = _("launch hugin gui"),
value = user_prefer_gui,
tooltip = _('launch hugin in gui mode'),
clicked_callback = user_preference_changed
},
exec_widget
}
dt.register_storage(namespace, _("hugin panorama"), show_status, create_panorama, nil, nil, hugin_widget)
script_data.destroy = destroy
return script_data
--
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua

607
contrib/image_stack.lua Normal file
View File

@@ -0,0 +1,607 @@
--[[
image_stack.lua - process a stack of images
Copyright (C) 2018 Bill Ferguson <wpferguson@gmail.com>.
Copyright (C) 2016,2017 Holger Klemm
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
]]
--[[
image_stack - export a stack of images and process them, returning the result
This script provides another storage (export target) for darktable. Selected
images are exported in the specified format to temporary storage. The images are aligned
if the user requests it. When the images are ready, imagemagick is launched and uses
the selected evaluate-sequence operator to process the images. The output file is written
to a filename representing the imput files in the format specified by the user. The resulting
image is imported into the film roll. The source images can be tagged as part of the file
creation so that a user can later find the contributing images.
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
* align_image_stack - http://www.hugin.org
* imagemagick - http://www.imagemagick.org
USAGE
* require this script from your main lua file
* select the images to process with image_stack
* in the export dialog select "image stack" and select the format and bit depth for the
exported image
* Select whether the images need to be aligned.
* Select the stack operator
* Select the output format
* Select whether to tag the source images used to create the resulting file
* Specify executable locations if necessary
* Press "export"
* The resulting image will be imported
NOTES
Mean is a fairly quick operation. On my machine (i7-6800K, 16G) it takes a few seconds. Median, on the other hand
takes approximately 10x longer to complete. Processing 10 and 12 image stacks took over a minute. I didn't test all
the other functions, but the ones I did fell between Mean and Median performance wise.
BUGS, COMMENTS, SUGGESTIONS
* Send to Bill Ferguson, wpferguson@gmail.com
CHANGES
THANKS
* Thanks to Pat David and his blog entry on blending images, https://patdavid.net/2013/05/noise-removal-in-photos-with-median_6.html
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
local job = nil
-- path separator constant
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
-- works with LUA API version 5.0.0
du.check_min_api_version("7.0.0", "image_stack")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("image stack"),
purpose = _("process a stack of images"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/image_stack"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- GUI definitions
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
local label_align_options= dt.new_widget("section_label"){
label = _('image align options')
}
local label_image_stack_options = dt.new_widget("section_label"){
label = _("image stack options")
}
local label_executable_locations = dt.new_widget("section_label"){
label = _("executable locations")
}
if not(dt.preferences.read("align_image_stack", "initialized", "bool")) then
dt.preferences.write("align_image_stack", "def_radial_distortion", "bool", false)
dt.preferences.write("align_image_stack", "def_optimize_field", "bool", false)
dt.preferences.write("align_image_stack", "def_optimize_image_center", "bool", true)
dt.preferences.write("align_image_stack", "def_auto_crop", "bool", true)
dt.preferences.write("align_image_stack", "def_distortion", "bool", true)
dt.preferences.write("align_image_stack", "def_grid_size", "integer", 5)
dt.preferences.write("align_image_stack", "def_control_points", "integer", 8)
dt.preferences.write("align_image_stack", "def_control_points_remove", "integer", 3)
dt.preferences.write("align_image_stack", "def_correlation", "integer", 9)
dt.preferences.write("align_image_stack", "initialized", "bool", true)
end
if not(dt.preferences.read("image_stack", "initialized", "bool")) then
dt.preferences.write("image_stack", "align_images", "bool", true)
dt.preferences.write("image_stack", "stack_function", "integer", 2)
dt.preferences.write("image_stack", "output_format", "integer", 6)
dt.preferences.write("image_stack", "tag_images", "bool", true)
dt.preferences.write("image_stack", "initialized", "bool", true)
end
local chkbtn_will_align = dt.new_widget("check_button"){
label = _('perform image alignment'),
value = dt.preferences.read("image_stack", "align_images", "bool"),
tooltip = _('align the image stack before processing')
}
local chkbtn_radial_distortion = dt.new_widget("check_button"){
label = _('optimize radial distortion for all images'),
value = dt.preferences.read("align_image_stack", "def_radial_distortion", "bool"),
tooltip = _('optimize radial distortion for all images, \nexcept the first'),
}
local chkbtn_optimize_field = dt.new_widget("check_button"){
label = _('optimize field of view for all images'),
value = dt.preferences.read("align_image_stack", "def_optimize_field", "bool"),
tooltip =_('optimize field of view for all images, except the first. \nUseful for aligning focus stacks (DFF) with slightly \ndifferent magnification.'),
}
local chkbtn_optimize_image_center = dt.new_widget("check_button"){
label = _('optimize image center shift for all images'),
value = dt.preferences.read("align_image_stack", "def_optimize_image_center", "bool"),
tooltip =_('optimize image center shift for all images, \nexcept the first.'),
}
local chkbtn_auto_crop = dt.new_widget("check_button"){
label = _('auto crop the image'),
value = dt.preferences.read("align_image_stack", "def_auto_crop", "bool"),
tooltip =_('auto crop the image to the area covered by all images.'),
}
local chkbtn_distortion = dt.new_widget("check_button"){
label = _('load distortion from lens database'),
value = dt.preferences.read("align_image_stack", "def_distortion", "bool"),
tooltip =_('try to load distortion information from lens database'),
}
local cmbx_grid_size = dt.new_widget("combobox"){
label = _('image grid size'),
tooltip =_('break image into a rectangular grid \nand attempt to find num control points in each section.\ndefault: (5x5)'),
value = dt.preferences.read("align_image_stack", "def_grid_size", "integer"), --5
"1", "2", "3","4","5","6","7","8","9",
reset_callback = function(self)
self.value = dt.preferences.read("align_image_stack", "def_grid_size", "integer")
end
}
local cmbx_control_points = dt.new_widget("combobox"){
label = _('control points/grid'),
tooltip =_('number of control points (per grid, see option -g) \nto create between adjacent images \ndefault: (8).'),
value = dt.preferences.read("align_image_stack", "def_control_points", "integer"), --8, "1", "2", "3","4","5","6","7","8","9",
"1", "2", "3","4","5","6","7","8","9",
reset_callback = function(self)
self.value = dt.preferences.read("align_image_stack", "def_control_points", "integer")
end
}
local cmbx_control_points_remove = dt.new_widget("combobox"){
label = _('remove control points with error'),
tooltip =_('remove all control points with an error higher \nthan num pixels \ndefault: (3)'),
value = dt.preferences.read("align_image_stack", "def_control_points_remove", "integer"), --3, "1", "2", "3","4","5","6","7","8","9",
"1", "2", "3","4","5","6","7","8","9",
reset_callback = function(self)
self.value = dt.preferences.read("align_image_stack", "def_control_points_remove", "integer")
end
}
local cmbx_correlation = dt.new_widget("combobox"){
label = _('correlation threshold for control points'),
tooltip =_('correlation threshold for identifying \ncontrol points \ndefault: (0.9).'),
value = dt.preferences.read("align_image_stack", "def_correlation", "integer"), --9, "0,1", "0,2", "0,3","0,4","0,5","0,6","0,7","0,8","0,9",
"0.1", "0.2", "0.3","0.4","0.5","0.6","0.7","0.8","0.9","1.0",
reset_callback = function(self)
self.value = dt.preferences.read("align_image_stack", "def_correlation", "integer")
end
}
local cmbx_stack_function = dt.new_widget("combobox"){
label = _("select stack function"),
tooltip = _("select function to be \napplied to image stack"),
value = dt.preferences.read("image_stack", "stack_function", "integer"), "Mean", "Median", "Abs", "Add", "And", "Divide", "Max", "Min",
"Or", "Subtract", "Sum", "Xor",
reset_callback = function(self)
self.value = dt.preferences.read("image_stack", "stack_function", "integer")
end
}
local cmbx_output_format = dt.new_widget("combobox"){
label = _("select output format"),
tooltip = _("choose the format for the resulting image"),
value = dt.preferences.read("image_stack", "output_format", "integer"), "EXR", "JPG", "PNG", "PNM", "PPM", "TIF",
reset_callback = function(self)
self.value = dt.preferences.read("image_stack", "output_format", "integer")
end
}
local chkbtn_tag_source_file = dt.new_widget("check_button"){
label = _("tag source images used?"),
value = dt.preferences.read("image_stack", "tag_images", "bool"),
tooltip = _("tag the source images used to create the output file?")
}
local image_stack_widget = dt.new_widget("box"){
orientation = "vertical",
label_align_options,
chkbtn_will_align,
chkbtn_radial_distortion,
chkbtn_optimize_field,
chkbtn_optimize_image_center,
chkbtn_auto_crop,
chkbtn_distortion,
cmbx_grid_size,
cmbx_control_points,
cmbx_control_points_remove,
cmbx_correlation,
dt.new_widget("separator"){},
dt.new_widget("separator"){},
label_image_stack_options,
cmbx_stack_function,
cmbx_output_format,
chkbtn_tag_source_file,
}
local executables = {"align_image_stack", "convert"}
if dt.configuration.running_os ~= "linux" then
image_stack_widget[#image_stack_widget + 1] = df.executable_path_widget(executables)
end
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- local functions
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
local function show_status(storage, image, format, filename, number, total, high_quality, extra_data)
dt.print(string.format(_("export image %i/%i"), number, total))
end
-- read the gui and populate the align_image_stack arguments
local function get_align_image_stack_arguments()
--Setup Align Image Stack Arguments--
local align_args = ""
if (chkbtn_radial_distortion.value) then align_args = align_args .. " -d" end
if (chkbtn_optimize_field.value) then align_args = align_args .. " -m" end
if (chkbtn_optimize_image_center.value) then align_args = align_args .. " -i" end
if (chkbtn_auto_crop.value) then align_args = align_args .. " -C" end
if (chkbtn_distortion.value) then align_args = align_args .. " --distortion" end
dt.preferences.write("align_image_stack", "def_radial_distortion", "bool", chkbtn_radial_distortion.value)
dt.preferences.write("align_image_stack", "def_optimize_field", "bool", chkbtn_optimize_field.value)
dt.preferences.write("align_image_stack", "def_optimize_image_center", "bool", chkbtn_optimize_image_center.value)
dt.preferences.write("align_image_stack", "def_auto_crop", "bool", chkbtn_auto_crop.value)
dt.preferences.write("align_image_stack", "def_distortion", "bool", chkbtn_distortion.value)
align_args = align_args.." -g "..cmbx_grid_size.value
align_args = align_args.." -c "..cmbx_control_points.value
align_args = align_args.." -t "..cmbx_control_points_remove.value
align_args = align_args.." --corr="..cmbx_correlation.value
dt.preferences.write("align_image_stack", "def_grid_size", "integer", cmbx_grid_size.selected)
dt.preferences.write("align_image_stack", "def_control_points", "integer", cmbx_control_points.selected)
dt.preferences.write("align_image_stack", "def_control_points_remove", "integer", cmbx_control_points_remove.selected)
dt.preferences.write("align_image_stack", "def_correlation", "integer", cmbx_correlation.selected)
if (dt.preferences.read("align_image_stack", "align_use_gpu", "bool")) then align_args = align_args .. " --gpu" end
align_args = align_args .. " -a " .. dt.configuration.tmp_dir .. "/aligned_ "
return align_args
end
-- extract, and sanitize, an image list from the supplied image table
local function extract_image_list(image_table)
local img_list = ""
local result = {}
for img,expimg in pairs(image_table) do
table.insert(result, expimg)
end
table.sort(result)
for _,exp_img in ipairs(result) do
img_list = img_list .. " " .. df.sanitize_filename(exp_img)
end
return img_list, #result
end
-- don't leave files laying around the operating system
local function cleanup(img_list)
dt.print_log("image list is " .. img_list)
files = du.split(img_list, " ")
for _,f in ipairs(files) do
f = string.gsub(f, '[\'\"]', "")
os.remove(f)
end
end
-- List files based on a search pattern. This is cross platform compatible
-- but the windows version is recursive in order to get ls type listings.
-- Normally this shouldn't be a problem, but if you use this code just beware.
-- If you want to do it non recursively, then remove the /s argument from dir
-- and grab the path component from the search string and prepend it to the files
-- found.
local function list_files(search_string)
local ls = "ls "
local files = {}
local dir_path = nil
local count = 1
if dt.configuration.running_os == "windows" then
ls = "dir /b/s "
search_string = string.gsub(search_string, "/", "\\\\")
end
local f = io.popen(ls .. search_string)
if f then
local found_file = f:read()
while found_file do
files[count] = found_file
count = count + 1
found_file = f:read()
end
f:close()
end
return files
end
-- create a filename from a multi image set. The image list is sorted, then
-- combined with first and last if more than 3 images or a - separated list
-- if three images or less.
local function make_output_filename(image_table)
local images = {}
local cnt = 1
local max_distinct_names = 3
local name_separator = "-"
local outputFileName = nil
local result = {}
for img,expimg in pairs(image_table) do
table.insert(result, expimg)
end
table.sort(result)
for _,img in pairs(result) do
images[cnt] = df.get_basename(img)
cnt = cnt + 1
end
cnt = cnt - 1
if cnt > 1 then
if cnt > max_distinct_names then
-- take the first and last
outputFileName = images[1] .. name_separator .. images[cnt]
else
-- join them
outputFileName = du.join(images, name_separator)
end
else
-- return the single name
outputFileName = images[cnt]
end
return outputFileName
end
-- get the path where the collection is stored
local function extract_collection_path(image_table)
local collection_path = nil
for i,_ in pairs(image_table) do
collection_path = i.path
break
end
return collection_path
end
-- copy an images database attributes to another image. This only
-- copies what the database knows, not the actual exif data in the
-- image itself.
local function copy_image_attributes(from, to, ...)
local args = {...}
if #args == 0 then
args[1] = "all"
end
if args[1] == "all" then
args[1] = "rating"
args[2] = "colors"
args[3] = "exif"
args[4] = "meta"
args[5] = "GPS"
end
for _,arg in ipairs(args) do
if arg == "rating" then
to.rating = from.rating
elseif arg == "colors" then
to.red = from.red
to.blue = from.blue
to.green = from.green
to.yellow = from.yellow
to.purple = from.purple
elseif arg == "exif" then
to.exif_maker = from.exif_maker
to.exif_model = from.exif_model
to.exif_lens = from.exif_lens
to.exif_aperture = from.exif_aperture
to.exif_exposure = from.exif_exposure
to.exif_focal_length = from.exif_focal_length
to.exif_iso = from.exif_iso
to.exif_datetime_taken = from.exif_datetime_taken
to.exif_focus_distance = from.exif_focus_distance
to.exif_crop = from.exif_crop
elseif arg == "GPS" then
to.elevation = from.elevation
to.longitude = from.longitude
to.latitude = from.latitude
elseif arg == "meta" then
to.publisher = from.publisher
to.title = from.title
to.creator = from.creator
to.rights = from.rights
to.description = from.description
else
dt.print_error("Unrecognized option to copy_image_attributes: " .. arg)
end
end
end
local function stop_job()
job.valid = false
end
local function destroy()
dt.destroy_storage("module_image_stack")
end
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- main program
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
local function image_stack(storage, image_table, extra_data)
local will_align = chkbtn_will_align.value
local img_list, image_count = extract_image_list(image_table)
local tmp_dir = dt.configuration.tmp_dir .. PS
local stack_function = cmbx_stack_function.value
local output_format = cmbx_output_format.value
local tag_source = chkbtn_tag_source_file.value
local tasks = 3
if will_align then
tasks = tasks + 1
end
if tag_source then
tasks = tasks + 1
end
local percent_step = 1 / tasks
-- update preferences
dt.preferences.write("image_stack", "align_images", "bool", will_align)
dt.preferences.write("image_stack", "stack_function", "integer", cmbx_stack_function.selected)
dt.preferences.write("image_stack", "output_format", "integer", cmbx_output_format.selected)
if image_count < 2 then
dt.print(_("ERROR: at least 2 images required for image stacking, exiting..."))
dt.print_error(image_count .. " image(s) selected, at least 2 required")
return
end
job = dt.gui.create_job(_("image stack"), true, stop_job)
job.percent = job.percent + percent_step
-- align images if requested
if will_align then
local align_image_stack_executable = df.check_if_bin_exists("align_image_stack")
if align_image_stack_executable then
local align_args = get_align_image_stack_arguments()
local align_image_stack_command = align_image_stack_executable .. align_args .. " " .. img_list
dt.print_log(align_image_stack_command)
dt.print(_("aligning images..."))
local result = dtsys.external_command(align_image_stack_command)
if result == 0 then
dt.print(_("images aligned"))
local files = list_files(tmp_dir .. "aligned_*")
cleanup(img_list)
img_list = extract_image_list(files)
job.percent = job.percent + percent_step
else
dt.print(_("ERROR: image alignment failed"))
dt.print_error("image alignment failed")
cleanup(img_list)
return
end
else
dt.print(_("ERROR: align_image_stack not found"))
dt.print_error("align_image_stack not found")
cleanup(img_list)
return
end
end
-- stack images
local output_filename = tmp_dir .. make_output_filename(image_table) .. "." .. string.lower(output_format)
local convert_arguments = img_list .. " -evaluate-sequence " .. stack_function .. " " .. df.sanitize_filename(output_filename)
local convert_executable = df.check_if_bin_exists("convert")
-- tif images exported from darktable have private tiff tags embedded in them and convert complains about them
local ignore_tif_tags = " -quiet -define tiff:ignore-tags=40965,42032,42033,42034,42036,18246,18249,36867,34864,34866 "
if convert_executable then
local convert_command = convert_executable .. ignore_tif_tags .. convert_arguments
dt.print_log("convert command is " .. convert_command)
dt.print(_("processing image stack"))
local result = dtsys.external_command(convert_command)
if result == 0 then
dt.print(_("image stack processed"))
cleanup(img_list)
job.percent = job.percent + percent_step
-- import image
dt.print(_("importing result"))
local film_roll_path = extract_collection_path(image_table)
local import_filename = df.create_unique_filename(film_roll_path .. PS .. df.get_filename(output_filename))
df.file_move(output_filename, import_filename)
imported_image = dt.database.import(import_filename)
local created_tag = dt.tags.create(_("created with|image_stack"))
dt.tags.attach(created_tag, imported_image)
-- all the images are the same except for time, so just copy the attributes
-- from the first
for img,_ in pairs(image_table) do
copy_image_attributes(img, imported_image)
break
end
job.percent = job.percent + percent_step
-- tag images if requested
if tag_source then
dt.print(_("tagging source images"))
local source_tag = dt.tags.create(_("source file|" .. imported_image.filename))
for img, _ in pairs(image_table) do
dt.tags.attach(source_tag, img)
end
job.percent = job.percent + percent_step
end
else
dt.print(_("ERROR: image stack processing failed"))
cleanup(img_list)
end
else
dt.print(_("ERROR: convert executable not found"))
dt.print_error("convert executable not found")
cleanup(img_list)
end
job.valid = false
end
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- darktable integration
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dt.preferences.register("align_image_stack", "align_use_gpu", -- name
"bool", -- type
_('align image stack: use GPU for remapping'), -- label
_('set the GPU remapping for image align'), -- tooltip
false)
dt.register_storage("module_image_stack", _("image stack"), show_status, image_stack, nil, nil, image_stack_widget)
script_data.destroy = destroy
return script_data

592
contrib/image_time.lua Normal file
View File

@@ -0,0 +1,592 @@
--[[
image_time.lua - synchronize image time for images shot with different cameras
Copyright (C) 2019, 2020 Bill Ferguson <wpferguson@gmail.com>.
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
]]
--[[
image_time - non-destructively modify the image time
DESCRIPTION
image_time non destructively adjusts image times by modifying the
database image exif_datetime_taken field. There are 4 modes: adjust time,
set time, synchronize time, and reset time.
ADJUST TIME
adjust time mode lets you chose an offset in terms of years, months,
days, hours, minutes, and seconds. The adjustment can be added or
subtracted.
WARNING: When adding and subtracting months the result will usually
be what is expected unless the time being adjusted is at the end of
the month. This is because a month is a variable amount of time that
can be 28, 29, 30 or 31 days depending on the month. Example: It's
March 31st and I subtract a month which not sets the time to February
31st. When that gets set to a valid time, then the date changes to
March 3rd.
SET TIME
set time mode allows you to pick a date and time and set the image
time accordingly. Fields may be left out. This is useful when
importing scanned images that don't have an embedded date.
SYNCHRONIZE TIME
I recently purchased a 7DmkII to replace my aging 7D. My 7D was still
serviceable, so I bought a remote control and figured I'd try shooting
events from 2 different perspectives. I didn't think to synchonize the
time between the 2 cameras, so when I loaded the images and sorted by
time it was a disaster. I hacked a script together with hard coded values
to adjust the exif_datetime_taken value in the database for the 7D images
so that everything sorted properly. I've tried shooting with 2 cameras
several times since that first attempt. I've gotten better at getting the
camera times close, but still haven't managed to get them to sync. So I
decided to think the problem through and write a proper script to take
care of the problem.
RESET TIME
Select the images and click reset.
USAGE
ADJUST TIME
Change the year, month, day, hour, minute, second dropdowns to the amount
of change desired. Select add or subtract. Select the images. Click
adjust.
SET TIME
Set the time fields to the desired time. Select the images to change. Click
set.
SYNCHRONIZE TIME
Select 2 images, one from each camera, of the same moment in time. Click
the Calculate button to calculate the time difference. The difference is
displayed in the difference entry. You can manually adjust it by changing
the value if necessary.
Select the images that need their time adjusted. Determine which way to adjust
adjust the time (add or subtract) and select the appropriate choice.
If the image times get messed up and you just want to start over, select reset time
from the mode and reset the image times.
RESET TIME
Select the images and click reset.
ADDITIONAL SOFTWARE REQUIRED
* exiv2
BUGS, COMMENTS, SUGGESTIONS
* Send to Bill Ferguson, wpferguson@gmail.com
CHANGES
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local ds = require "lib/dtutils.string"
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext.gettext
local img_time = {}
img_time.module_installed = false
img_time.event_registered = false
du.check_min_api_version("7.0.0", "image_time")
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("image time"),
purpose = _("synchronize image time for images shot with different cameras or adjust or set image time"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/image_time"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local PS = dt.configuration.runnin_os == "windows" and "\\" or "/"
local ERROR = -1
-- function to convert from exif time to system time
local function exiftime2systime(exiftime)
local yr,mo,dy,h,m,s = string.match(exiftime, "(%d-):(%d-):(%d-) (%d-):(%d-):(%d+)")
return(os.time{year=yr, month=mo, day=dy, hour=h, min=m, sec=s})
end
-- function to convert from systime to exif time
local function systime2exiftime(systime)
local t = os.date("*t", systime)
return(string.format("%4d:%02d:%02d %02d:%02d:%02d", t.year, t.month, t.day, t.hour, t.min, t.sec))
end
local function vars2exiftime(year, month, day, hour, min, sec)
local y = tonumber(year) and string.format("%4d", year) or "0000"
local mo = tonumber(month) and string.format("%02d", month) or "00"
local d = tonumber(day) and string.format("%02d", day) or "00"
local h = tonumber(hour) and string.format("%02d", hour) or "00"
local m = tonumber(min) and string.format("%02d", min) or "00"
local s = tonumber(sec) and string.format("%02d", sec) or "00"
return(y .. ":" .. mo .. ":" .. d .. " " .. h .. ":" .. m .. ":" .. s)
end
local function exiftime2vars(exiftime)
return string.match(exiftime, "(%d+):(%d+):(%d+) (%d+):(%d+):(%d+)")
end
local function calc_time_difference(image1, image2)
return math.abs(exiftime2systime(image1.exif_datetime_taken) - exiftime2systime(image2.exif_datetime_taken))
end
local function adjust_image_time(image, difference)
image.exif_datetime_taken = systime2exiftime(exiftime2systime(image.exif_datetime_taken) + difference)
return
end
local function calculate_difference(images)
if #images == 2 then
img_time.diff_entry.text = calc_time_difference(images[1], images[2])
img_time.btn.sensitive = true
else
dt.print(_("ERROR: 2 images must be selected"))
end
end
local function synchronize_times(images, difference)
for _, image in ipairs(images) do
adjust_image_time(image, difference)
end
end
local function synchronize_time(images)
local sign = 1
if img_time.sdir.value == _("subtract") then
sign = -1
end
synchronize_times(images, tonumber(img_time.diff_entry.text) * sign)
end
local function add_time(images)
synchronize_times(images, tonumber(img_time.diff_entry.text))
end
local function year_month2months(year, month)
year_months = tonumber(year) and year * 12 or 0
local months = tonumber(month) and tonumber(month) or 0
return year_months + months
end
local function months2year_month(months)
local year = math.floor(months / 12)
local month = months - (year * 12)
return year, month
end
local function get_image_taken_time(image)
-- get original image time
local datetime = nil
local exiv2 = df.check_if_bin_exists("exiv2")
if exiv2 then
p = io.popen(exiv2 .. " -K Exif.Image.DateTime " .. df.sanitize_filename(image.path .. PS .. image.filename))
if p then
for line in p:lines() do
if string.match(line, "Exif.Image.DateTime") then
datetime = string.match(line, "(%d-:%d-:%d- %d-:%d-:%d+)")
end
end
p:close()
end
else
dt.print(_("unable to detect exiv2"))
datetime = ERROR
end
return datetime
end
local function _get_windows_image_file_creation_time(image)
local datetime = nil
local p = io.popen("dir " .. image.path .. PS .. image.filename)
if p then
for line in p:lines() do
if string.match(line, ds.sanitize_lua(image.filename)) then
local mo, day, yr, hr, min, apm = string.match(line, "(%d+)/(%d+)/(%d+) (%d-):(%d+) (%S+)")
if apm == "PM" then
hr = hr + 12
end
datetime = vars2exiftime(yr, mo, day, hr, min, 0)
end
end
p:close()
else
dt.print(string.format(_("unable to get information for %s"), image.filename))
datetime = ERROR
end
return datetime
end
local function _get_nix_image_file_creation_time(image)
local datetime = nil
local p = io.popen("ls -lL --time-style=full-iso " .. df.sanitize_filename(image.path .. PS .. image.filename))
if p then
for line in p:lines() do
if string.match(line, ds.sanitize_lua(image.filename)) then
datetime = vars2exiftime(string.match(line, "(%d+)%-(%d-)%-(%d-) (%d-):(%d-):(%d+)."))
end
end
p:close()
else
dt.print(string.format(_("unable to get information for %s"), image.filename))
datetime = ERROR
end
return datetime
end
local function get_image_file_creation_time(image)
-- no exif time in the image file so get the creation time
local datetime = nil
if dt.configuration.running_os == "windows" then
datetime = _get_windows_image_file_creation_time(image)
else
datetime = _get_nix_image_file_creation_time(image)
end
return datetime
end
local function get_original_image_time(image)
local image_time = image.exif_datetime_taken
local reset_time = nil
reset_time = get_image_taken_time(image)
if reset_time then
if reset_time == ERROR then
return image_time
else
return reset_time
end
else
reset_time = get_image_file_creation_time(image)
if reset_time then
if reset_time == ERROR then
return image_time
else
return reset_time
end
end
end
end
local function reset_time(images)
if #images > 0 then
for _, image in ipairs(images) do
image.exif_datetime_taken = get_original_image_time(image)
end
else
dt.print_error("reset time: no images selected")
dt.print(_("please select the images that need their time reset"))
end
end
local function adjust_time(images)
local SEC_MIN = 60
local SEC_HR = SEC_MIN * 60
local SEC_DY = SEC_HR * 24
local offset = nil
local sign = 1
if #images < 1 then
dt.print(_("please select some images and try again"))
return
end
if img_time.adir.value == _("subtract") then
sign = -1
end
for _, image in ipairs(images) do
local y, mo, d, h, m, s = exiftime2vars(image.exif_datetime_taken)
local image_months = year_month2months(y, mo)
local months_diff = year_month2months(img_time.ayr.value, img_time.amo.value)
y, mo = months2year_month(image_months + (months_diff * sign))
local exif_new = vars2exiftime(y, mo, d, h, m, s)
offset = img_time.ady.value * SEC_DY
offset = offset + img_time.ahr.value * SEC_HR
offset = offset + img_time.amn.value * SEC_MIN
offset = offset + img_time.asc.value
offset = offset * sign
image.exif_datetime_taken = systime2exiftime(exiftime2systime(exif_new) + offset)
end
end
local function set_time(images)
if #images < 1 then
dt.print(_("please select some images and try again"))
return
end
local y = img_time.syr.value
local mo = img_time.smo.value
local d = img_time.sdy.value
local h = img_time.shr.value
local m = img_time.smn.value
local s = img_time.ssc.value
for _, image in ipairs(images) do
image.exif_datetime_taken = vars2exiftime(y, mo, d, h, m, s)
end
end
local function seq(first, last)
local result = {}
local num = first
while num <= last do
table.insert(result, num)
num = num + 1
end
return table.unpack(result)
end
local function reset_widgets()
dt.print_log("took the reset function")
img_time.ayr.selected = 1
img_time.amo.selected = 1
img_time.ady.selected = 1
img_time.ahr.selected = 1
img_time.ayr.selected = 1
img_time.amn.selected = 1
img_time.asc.selected = 1
img_time.adir.selected = 1
img_time.syr.selected = #img_time.syr
img_time.smo.selected = 1
img_time.sdy.selected = 1
img_time.shr.selected = 1
img_time.smn.selected = 1
img_time.ssc.selected = 1
img_time.adir.selected = 1
end
local function install_module()
if not img_time.module_installed then
dt.register_lib(
"image_time", -- Module name
_("image time"), -- Visible name
true, -- expandable
true, -- resetable
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers
img_time.widget,
nil,-- view_enter
nil -- view_leave
)
img_time.module_installed = true
end
end
local function destroy()
dt.gui.libs["image_time"].visible = false
end
local function restart()
dt.gui.libs["image_time"].visible = true
end
-- widgets
img_time.widgets = {
-- name, type, tooltip, placeholder,
{"ayr", "combobox", _("years"), _("years to adjust by, 0 - ?"), {seq(0,20)}, 1},
{"amo", "combobox", _("months"), _("months to adjust by, 0-12"), {seq(0,12)}, 1},
{"ady", "combobox", _("days"), _("days to adjust by, 0-31"), {seq(0,31)}, 1},
{"ahr", "combobox", _("hours"), _("hours to adjust by, 0-23"), {seq(0,23)}, 1},
{"amn", "combobox", _("minutes"), _("minutes to adjust by, 0-59"), {seq(0,59)}, 1},
{"asc", "combobox", _("seconds"), _("seconds to adjust by, 0-59"), {seq(0,59)}, 1},
{"adir", "combobox", _("add/subtract"), _("add or subtract time"), {_("add"), _("subtract")}, 1},
{"syr", "combobox", _("year"), _("year to set, 1900 - now"), {" ", seq(1900,os.date("*t", os.time()).year)}, 1},
{"smo", "combobox", _("month"), _("month to set, 1-12"), {" ", seq(1,12)}, 1},
{"sdy", "combobox", _("day"), _("day to set, 1-31"), {" ", seq(1,31)}, 1},
{"shr", "combobox", _("hour"), _("hour to set, 0-23"), {" ", seq(0,23)}, 1},
{"smn", "combobox", _("minute"), _("minutes to set, 0-59"), {" ", seq(0, 59)}, 1},
{"ssc", "combobox", _("seconds"), _("seconds to set, 0-59"), {" ", seq(0,59)}, 1},
{"sdir", "combobox", _("add/subtract"), _("add or subtract time"), {_("add"), _("subtract")}, 1},
}
for _, widget in ipairs(img_time.widgets) do
img_time[widget[1]] = dt.new_widget(widget[2]){
label = widget[3],
tooltip = widget[4],
selected = widget[6],
table.unpack(widget[5])
}
end
img_time.syr.selected = #img_time.syr
img_time.diff_entry = dt.new_widget("entry"){
tooltip = _("time difference between images in seconds"),
placeholder = _("select 2 images and use the calculate button"),
text = "",
}
img_time.calc_btn = dt.new_widget("button"){
label = _("calculate"),
tooltip = _("calculate time difference between 2 images"),
clicked_callback = function()
calculate_difference(dt.gui.action_images)
end
}
img_time.btn = dt.new_widget("button"){
label = _("synchronize image times"),
tooltip = _("apply the time difference from selected images"),
sensitive = false,
clicked_callback = function()
synchronize_time(dt.gui.action_images)
end
}
img_time.stack = dt.new_widget("stack"){
dt.new_widget("box"){
orientation = "vertical",
dt.new_widget("label"){label = _("adjust time")},
dt.new_widget("section_label"){label = _("days, months, years")},
img_time.ady,
img_time.amo,
img_time.ayr,
dt.new_widget("section_label"){label = _("hours, minutes, seconds")},
img_time.ahr,
img_time.amn,
img_time.asc,
dt.new_widget("section_label"){label = _("adjustment direction")},
img_time.adir,
dt.new_widget("button"){
label = _("adjust"),
clicked_callback = function()
adjust_time(dt.gui.action_images)
end
}
},
dt.new_widget("box"){
orientation = "vertical",
dt.new_widget("label"){label = _("set time")},
dt.new_widget("section_label"){label = _("date:")},
img_time.sdy,
img_time.smo,
img_time.syr,
dt.new_widget("section_label"){label = _("time:")},
img_time.shr,
img_time.smn,
img_time.ssc,
dt.new_widget("button"){
label = _("set"),
clicked_callback = function()
set_time(dt.gui.action_images)
end
}
},
dt.new_widget("box"){
orientation = "vertical",
dt.new_widget("label"){label = _("synchronize image time")},
dt.new_widget("section_label"){label = _("calculate difference between images")},
img_time.diff_entry,
img_time.calc_btn,
dt.new_widget("section_label"){label = _("apply difference")},
img_time.sdir,
img_time.btn,
},
dt.new_widget("box"){
orientation = "vertical",
dt.new_widget("label"){label = _("reset to original time")},
dt.new_widget("separator"){},
dt.new_widget("button"){
label = _("reset"),
clicked_callback = function()
reset_time(dt.gui.action_images)
end
}
},
}
img_time.mode = dt.new_widget("combobox"){
label = _("mode"),
tooltip = _("select mode"),
selected = 1,
changed_callback = function(this)
img_time.stack.active = this.selected
end,
_("adjust time"),
_("set time"),
_("synchronize time"),
_("reset time")
}
img_time.widget = dt.new_widget("box"){
orientation = "vertical",
reset_callback = function(this)
reset_widgets()
end,
img_time.mode,
img_time.stack,
}
if dt.gui.current_view().id == "lighttable" then
install_module()
else
if not img_time.event_registered then
dt.register_event(
"image_time", "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
img_time.event_registered = true
end
end
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = restart
return script_data

View File

@@ -0,0 +1,200 @@
--[[
jpg_group_leader.lua - Make jpg image group leader
Copyright (C) 2024 Bill Ferguson <wpferguson@gmail.com>.
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
]]
--[[
jpg_group_leader - Make jpg image group leader
After a film roll is imported, check for RAW-JPG image groups
and make the JPG image the group leader. This is on by default
but can be disabled in preferences.
Shortcuts are included to filter existing collections or
selections of images and make the jpg the group leader.
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
None
USAGE
Start script from script_manager
Assign keys to the shortcuts
BUGS, COMMENTS, SUGGESTIONS
Bill Ferguson <wpferguson@gmail.com>
CHANGES
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- C O N S T A N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
local MODULE = "jpg_group_leader"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- A P I C H E C K
-- - - - - - - - - - - - - - - - - - - - - - - -
du.check_min_api_version("7.0.0", MODULE)
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- I 1 8 N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- S C R I P T M A N A G E R I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local script_data = {}
script_data.metadata = {
name = _("JPG group leader"),
purpose = _("make jpg image group leader"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/jpg_group_leader"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- - - - - - - - - - - - - - - - - - - - - - - -
-- P R E F E R E N C E S
-- - - - - - - - - - - - - - - - - - - - - - - -
dt.preferences.register(MODULE, "on_import", "bool", _("make jpg group leader on import"), _("automatically make the jpg file the group leader when raw + jpg are imported"), true)
-- - - - - - - - - - - - - - - - - - - - - - - -
-- N A M E S P A C E
-- - - - - - - - - - - - - - - - - - - - - - - -
local jgloi = {}
jgloi.images = {}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- F U N C T I O N S
-- - - - - - - - - - - - - - - - - - - - - - - -
local function toggle_global_toolbox_grouping()
dt.gui.libs.global_toolbox.grouping = false
dt.gui.libs.global_toolbox.grouping = true
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- M A I N P R O G R A M
-- - - - - - - - - - - - - - - - - - - - - - - -
local function make_jpg_group_leader(images)
-- if the image is part of a group, make it the leader
for _, image in ipairs(images) do
if #image:get_group_members() > 1 then
image:make_group_leader()
end
end
if dt.gui.libs.global_toolbox.grouping then
-- toggle the grouping to make the new leader show
toggle_global_toolbox_grouping()
end
end
local function make_existing_jpg_group_leader(images)
for _, image in ipairs(images) do
if string.lower(df.get_filetype(image.filename)) == "jpg" then
if #image:get_group_members() > 1 then
image:make_group_leader()
end
end
end
if dt.gui.libs.global_toolbox.grouping then
-- toggle the grouping to make the new leader show
toggle_global_toolbox_grouping()
end
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- D A R K T A B L E I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - -
local function destroy()
if dt.preferences.read(MODULE, "on_import", "bool") then
dt.destroy_event(MODULE, "post-import-film")
dt.destroy_event(MODULE, "post-import-image")
end
dt.destroy_event(MODULE .. "_collect", "shortcut")
dt.destroy_event(MODULE .. "_select", "shortcut")
end
script_data.destroy = destroy
-- - - - - - - - - - - - - - - - - - - - - - - -
-- E V E N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
if dt.preferences.read(MODULE, "on_import", "bool") then
dt.register_event(MODULE, "post-import-film",
function(event, film_roll)
-- ignore the film roll, it contains all the images, not just the imported
local images = jgloi.images
if #images > 0 then
jgloi.images = {}
make_jpg_group_leader(images)
end
end
)
dt.register_event(MODULE, "post-import-image",
function(event, image)
if string.lower(df.get_filetype(image.filename)) == "jpg" then
table.insert(jgloi.images, image)
end
end
)
end
dt.register_event(MODULE .. "_collect", "shortcut",
function(event, shortcut)
-- ignore the film roll, it contains all the images, not just the imported
local images = dt.collection
make_existing_jpg_group_leader(images)
end,
_("make jpg group leader for collection")
)
dt.register_event(MODULE .. "_select", "shortcut",
function(event, shortcut)
local images = dt.gui.selection()
make_existing_jpg_group_leader(images)
end,
_("make jpg group leader for selection")
)
return script_data

View File

@@ -1,7 +1,7 @@
--[[
This file is part of darktable,
Copyright 2016 by Tobias Jakobs.
Copyright 2016 by Erik Augustin.
Copyright 2018 by Tobias Jakobs.
Copyright 2018 by Erik Augustin.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,187 +20,106 @@
darktable KML export script
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
* mkdir
* zip (only if you create KMZ files)
* convert (ImageMagick)
* xdg-open
* xdg-user-dir
* zip (at the moment Linux only and only if you create KMZ files)
* magick (ImageMagick)
* xdg-user-dir (Linux)
WARNING
This script is only tested with Linux
USAGE
* require script "official/yield" from your main Lua file in the first line
* require this script from your main Lua file
* when choosing file format, pick JPEG or PNG as Google Earth doesn't support other formats
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
require "official/yield"
local gettext = dt.gettext
local ds = require "lib/dtutils.string"
local dsys = require "lib/dtutils.system"
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
local gettext = dt.gettext.gettext
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("kml_export",dt.configuration.config_dir.."/lua/locale/")
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
du.check_min_api_version("7.0.0", "kml_export")
local function _(msgid)
return gettext.dgettext("kml_export", msgid)
return gettext(msgid)
end
-- Sort a table
local function spairs(_table, order) -- Code copied from http://stackoverflow.com/questions/15706270/sort-a-table-in-lua
-- collect the keys
local keys = {}
for _key in pairs(_table) do keys[#keys + 1] = _key end
-- return data structure for script_manager
-- if order function given, sort by it by passing the table and keys a, b,
-- otherwise just sort the keys
if order then
table.sort(keys, function(a,b) return order(_table, a, b) end)
else
table.sort(keys)
end
local script_data = {}
-- return the iterator function
local i = 0
return function()
i = i + 1
if keys[i] then
return keys[i], _table[keys[i]]
end
end
end
script_data.metadata = {
name = _("kml export"),
purpose = _("export KML/KMZ data to a file"),
author = "Tobias Jakobs",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/kml_export"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local function show_status(storage, image, format, filename, number, total, high_quality, extra_data)
dt.print(string.format(_("Export Image %i/%i"), number, total))
dt.print(string.format(_("export image %i/%i"), number, total))
end
-- Strip accents from a string
-- Copied from https://forums.coronalabs.com/topic/43048-remove-special-characters-from-string/
function string.stripAccents( str )
local tableAccents = {}
tableAccents["à"] = "a"
tableAccents["á"] = "a"
tableAccents["â"] = "a"
tableAccents["ã"] = "a"
tableAccents["ä"] = "a"
tableAccents["ç"] = "c"
tableAccents["è"] = "e"
tableAccents["é"] = "e"
tableAccents["ê"] = "e"
tableAccents["ë"] = "e"
tableAccents["ì"] = "i"
tableAccents["í"] = "i"
tableAccents["î"] = "i"
tableAccents["ï"] = "i"
tableAccents["ñ"] = "n"
tableAccents["ò"] = "o"
tableAccents["ó"] = "o"
tableAccents["ô"] = "o"
tableAccents["õ"] = "o"
tableAccents["ö"] = "o"
tableAccents["ù"] = "u"
tableAccents["ú"] = "u"
tableAccents["û"] = "u"
tableAccents["ü"] = "u"
tableAccents["ý"] = "y"
tableAccents["ÿ"] = "y"
tableAccents["À"] = "A"
tableAccents["Á"] = "A"
tableAccents["Â"] = "A"
tableAccents["Ã"] = "A"
tableAccents["Ä"] = "A"
tableAccents["Ç"] = "C"
tableAccents["È"] = "E"
tableAccents["É"] = "E"
tableAccents["Ê"] = "E"
tableAccents["Ë"] = "E"
tableAccents["Ì"] = "I"
tableAccents["Í"] = "I"
tableAccents["Î"] = "I"
tableAccents["Ï"] = "I"
tableAccents["Ñ"] = "N"
tableAccents["Ò"] = "O"
tableAccents["Ó"] = "O"
tableAccents["Ô"] = "O"
tableAccents["Õ"] = "O"
tableAccents["Ö"] = "O"
tableAccents["Ù"] = "U"
tableAccents["Ú"] = "U"
tableAccents["Û"] = "U"
tableAccents["Ü"] = "U"
tableAccents["Ý"] = "Y"
local normalizedString = ""
for strChar in string.gmatch(str, "([%z\1-\127\194-\244][\128-\191]*)") do
if tableAccents[strChar] ~= nil then
normalizedString = normalizedString..tableAccents[strChar]
else
normalizedString = normalizedString..strChar
-- Add duplicate index to filename
-- image.filename does not have index, exported_image has index
function addDuplicateIndex( index, filename )
if index > 0 then
filename = filename.."_"
if index < 10 then
filename = filename.."0"
end
filename = filename..index
end
return normalizedString
end
-- Escape XML characters
-- Keep &amp; first, otherwise it will double escape other characters
-- https://stackoverflow.com/questions/1091945/what-characters-do-i-need-to-escape-in-xml-documents
function string.escapeXmlCharacters( str )
str = string.gsub(str,"&", "&amp;")
str = string.gsub(str,"\"", "&quot;")
str = string.gsub(str,"'", "&apos;")
str = string.gsub(str,"<", "&lt;")
str = string.gsub(str,">", "&gt;")
return str
return filename
end
local function create_kml_file(storage, image_table, extra_data)
if not df.check_if_bin_exists("mkdir") then
dt.print_error(_("mkdir not found"))
return
end
if not df.check_if_bin_exists("convert") then
dt.print_error(_("convert not found"))
return
end
if not df.check_if_bin_exists("xdg-open") then
dt.print_error(_("xdg-open not found"))
return
end
if not df.check_if_bin_exists("xdg-user-dir") then
dt.print_error(_("xdg-user-dir not found"))
return
local magickPath
if dt.configuration.running_os == "linux" then
magickPath = 'convert'
else
magickPath = dt.preferences.read("kml_export","magickPath","string")
end
dt.print_error("Will try to export KML file now")
if not df.check_if_bin_exists(magickPath) then
dt.print_error("magick not found")
return
end
if dt.configuration.running_os == "linux" then
if not df.check_if_bin_exists("xdg-user-dir") then
dt.print_error("xdg-user-dir not found")
return
end
end
dt.print_log("Will try to export KML file now")
local imageFoldername
if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true ) then
if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true
and dt.configuration.running_os == "linux") then
if not df.check_if_bin_exists("zip") then
dt.print_error(_("zip not found"))
dt.print_error("zip not found")
return
end
exportDirectory = dt.configuration.tmp_dir
imageFoldername = ""
else
exportDirectory = dt.preferences.read("kml_export","ExportDirectory","string")
-- Creates dir if not exsists
imageFoldername = "files/"
local mkdirCommand = "mkdir -p "..exportDirectory.."/"..imageFoldername
dt.control.execute(mkdirCommand)
imageFoldername = "files"..PS
df.mkdir(df.sanitize_filename(exportDirectory..PS..imageFoldername))
end
-- Create the thumbnails
for image,exported_image in pairs(image_table) do
if ((image.longitude and image.latitude) and
@@ -209,15 +128,20 @@ local function create_kml_file(storage, image_table, extra_data)
local path, filename, filetype = string.match(exported_image, "(.-)([^\\/]-%.?([^%.\\/]*))$")
filename = string.upper(string.gsub(filename,"%.%w*", ""))
-- convert -size 92x92 filename.jpg -resize 92x92 +profile "*" thumbnail.jpg
-- magick -size 92x92 filename.jpg -resize 92x92 +profile "*" thumbnail.jpg
-- In this example, '-size 120x120' gives a hint to the JPEG decoder that the image is going to be downscaled to
-- 120x120, allowing it to run faster by avoiding returning full-resolution images to GraphicsMagick for the
-- subsequent resizing operation. The '-resize 120x120' specifies the desired dimensions of the output image. It
-- will be scaled so its largest dimension is 120 pixels. The '+profile "*"' removes any ICM, EXIF, IPTC, or other
-- profiles that might be present in the input and aren't needed in the thumbnail.
local convertToThumbCommand = "convert -size 96x96 "..exported_image.." -resize 92x92 -mattecolor \"#FFFFFF\" -frame 2x2 +profile \"*\" "..exportDirectory.."/"..imageFoldername.."thumb_"..filename..".jpg"
dt.control.execute(convertToThumbCommand)
local convertToThumbCommand = ds.sanitize(magickPath) .. " -size 96x96 " .. exported_image .. " -resize 92x92 -mattecolor \"#FFFFFF\" -frame 2x2 +profile \"*\" " .. exportDirectory .. PS .. imageFoldername .. "thumb_" .. filename .. ".jpg"
if (exported_image ~= exportDirectory..PS..imageFoldername..filename.."."..filetype) then
df.file_copy(exported_image, exportDirectory..PS..imageFoldername..filename.."."..filetype)
end
dsys.external_command(convertToThumbCommand)
else
-- Remove exported image if it has no GPS data
os.remove(exported_image)
@@ -228,7 +152,19 @@ local function create_kml_file(storage, image_table, extra_data)
-- Strip accents from the filename, because GoogleEarth can't open them
-- https://github.com/darktable-org/lua-scripts/issues/54
filmName = string.stripAccents(filmName)
filmName = ds.strip_accents(filmName)
-- Remove chars we don't like to have in filenames
filmName = string.gsub(filmName, [[\]], "")
filmName = string.gsub(filmName, [[/]], "")
filmName = string.gsub(filmName, [[:]], "")
filmName = string.gsub(filmName, [["]], "")
filmName = string.gsub(filmName, "<", "")
filmName = string.gsub(filmName, ">", "")
filmName = string.gsub(filmName, "|", "")
filmName = string.gsub(filmName, "*", "")
filmName = string.gsub(filmName, "?", "")
filmName = string.gsub(filmName,'[.]', "") -- At least Windwows has problems with the "." and the start command
end
exportKMLFilename = filmName..".kml"
@@ -246,6 +182,8 @@ local function create_kml_file(storage, image_table, extra_data)
for image,exported_image in pairs(image_table) do
-- Extract filename, e.g DSC9784.ARW -> DSC9784
filename = string.upper(string.gsub(image.filename,"%.%w*", ""))
-- Handle duplicates
filename = addDuplicateIndex( image.duplicate_index, filename )
-- Extract extension from exported image (user can choose JPG or PNG), e.g DSC9784.JPG -> .JPG
extension = string.match(exported_image,"%.%w*$")
@@ -256,12 +194,12 @@ local function create_kml_file(storage, image_table, extra_data)
local image_title, image_description
if (image.title and image.title ~= "") then
image_title = string.escapeXmlCharacters(image.title)
image_title = ds.escape_xml_characters(image.title)
else
image_title = image.filename
image_title = filename..extension
end
-- Characters should not be escaped in CDATA, but we are using HTML fragment, so we must escape them
image_description = string.escapeXmlCharacters(image.description)
image_description = ds.escape_xml_characters(image.description)
kml_file = kml_file.." <name>"..image_title.."</name>\n"
kml_file = kml_file.." <description>"..image_description.."</description>\n"
@@ -306,7 +244,7 @@ local function create_kml_file(storage, image_table, extra_data)
kml_file = kml_file.." <LineString>\n"
kml_file = kml_file.." <coordinates>\n"
for image,exported_image in spairs(image_table, function(t,a,b) return t[b] < t[a] end) do
for image,exported_image in du.spairs(image_table, function(t,a,b) return b.exif_datetime_taken > a.exif_datetime_taken end) do
if ((image.longitude and image.latitude) and
(image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data
) then
@@ -314,9 +252,11 @@ local function create_kml_file(storage, image_table, extra_data)
if (image.elevation) then
altitude = image.elevation;
end
kml_file = kml_file.." "..string.gsub(tostring(image.longitude),",", ".")..","..string.gsub(tostring(image.latitude),",", ".")..",altitude\n"
end
end
kml_file = kml_file.." </coordinates>\n"
kml_file = kml_file.." </LineString>\n"
@@ -326,27 +266,31 @@ local function create_kml_file(storage, image_table, extra_data)
kml_file = kml_file.."</Document>\n"
kml_file = kml_file.."</kml>"
local file = io.open(exportDirectory.."/"..exportKMLFilename, "w")
local file = io.open(exportDirectory..PS..exportKMLFilename, "w")
file:write(kml_file)
file:close()
dt.print("KML file created in "..exportDirectory)
-- Compress the files to create a KMZ file
if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true ) then
if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true
and dt.configuration.running_os == "linux") then
exportDirectory = dt.preferences.read("kml_export","ExportDirectory","string")
local createKMZCommand = "zip --test --move --junk-paths "
createKMZCommand = createKMZCommand .."\""..exportDirectory.."/"..exportKMZFilename.."\" " -- KMZ filename
createKMZCommand = createKMZCommand .."\""..dt.configuration.tmp_dir.."/"..exportKMLFilename.."\" " -- KML file
createKMZCommand = createKMZCommand .."\""..exportDirectory..PS..exportKMZFilename.."\" " -- KMZ filename
createKMZCommand = createKMZCommand .."\""..dt.configuration.tmp_dir..PS..exportKMLFilename.."\" " -- KML file
for image,exported_image in pairs(image_table) do
if ((image.longitude and image.latitude) and
(image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data
) then
local filename = string.upper(string.gsub(image.filename,"%.%w*", ""))
-- Handle duplicates
filename = addDuplicateIndex( image.duplicate_index, filename )
createKMZCommand = createKMZCommand .."\""..dt.configuration.tmp_dir.."/"..imageFoldername.."thumb_"..filename..".jpg\" " -- thumbnails
createKMZCommand = createKMZCommand .."\""..dt.configuration.tmp_dir..PS..imageFoldername.."thumb_"..filename..".jpg\" " -- thumbnails
createKMZCommand = createKMZCommand .."\""..exported_image.."\" " -- images
end
end
@@ -356,52 +300,95 @@ local function create_kml_file(storage, image_table, extra_data)
-- Open the file with the standard programm
if ( dt.preferences.read("kml_export","OpenKmlFile","bool") == true ) then
local kmlFileOpenCommand
local path
if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true ) then
kmlFileOpenCommand = "xdg-open "..exportDirectory.."/\""..exportKMZFilename.."\""
if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true
and dt.configuration.running_os == "linux") then
path = exportDirectory..PS..exportKMZFilename
else
kmlFileOpenCommand = "xdg-open "..exportDirectory.."/\""..exportKMLFilename.."\""
end
dt.control.execute(kmlFileOpenCommand)
path = exportDirectory..PS..exportKMLFilename
end
dsys.launch_default_app(df.sanitize_filename(path))
end
end
local function destroy()
dt.destroy_storage("kml_export")
end
-- Preferences
if dt.configuration.running_os == "windows" then
dt.preferences.register("kml_export",
"OpenKmlFile",
"bool",
_("KML export: Open KML/KMZ file after export"),
_("Opens the KML file after the export with the standard program for KML files"),
_("KML export: Open KML file after export"),
_("opens the KML file after the export with the standard program for KML files"),
false )
else
dt.preferences.register("kml_export",
"OpenKmlFile",
"bool",
_("KML export: open KML/KMZ file after export"),
_("opens the KML file after the export with the standard program for KML files"),
false )
local handle = io.popen("xdg-user-dir DESKTOP")
local result = handle:read()
if (result == nil) then
result = ""
end
local defaultDir = ''
if dt.configuration.running_os == "windows" then
defaultDir = os.getenv("USERPROFILE")
elseif dt.configuration.running_os == "macos" then
defaultDir = os.getenv("HOME")
else
local handle = io.popen("xdg-user-dir DESKTOP")
defaultDir = handle:read()
handle:close()
end
dt.preferences.register("kml_export",
"ExportDirectory",
"directory",
_("KML export: Export directory"),
_("A directory that will be used to export the KML/KMZ files"),
result )
_("KML export: export directory"),
_("a directory that will be used to export the KML/KMZ files"),
defaultDir )
if dt.configuration.running_os ~= "linux" then
dt.preferences.register("kml_export",
"magickPath", -- name
"file", -- type
_("KML export: ImageMagick binary location"), -- label
_("install location of magick[.exe], requires restart to take effect"), -- tooltip
"magick") -- default
end
dt.preferences.register("kml_export",
"CreatePath",
"bool",
_("KML export: Connect images with path"),
_("KML export: connect images with path"),
_("connect all images with a path"),
false )
if dt.configuration.running_os == "linux" then
dt.preferences.register("kml_export",
"CreateKMZ",
"bool",
_("KML export: Create KMZ file"),
_("Compress all imeges to one KMZ file"),
_("KML export: create KMZ file"),
_("compress all imeges to one KMZ file"),
true )
end
-- Register
dt.register_storage("kml_export", _("KML/KMZ Export"), nil, create_kml_file)
if dt.configuration.running_os == "windows" then
dt.register_storage("kml_export", _("KML export"), nil, create_kml_file)
else
dt.register_storage("kml_export", _("KML/KMZ export"), nil, create_kml_file)
end
script_data.destroy = destroy
return script_data
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
-- kate: hl Lua;

View File

@@ -20,7 +20,7 @@
--[[
PASSPORT CROPPING GUIDE
guides for cropping passport photos based on documents from the Finnish police
(https://www.poliisi.fi/instancedata/prime_product_julkaisu/intermin/embeds/poliisiwwwstructure/38462_Passikuvaohje_EN.pdf) describing passport photo dimensions of 47x36 mm and 500x653 px for digital biometric data stored in passports. They use ISO 19794-5 standard based on ICAO 9303 regulations which should also be compliant for all of Europe.
(https://poliisi.fi/documents/25235045/31329600/Passport-photograph-instructions-by-the-police-2020-EN-fixed.pdf/1eec2f4c-aed7-68e0-c112-0a8f25e0328d/Passport-photograph-instructions-by-the-police-2020-EN-fixed.pdf) describing passport photo dimensions of 47x36 mm and 500x653 px for digital biometric data stored in passports. They use ISO 19794-5 standard based on ICAO 9303 regulations which should also be compliant for all of Europe.
INSTALLATION
* copy this file in $CONFIGDIR/lua/ where CONFIGDIR is your darktable configuration directory
@@ -36,17 +36,29 @@ USAGE
]]
local dt = require "darktable"
local gettext = dt.gettext
local du = require "lib/dtutils"
local gettext = dt.gettext.gettext
dt.configuration.check_version(...,{2,0,0},{3,0,0},{4,0,0},{5,0,0})
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("passport_guide",dt.configuration.config_dir.."/lua/locale/")
du.check_min_api_version("2.0.0", "passport_guide")
local function _(msgid)
return gettext.dgettext("passport_guide", msgid)
return gettext(msgid)
end
local script_data = {}
script_data.metadata = {
name = _("passport guide"),
purpose = _("guides for cropping passport photos"),
author = "Kåre Hampf",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/passport_guide"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
dt.guides.register_guide("passport",
-- draw
function(cairo, x, y, width, height, zoom_scale)
@@ -90,5 +102,13 @@ function()
end
)
local function destroy()
-- nothing to destroy
end
script_data.destroy = destroy
return script_data
-- kate: tab-indents: off; indent-width 2; replace-tabs on; remove-trailing-space on; hl Lua;
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua

View File

@@ -0,0 +1,125 @@
--[[
German passport photo cropping guide for darktable.
Derived from the passport cropping guide by Kåre Hampf.
copyright (c) 2017 Kåre Hampf
copyright (c) 2024 Christian Sültrop
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/>.
]]
--[[
PASSPORT CROPPING GUIDE
Guides for cropping passport and ID card ("Personalausweis") photos based on the "Passbild-Schablone"
from the German Federal Ministry of the Interior and Community.
(https://www.bmi.bund.de/SharedDocs/downloads/DE/veroeffentlichungen/themen/moderne-verwaltung/ausweise/passbild-schablone-erwachsene.pdf?__blob=publicationFile&v=3)
INSTALLATION
* copy this file in $CONFIGDIR/lua/ where CONFIGDIR is your darktable configuration directory
* add the following line in the file $CONFIGDIR/luarc
require "passport_guide_germany"
* (optional) add the line:
"plugins/darkroom/clipping/extra_aspect_ratios/passport 35x45mm=45:35"
to $CONFIGDIR/darktablerc
USAGE
* when using the cropping tool, select "Passport Photo Germany" as guide and if you added the line in yout rc
select "passport 35x45mm" as aspect
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local gettext = dt.gettext.gettext
du.check_min_api_version("2.0.0", "passport_guide_germany")
-- Tell gettext where to find the .mo file translating messages for a particular domain
local function _(msgid)
return gettext(msgid)
end
local script_data = {}
script_data.metadata = {
name = _("passport guide Germany"),
purpose = _("guides for cropping passport and ID card (\"Personalausweis\") photos based on the \"Passbild-Schablone\" from the German Federal Ministry of the Interior and Community"),
author = "menschmachine",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/passport_guide_germany"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
dt.guides.register_guide("Passport Photo Germany",
-- draw
function(cairo, x, y, width, height, zoom_scale)
local _width, _height
-- get the max 35x45 rectangle
local aspect_ratio = 45 / 35
if width * aspect_ratio > height then
_width = height / aspect_ratio
_height = height
else
_width = width
_height = width * aspect_ratio
end
cairo:save()
cairo:translate(x + (width - _width) / 2, y + (height - _height) / 2)
cairo:scale(_width / 35, _height / 45)
-- the outer rectangle
cairo:rectangle( 0, 0, 35, 45)
-- Nose position: The nose tip must be between these lines
cairo:draw_line(15.5, 45, 15.5, 13)
cairo:draw_line(35-15.5, 45, 35-15.5, 13)
-- Face height
-- optimum face height: The upper end of the head should be between these lines
cairo:draw_line(0, 4, 35, 4)
cairo:draw_line(0, 8, 35, 8)
-- tolerated face height: The upper end of the head must not be below this line
cairo:draw_line(6, 13, 30, 13)
-- Eye area: The eyes must be between these lines
cairo:draw_line(0, 13, 35, 13)
cairo:draw_line(0, 23, 35, 23)
-- Cheek line: The cheek must lie on this line
cairo:draw_line(9, 45-5, 27, 45-5)
cairo:restore()
end,
-- gui
function()
return dt.new_widget("label"){label = _("Passport Photo Germany"), halign = "start"}
end
)
local function destroy()
-- noting to destroy
end
script_data.destroy = destroy
return script_data
-- kate: tab-indents: off; indent-width 2; replace-tabs on; remove-trailing-space on; hl Lua;
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua

View File

@@ -39,24 +39,37 @@ format (all fields can be the empty string):
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
require "official/yield"
local gettext = dt.gettext
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("pdf_slideshow",dt.configuration.config_dir.."/lua/locale/")
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext.dgettext("pdf_slideshow", msgid)
return gettext(msgid)
end
if not df.check_if_bin_exists("pdflatex") then
dt.print_error(_("pdflatex not found"))
dt.print_error("pdflatex not found")
return
end
dt.configuration.check_version(...,{4,0,0},{5,0,0})
du.check_min_api_version("7.0.0", "pdf_slideshow")
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("PDF slideshow"),
purpose = _("generates a PDF slideshow (via Latex) containing all selected images one per slide"),
author = "Pascal Obry",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/pdf_slideshow"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
dt.preferences.register
("pdf_slideshow","open with","string",
@@ -164,6 +177,10 @@ local function slide(latexfile,i,image,file)
my_write(latexfile,"\\end{figure}\n")
end
local function destroy()
dt.destroy_storage("pdf_slideshow")
end
dt.register_storage("pdf_slideshow",_("pdf slideshow"),
nil,
function(storage,image_table)
@@ -218,7 +235,7 @@ dt.register_storage("pdf_slideshow",_("pdf slideshow"),
local result = dt.control.execute(command)
if result ~= 0 then
dt.print(_("problem running pdflatex")) -- this one is probably usefull to the user
error(_("problem running ")..command)
error("problem running "..command)
end
-- open the PDF
@@ -228,7 +245,7 @@ dt.register_storage("pdf_slideshow",_("pdf slideshow"),
local result = dt.control.execute(command)
if result ~= 0 then
dt.print(_("problem running pdf viewer")) -- this one is probably usefull to the user
error(_("problem running ")..command)
error("problem running "..command)
end
-- finally do some clean-up
@@ -243,5 +260,8 @@ dt.register_storage("pdf_slideshow",_("pdf slideshow"),
nil,
widget)
script_data.destroy = destroy
return script_data
--
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua

507
contrib/photils.lua Normal file
View File

@@ -0,0 +1,507 @@
--[[ photils Auto Tagging plugin
copyright (c) 2020 Tobias Scheck
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/>.
--]]
--[[
A darktable plugin that tries to predict keywords based on the selected image.
This plugin uses photils-cli to handle this task. Photils-cli is an application
that passes the image through a neural network, classifies it, and extracts the
suggested tags. Everything happens offline without the need that your data are
sent over the internet.
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
* photils-cli - https://github.com/scheckmedia/photils-cli at the moment only
available for Linux and MacOS
USAGE
* require this script from your main lua file
To do this add this line to the file .config/darktable/luarc:
require "contrib/photils"
* Select an image
* Press "get tags"
* Select the tags you want from a list of suggestions
* Press "Attach .. Tags" to add the selected tags to your image
--]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
local MODULE_NAME = "photils"
du.check_min_api_version("7.0.0", MODULE_NAME)
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("photils"),
purpose = _("suggest tags based on image classification"),
author = "Tobias Scheck",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/photils"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
local exporter = dt.new_format("jpeg")
exporter.quality = 80
exporter.max_height = 224
exporter.max_width = 224
-- helper functions
local function num_keys(tbl)
local num = 0
for _ in pairs(tbl) do num = num + 1 end
return num
end
local function has_key(tbl, value)
for k, _ in pairs(tbl) do
if k == value then
return true
end
end
return false
end
local photils_installed = df.check_if_bin_exists("photils-cli")
--[[
local state object
maybe per_page is a preference variable but I think 10
is a good value for the ui
]]
local PHOTILS = {
tags = {},
confidences = {},
page = 1,
per_page = 10,
selected_tags = {},
in_pagination = false,
tagged_image = "",
module_installed = false,
event_registered = false,
plugin_display_views = {
[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100},
[dt.gui.views.darkroom] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER", 100}
},
}
local GUI = {
container = dt.new_widget("box") {
orientation = "vertical",
sensitive = true,
dt.new_widget("button") {
label = _("get tags"),
sensitive = photils_installed,
clicked_callback = function() PHOTILS.on_tags_clicked() end
},
reset_callback = function() PHOTILS.on_reset(true) end
},
stack = dt.new_widget("stack"),
prev_button = dt.new_widget("button") {
label = "<",
sensitive = false,
clicked_callback = function()
PHOTILS.page = PHOTILS.page - 1
PHOTILS.paginate()
end
},
next_button = dt.new_widget("button") {
label = ">",
sensitive = false,
clicked_callback = function()
PHOTILS.page = PHOTILS.page + 1
PHOTILS.paginate()
end
},
tag_box = dt.new_widget("box") {orientation = "vertical"},
tag_view = dt.new_widget("box") {orientation = "vertical"},
page_label = dt.new_widget("label") {label = ""},
error_view = dt.new_widget("box") {orientation = "vertical"},
warning_label = dt.new_widget("label") {
label = ""
},
restart_required_label = dt.new_widget("label") {
label = _("requires a restart to be applied")
},
attach_button = dt.new_widget("button") {
label = "",
sensitive = false,
clicked_callback = function(self) PHOTILS.attach_tags() end
},
confidence_slider = dt.new_widget("slider") {
step = 1,
digits = 0,
value = 90,
hard_max = 100,
hard_min = 0,
soft_max = 100,
soft_min = 0,
label = _("min confidence value")
},
warning = dt.new_widget("label")
}
function PHOTILS.image_changed()
local current_image = tostring(dt.gui.selection()[1])
if current_image ~= PHOTILS.tagged_image then
if PHOTILS.tagged_image ~= "" then
PHOTILS.tagged_image_has_changed()
end
PHOTILS.tagged_image = tostring(current_image)
end
end
function PHOTILS.tagged_image_has_changed()
GUI.warning.label = _("the suggested tags were not generated\n for the currently selected image!")
end
function PHOTILS.paginate()
PHOTILS.in_pagination = true
local num_pages = math.ceil(#PHOTILS.tags / PHOTILS.per_page)
GUI.page_label.label = string.format(_(" page %s of %s "), PHOTILS.page,
num_pages)
if PHOTILS.page <= 1 then
PHOTILS.page = 1
GUI.prev_button.sensitive = false
else
GUI.prev_button.sensitive = true
end
if PHOTILS.page > num_pages - 1 then
PHOTILS.page = num_pages
GUI.next_button.sensitive = false
else
GUI.next_button.sensitive = true
end
--[[
calculates the start positon in the tag array based on the current page
and takes N tags from that array to show these in darktable
e.g. page 1 goes from 1 to 10, page 2 from 11 to 20 a.s.o.
the paginaton approach is related to a problem with the dynamic addition
of mutliple widgets https://github.com/darktable-org/darktable/issues/4934#event-3318100463
]]--
local offset = ((PHOTILS.page - 1) * PHOTILS.per_page) + 1
local tag_index = 1
for i = offset, offset + PHOTILS.per_page - 1, 1 do
local tag = PHOTILS.tags[i]
local conf = PHOTILS.confidences[i]
GUI.tag_box[tag_index].value = has_key(PHOTILS.selected_tags, tag)
if tag then
if dt.preferences.read(MODULE_NAME, "show_confidence", "bool") then
tag = tag .. string.format(" (%.3f)", conf)
end
GUI.tag_box[tag_index].label = tag
GUI.tag_box[tag_index].sensitive = true
else
GUI.tag_box[tag_index].label = ""
GUI.tag_box[tag_index].sensitive = false
end
tag_index = tag_index + 1
end
PHOTILS.in_pagination = false
end
function PHOTILS.attach_tags()
local num_selected = #dt.gui.selection()
local job = dt.gui.create_job(_("apply tag to image"), true)
for i = 1, num_selected, 1 do
local image = dt.gui.selection()[i]
for tag, _ in pairs(PHOTILS.selected_tags) do
local dt_tag = dt.tags.create(tag)
dt.tags.attach(dt_tag, image)
end
job.percent = i / num_selected
end
dt.print(_("tags successfully attached to image"))
job.valid = false
end
function PHOTILS.get_tags(image, with_export)
local tmp_file = df.create_tmp_file()
local in_arg = df.sanitize_filename(tostring(image))
local out_arg = df.sanitize_filename(tmp_file)
local executable = photils_installed
if with_export then
dt.print_log("use export to for prediction")
local export_file = df.create_tmp_file()
exporter:write_image(image, export_file)
in_arg = df.sanitize_filename(tostring(export_file))
end
local command = executable .. " -c " .. " -i " .. in_arg .. " -o " .. out_arg
local ret = dtsys.external_command(command)
if ret > 0 then
dt.print_error(string.format("command %s returned error code %d", command, ret))
os.remove(tmp_file)
-- try to export the image and run tagging
if not with_export then
return PHOTILS.get_tags(image, true)
end
return false
end
for i = #PHOTILS.tags, 1, -1 do
PHOTILS.tags[i] = nil
PHOTILS.confidences[i] = nil
end
for tag in io.lines(tmp_file) do
local splitted = du.split(tag, ":")
if 100 * tonumber(splitted[2]) >= GUI.confidence_slider.value then
PHOTILS.tags[#PHOTILS.tags + 1] = splitted[1]
PHOTILS.confidences[#PHOTILS.confidences+1] = splitted[2]
end
end
dt.print(string.format(_("%s found %d tags for your image"), MODULE_NAME,
#PHOTILS.tags))
os.remove(tmp_file)
return true
end
function PHOTILS.on_tags_clicked()
PHOTILS.page = 1
GUI.warning.label = ""
PHOTILS.on_reset(false)
local images = dt.gui.selection()
if #images == 0 then
dt.print(_("no image selected."))
dt.control.sleep(2000)
else
if #images > 1 then
dt.print(_("this plugin can only handle a single image."))
dt.gui.selection({images[1]})
dt.control.sleep(2000)
end
with_export = dt.preferences.read(MODULE_NAME, "export_image_before_for_tags", "bool")
if not PHOTILS.get_tags(images[1], with_export) then
local msg = string.format(_("%s failed, see terminal output for details"), MODULE_NAME)
GUI.warning_label.label = msg
GUI.stack.active = GUI.error_view
dt.print(msg)
return
end
if #PHOTILS.tags == 0 then
local msg = string.format(_("no tags were found"), MODULE_NAME)
GUI.warning_label.label = msg
GUI.stack.active = GUI.error_view
return
end
GUI.stack.active = GUI.tag_view
PHOTILS.paginate()
end
end
function PHOTILS.tag_selected(tag_button)
if PHOTILS.in_pagination then return end
if tag_button.value then
local tag = tag_button.label
if dt.preferences.read(MODULE_NAME, "show_confidence", "bool") then
local idx = string.find(tag, "%(") - 2
tag = string.sub(tag, 0, idx)
end
PHOTILS.selected_tags[tag] = tag
else
PHOTILS.selected_tags[tag_button.label] = nil
end
local num_selected = num_keys(PHOTILS.selected_tags)
if num_selected == 0 then
GUI.attach_button.label = ""
GUI.attach_button.sensitive = false
else
GUI.attach_button.label = string.format(_("attach %d tags"),
num_selected)
GUI.attach_button.sensitive = true
end
end
function PHOTILS.on_reset(with_view)
if with_view then GUI.stack.active = 1 end
for k, _ in pairs(PHOTILS.selected_tags) do
PHOTILS.selected_tags[k] = nil
end
for _, v in ipairs(GUI.tag_box) do
v.value = false
end
GUI.attach_button.label = ""
GUI.attach_button.sensitive = false
end
local function install_module()
if not PHOTILS.module_installed then
dt.register_lib(MODULE_NAME,
_("photils auto-tagger"),
true,
true,
PHOTILS.plugin_display_views,
GUI.container,
nil,
nil
)
PHOTILS.module_installed = true
end
end
local function destroy()
dt.gui.libs[MODULE_NAME].visible = false
dt.destroy_event("photils", "mouse-over-image-changed")
end
local function restart()
dt.gui.libs[MODULE_NAME].visible = true
dt.register_event("photils", "mouse-over-image-changed",
PHOTILS.image_changed)
end
local function show()
dt.gui.libs[MODULE_NAME].visible = true
end
-- add a fix number of buttons
for _ = 1, PHOTILS.per_page, 1 do
local btn_tag = dt.new_widget("check_button") {
label = "",
sensitive = false,
clicked_callback = PHOTILS.tag_selected
}
table.insert(GUI.tag_box, btn_tag)
end
if not photils_installed then
GUI.warning_label.label = _("photils-cli not found")
dt.print_log("photils-cli not found")
else
GUI.warning_label.label = _("select an image, click \"get tags\" and get \nsuggestions for tags.")
end
GUI.pagination = dt.new_widget("box") {
orientation = "horizontal",
GUI.prev_button,
GUI.page_label,
GUI.next_button
}
table.insert(GUI.error_view, GUI.warning_label)
if not photils_installed then
table.insert(GUI.error_view, df.executable_path_widget({"photils-cli"}))
table.insert(GUI.error_view, GUI.restart_required_label)
end
table.insert(GUI.stack, GUI.error_view)
table.insert(GUI.stack, GUI.tag_view)
table.insert(GUI.tag_view, GUI.pagination)
table.insert(GUI.tag_view, GUI.tag_box)
table.insert(GUI.tag_view, GUI.attach_button)
table.insert(GUI.tag_view, GUI.warning)
table.insert(GUI.container, GUI.confidence_slider)
table.insert(GUI.container, GUI.stack)
GUI.stack.active = 1
-- uses photils: prefix because script settings are all together and not seperated by script
dt.preferences.register(MODULE_NAME,
"show_confidence",
"bool",
_("photils: show confidence value"),
_("if enabled, the confidence value for each tag is displayed"),
true)
dt.preferences.register(MODULE_NAME,
"export_image_before_for_tags",
"bool",
_("photils: use exported image for tag request"),
_("if enabled, the image passed to photils for tag suggestion is based on the exported, already edited image. " ..
"otherwise, the embedded thumbnail of the RAW file will be used for tag suggestion." ..
"the embedded thumbnail could speedup the tag suggestion but can fail if the RAW file is not supported."),
true)
dt.register_event("photils", "mouse-over-image-changed",
PHOTILS.image_changed)
if dt.gui.current_view().id == "lighttable" then
install_module()
else
if not PHOTILS.event_registered then
dt.register_event(
"photils", "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
PHOTILS.event_registered = true
end
end
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = show
return script_data

View File

@@ -44,20 +44,37 @@ USAGE
local dt = require "darktable"
local du = require "lib/dtutils"
local debug = require "darktable.debug"
du.check_min_api_version("7.0.0", "quicktag")
local gettext = dt.gettext
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("quicktag",dt.configuration.config_dir.."/lua/locale/")
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext.dgettext("quicktag", msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("quick tag"),
purpose = _("use buttons to quickly apply tags assigned to them"),
author = "Christian Kanzian",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/quicktag"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
local qt = {}
qt.module_installed = false
qt.event_registered = false
qt.widget_table = {}
-- maximum length of button labels
dt.preferences.register("quickTag",
"labellength",
@@ -176,12 +193,56 @@ local function update_quicktag_list()
end
end
local function install_module()
if not qt.module_installed then
dt.register_lib(
"quicktag", -- Module name
_("quick tag"), -- name
true, -- expandable
false, -- resetable
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 490}},
dt.new_widget("box"){
orientation = "vertical",
table.unpack(qt.widget_table),
},
nil,-- view_enter
nil -- view_leave
)
qt.module_installed = true
end
end
local function destroy()
dt.gui.libs["quicktag"].visible = false
for i=1,qnr do
dt.destroy_event("quicktag " .. tostring(i), "shortcut")
end
end
local function restart()
dt.gui.libs["quicktag"].visible = true
for i = 1 ,qnr do
dt.register_event("quicktag", "shortcut",
function(event, shortcut) tagattach(tostring(quicktag_table[i])) end,
string.format(_("quicktag %i"),i))
end
end
local function show()
dt.gui.libs["quicktag"].visible = true
end
update_quicktag_list()
local new_quicktag = dt.new_widget("entry"){
text = "",
placeholder = _("new tag"),
is_password = true,
is_password = false,
editable = true,
tooltip = _("enter your tag here")
}
@@ -212,40 +273,46 @@ local new_qt_widget = dt.new_widget ("box") {
-- back UI elements in a table
-- thanks to wpferguson for the hint
local widget_table = {}
for i=1,qnr do
widget_table[#widget_table + 1] = button[i]
qt.widget_table[#qt.widget_table + 1] = button[i]
end
widget_table[#widget_table + 1] = dt.new_widget("separator"){}
widget_table[#widget_table + 1] = old_quicktag
widget_table[#widget_table + 1] = new_qt_widget
qt.widget_table[#qt.widget_table + 1] = dt.new_widget("separator"){}
qt.widget_table[#qt.widget_table + 1] = old_quicktag
qt.widget_table[#qt.widget_table + 1] = new_qt_widget
--create module
dt.register_lib(
"quicktag", -- Module name
"quicktag", -- name
true, -- expandable
false, -- resetable
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 490}},
dt.new_widget("box"){
orientation = "vertical",
table.unpack(widget_table),
},
nil,-- view_enter
nil -- view_leave
if dt.gui.current_view().id == "lighttable" then
install_module()
else
if not qt.event_registered then
dt.register_event(
"quicktag", "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
qt.event_registered = true
end
end
-- create shortcuts
for i=1,qnr do
dt.register_event("shortcut",
dt.register_event("quicktag " .. tostring(i), "shortcut",
function(event, shortcut) tagattach(tostring(quicktag_table[i])) end,
string.format(_("quick tag %i"),i))
end
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = show
return script_data
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
-- kate: tab-indents: off; indent-width 2; replace-tabs on; remove-trailing-space on;

View File

@@ -39,9 +39,32 @@
]]
local dt = require "darktable"
local du = require "lib/dtutils"
-- added version check
dt.configuration.check_version(...,{3,0,0},{4,0,0})
du.check_min_api_version("7.0.0", "rate_group")
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("rate group"),
purpose = _("rate all images in a group"),
author = "Dom H (dom@hxy.io)",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/rate_group"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local function apply_rating(rating)
local images = dt.gui.action_images
@@ -52,36 +75,58 @@ local function apply_rating(rating)
end
end
if rating < 0 then
dt.print("rejecting group(s)")
dt.print(_("rejecting group(s)"))
else
dt.print("applying rating " ..rating.. " to group(s)")
dt.print(string.format(_("applying rating %d to group(s)"), rating))
end
end
dt.register_event("shortcut",function(event, shortcut)
local function destroy()
dt.destroy_event("rg_reject", "shortcut")
dt.destroy_event("rg0", "shortcut")
dt.destroy_event("rg1", "shortcut")
dt.destroy_event("rg2", "shortcut")
dt.destroy_event("rg3", "shortcut")
dt.destroy_event("rg4", "shortcut")
dt.destroy_event("rg5", "shortcut")
end
dt.register_event("rg_reject", "shortcut",
function(event, shortcut)
apply_rating(-1)
end, "Reject group")
end, _("reject group"))
dt.register_event("shortcut",function(event, shortcut)
dt.register_event("rg0", "shortcut",
function(event, shortcut)
apply_rating(0)
end, "Rate group 0")
end, string.format(_("rate group %d"), 0)
)
dt.register_event("shortcut",function(event, shortcut)
dt.register_event("rg1", "shortcut",
function(event, shortcut)
apply_rating(1)
end, "Rate group 1")
end, string.format(_("rate group %d"), 1))
dt.register_event("shortcut",function(event, shortcut)
dt.register_event("rg2", "shortcut",
function(event, shortcut)
apply_rating(2)
end, "Rate group 2")
end, string.format(_("rate group %d"), 2))
dt.register_event("shortcut",function(event, shortcut)
dt.register_event("rg3", "shortcut",
function(event, shortcut)
apply_rating(3)
end, "Rate group 3")
end, string.format(_("rate group %d"), 3))
dt.register_event("shortcut",function(event, shortcut)
dt.register_event("rg4", "shortcut",
function(event, shortcut)
apply_rating(4)
end, "Rate group 4")
end, string.format(_("rate group %d"), 4))
dt.register_event("shortcut",function(event, shortcut)
dt.register_event("rg5", "shortcut",
function(event, shortcut)
apply_rating(5)
end, "Rate group 5")
end, string.format(_("rate group %d"), 5))
script_data.destroy = destroy
return script_data

View File

@@ -1,3 +1,7 @@
--[[
Copyright (c) 2016 Sebastian Witt <se.witt@gmx.net>
Copyright (c) 2018 Bill Ferguson <wpferguson@gmail.com>
]]
--[[
Rename tags
@@ -18,39 +22,79 @@ USAGE
LICENSE
GPLv2
Changes
* 20180912 - Did an RTFM and read a bug (12277, thanks Christian G) that showed
a way to get the images containing the old tag one by one instead of searching
the entire database. Changed rename_tags() function to use this method.
]]
local darktable = require "darktable"
local du = require "lib/dtutils"
local debug = require "darktable.debug"
-- check API version
du.check_min_api_version("7.0.0", "rename-tags")
du.deprecated("contrib/rename-tags.lua","darktable release 4.0")
local gettext = darktable.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("rename tags"),
purpose = _("rename an existing tag"),
author = "Sebastian Witt (se.witt@gmx.net)",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/rename-tags"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local rt = {}
rt.module_installed = false
rt.event_registered = false
-- GUI entries
local old_tag = darktable.new_widget("entry") { tooltip = "Enter old tag" }
local new_tag = darktable.new_widget("entry") { tooltip = "Enter new tag" }
local old_tag = darktable.new_widget("entry") { tooltip = _("enter old tag") }
local new_tag = darktable.new_widget("entry") { tooltip = _("enter new tag") }
local function rename_reset()
old_tag.text = ''
new_tag.text = ''
end
-- This function does the renaming
local function rename_tags(widget)
local function rename_tags()
-- If entries are empty, return
if old_tag.text == '' then
darktable.print ("Old tag can't be empty")
darktable.print (_("old tag can't be empty"))
return
end
if new_tag.text == '' then
darktable.print ("New tag can't be empty")
darktable.print (_("new tag can't be empty"))
return
end
local Count = 0
local count = 0
-- Check if old tag exists
local ot = darktable.tags.find (old_tag.text)
if not ot then
darktable.print ("Old tag does not exist")
darktable.print (_("old tag does not exist"))
return
end
-- Show job
local job = darktable.gui.create_job ("Renaming tag", true)
local job = darktable.gui.create_job (_("renaming tag"), true)
old_tag.editable = false
new_tag.editable = false
@@ -58,57 +102,87 @@ local function rename_tags(widget)
-- Create if it does not exists
local nt = darktable.tags.create (new_tag.text)
-- Search images for old tag
dbcount = #darktable.database
for i,image in ipairs(darktable.database) do
-- Get number of images for old tag
local dbcount = #ot
-- loop through the images containing the old tag, and attach the new tag
for i=1, #ot do
-- Update progress bar
job.percent = i / dbcount
local tags = image:get_tags ()
for _,t in ipairs (tags) do
if t.name == old_tag.text then
-- Found it, attach new tag
image:attach_tag (nt)
Count = Count + 1
end
end
ot[i]:attach_tag(nt)
count = count + 1
end
-- Delete old tag, this removes it from all images
darktable.tags.delete (ot)
job.valid = false
darktable.print ("Renamed tags for " .. Count .. " images")
darktable.print (string.format(_("renamed tags for %d images"), count))
old_tag.editable = true
new_tag.editable = true
-- reset the gui fields
rename_reset()
end
local function install_module()
if not rt.module_installed then
darktable.register_lib ("rename_tags", _("rename tag"), true, true, {[darktable.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 20},}, rt.rename_widget, nil, nil)
rt.module_installed = true
end
end
local function destroy()
darktable.gui.libs["rename_tags"].visible = false
end
local function restart()
darktable.gui.libs["rename_tags"].visible = true
end
-- GUI
local old_widget = darktable.new_widget ("box") {
orientation = "horizontal",
darktable.new_widget("label") { label = "Old tag" },
darktable.new_widget("label") { label = _("old tag") },
old_tag
}
local new_widget = darktable.new_widget ("box") {
orientation = "horizontal",
darktable.new_widget("label") { label = "New tag" },
darktable.new_widget("label") { label = _("new tag") },
new_tag
}
local function rename_reset(widget)
old_tag.text = ''
new_tag.text = ''
end
local rename_widget = darktable.new_widget ("box") {
rt.rename_widget = darktable.new_widget ("box") {
orientation = "vertical",
reset_callback = rename_reset,
old_widget,
new_widget,
darktable.new_widget("button") { label = "Go", clicked_callback = rename_tags }
darktable.new_widget("button") { label = _("go"), clicked_callback = rename_tags }
}
if darktable.gui.current_view().id == "lighttable" then
install_module()
else
if not rt.event_registered then
darktable.register_event(
"rename_tags", "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
rt.event_registered = true
end
end
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = restart
return script_data
darktable.register_lib ("rename_tags", "rename tag", true, true, {[darktable.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 20},}, rename_widget, nil, nil)

236
contrib/rename_images.lua Normal file
View File

@@ -0,0 +1,236 @@
--[[
rename.lua - rename image file(s)
Copyright (C) 2020, 2021 Bill Ferguson <wpferguson@gmail.com>.
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
]]
--[[
rename - rename an image file or files
This shortcut resets the GPS information to that contained within
the image file. If no GPS info is in the image file, the GPS data
is cleared.
USAGE
* require this script from your luarc file or start it from script_manager
* select an image or images
* enter a renaming pattern
* click the button to rename the files
BUGS, COMMENTS, SUGGESTIONS
* Send to Bill Ferguson, wpferguson@gmail.com
CHANGES
TODO
* Add pattern builder
* Add new name preview
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local ds = require "lib/dtutils.string"
du.check_min_api_version("7.0.0", "rename_images")
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- namespace variable
local rename = {
presets = {},
widgets = {},
}
rename.module_installed = false
rename.event_registered = false
-- script_manager integration
local script_data = {}
script_data.metadata = {
name = _("rename images"),
purpose = _("rename an image file or files"),
author = "Bill Ferguson <wpferguson@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/rename_images"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
-- - - - - - - - - - - - - - - - - - - - - - - -
-- C O N S T A N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
local MODULE_NAME = "rename_images"
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
local USER = os.getenv("USERNAME")
local HOME = os.getenv(dt.configuration.running_os == "windows" and "HOMEPATH" or "HOME")
local PICTURES = HOME .. PS .. dt.configuration.running_os == "windows" and _("My Pictures") or _("Pictures")
local DESKTOP = HOME .. PS .. "Desktop"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- F U N C T I O N S
-- - - - - - - - - - - - - - - - - - - - - - - -
local function stop_job(job)
job.valid = false
end
local function install_module()
if not rename.module_installed then
dt.register_lib(
MODULE_NAME,
_("rename images"),
true,
true,
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER",700}},
dt.new_widget("box"){
orientation = "vertical",
rename.widgets.pattern,
rename.widgets.button,
},
nil,
nil
)
rename.module_installed = true
end
end
local function destroy()
dt.gui.libs[MODULE_NAME].visible = false
end
local function restart()
dt.gui.libs[MODULE_NAME].visible = true
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- M A I N
-- - - - - - - - - - - - - - - - - - - - - - - -
local function do_rename(images)
if #images > 0 then
local first_image = images[1]
local pattern = rename.widgets.pattern.text
dt.preferences.write(MODULE_NAME, "pattern", "string", pattern)
dt.print_log("pattern is " .. pattern)
if string.len(pattern) > 0 then
local datetime = os.date("*t")
local job = dt.gui.create_job(_("renaming images"), true, stop_job)
for i, image in ipairs(images) do
if job.valid then
job.percent = i / #images
ds.build_substitute_list(image, i, pattern, USER, PICTURES, HOME, DESKTOP)
local new_name = ds.substitute_list(pattern)
if new_name == -1 then
dt.print(_("unable to do variable substitution, exiting..."))
stop_job(job)
return
end
ds.clear_substitute_list()
local args = {}
local path = string.sub(df.get_path(new_name), 1, -2)
if string.len(path) == 0 then
path = image.path
end
local filename = df.get_filename(new_name)
local filmname = image.path
if path ~= image.path then
if not df.check_if_file_exists(df.sanitize_filename(path)) then
df.mkdir(df.sanitize_filename(path))
end
filmname = path
end
args[1] = dt.films.new(filmname)
args[2] = image
if filename ~= image.filename then
args[3] = filename
end
dt.database.move_image(table.unpack(args))
end
end
stop_job(job)
local collect_rules = dt.gui.libs.collect.filter()
dt.gui.libs.collect.filter(collect_rules)
dt.gui.views.lighttable.set_image_visible(first_image)
dt.print(string.format(_("renamed %d images"), #images))
else -- pattern length
dt.print_error("no pattern supplied, returning...")
dt.print(_("please enter the new name or pattern"))
end
else -- image count
dt.print_error("no images selected, returning...")
dt.print(_("please select some images and try again"))
end
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- W I D G E T S
-- - - - - - - - - - - - - - - - - - - - - - - -
rename.widgets.pattern = dt.new_widget("entry"){
tooltip = ds.get_substitution_tooltip(),
placeholder = _("enter pattern") .. "$(FILE_FOLDER)/$(FILE_NAME)",
text = "",
reset_callback = function(self)
self.text = ""
dt.preferences.write(MODULE_NAME, "pattern", "string", self.text)
end
}
local pattern_pref = dt.preferences.read(MODULE_NAME, "pattern", "string")
if pattern_pref then
rename.widgets.pattern.text = pattern_pref
end
rename.widgets.button = dt.new_widget("button"){
label = _("rename"),
clicked_callback = function(this)
do_rename(dt.gui.action_images)
end
}
if dt.gui.current_view().id == "lighttable" then
install_module()
else
if not rename.event_registered then
dt.register_event(
"rename_images", "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
rename.event_registered = true
end
end
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = restart
return script_data

View File

@@ -0,0 +1,124 @@
--[[
This file is part of darktable,
copyright (c) 2023 Dirk Dittmar
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/>.
]]
--[[
Enable selection of non-existing images in the the currently worked on images, e.g. the ones selected by the collection module.
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local ds = require "lib/dtutils.string"
local log = require "lib/dtutils.log"
-- module name
local MODULE <const> = "select_non_existing"
du.check_min_api_version("9.1.0", MODULE)
-- figure out the path separator
local PS <const> = dt.configuration.running_os == "windows" and "\\" or "/"
local DEFAULT_LOG_LEVEL <const> = log.info
log.log_level(DEFAULT_LOG_LEVEL)
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
local function stop_job(job)
job.valid = false
end
local function get_file_list(dir)
log.log_level(DEFAULT_LOG_LEVEL)
local file_list = {}
local cmd = nil
log.msg(log.debug, "called get_file_list with " .. dir)
if dt.configuration.running_os == "windows" then
cmd = "forfiles /P " .. ds.sanitize(dir) .. " /M * /C \"cmd /c echo @file\""
else
cmd = "cd " .. ds.sanitize(dir) ..";ls -1"
end
log.msg(log.info, "cmd is " .. cmd)
local p = io.popen(cmd)
if p then
for line in p:lines() do
if line:len() > 4 then
if not string.match(line, "xmp$") and not string.match(line, "XMP$") then
line = line:gsub("\"", "")
file_list[line] = true
end
end
end
p:close()
end
return file_list
end
local function select_nonexisting_images(event, images)
log.log_level(DEFAULT_LOG_LEVEL)
local selection = {}
local known_files = {}
local job = dt.gui.create_job(_("select non existing images"), true, stop_job)
for key,image in ipairs(images) do
if(job.valid) then
if not known_files[image.path] then
known_files[image.path] = get_file_list(image.path)
end
if key % 10 == 0 then
job.percent = key/#images
end
local file_exists = known_files[image.path][image.filename]
log.msg(log.debug, image.path .. PS .. image.filename .." exists? => "..tostring(file_exists))
if (not file_exists) then
table.insert(selection, image)
end
else
break
end
end
stop_job(job)
return selection
end
local function destroy()
dt.gui.libs.select.destroy_selection(MODULE)
end
dt.gui.libs.select.register_selection(
MODULE,
_("select non existing"),
select_nonexisting_images,
_("select all non-existing images in the current images"))
local script_data = {}
script_data.metadata = {
name = _("select non existing"),
purpose = _("enable selection of non-existing images"),
author = "Dirk Dittmar",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/select_non_existing"
}
script_data.destroy = destroy
return script_data

View File

@@ -19,29 +19,43 @@ Enable selection of untagged images (darktable|* tags are ignored)
]]
local dt = require "darktable"
local gettext = dt.gettext
local du = require "lib/dtutils"
local gettext = dt.gettext.gettext
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("select_untagged",dt.configuration.config_dir.."/lua/locale/")
du.check_min_api_version("7.0.0", "select_untagged")
local function _(msgid)
return gettext.dgettext("select_untagged", msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("select untagged"),
purpose = _("enable selection of untagged images"),
author = "Jannis_V",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/select_untagged"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local function stop_job(job)
job.valid = false
end
local function select_untagged_images()
local function select_untagged_images(event, images)
job = dt.gui.create_job(_("select untagged images"), true, stop_job)
local selection = {}
for key,image in ipairs(dt.collection) do
for key,image in ipairs(images) do
if(job.valid) then
job.percent = (key-1)/#dt.collection
job.percent = (key - 1)/#images
local tags = dt.tags.get_tags(image)
local hasTags = false
for _,tag in ipairs(tags) do
@@ -58,7 +72,19 @@ local function select_untagged_images()
end
job.valid = false
dt.gui.selection(selection)
-- return table of images to set the selection to
return selection
end
dt.gui.libs.select.register_selection(_("select untagged"),select_untagged_images,_("select all images containing no tags or only tags added by darktable"))
local function destroy()
dt.gui.libs.select.destroy_selection("select_untagged")
end
dt.gui.libs.select.register_selection(
"select_untagged", _("select untagged"),
select_untagged_images,
_("select all images containing no tags or only tags added by darktable"))
script_data.destroy = destroy
return script_data

View File

@@ -0,0 +1,199 @@
--[[
selected_image_visible.lua - make the selected image visible in lighttable
Copyright (C) 2026 Bill Ferguson <wpferguson@gmail.com>.
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
]]
--[[
selected_image_visible - make the selected image visible in lighttable
selected_image_visible adds a bshortcut to make the currently
selected image or the first image of a selection visible in lighttable
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
None
USAGE
* enable the script in script_manager
BUGS, COMMENTS, SUGGESTIONS
Bill Ferguson <wpferguson@gmail.com>
CHANGES
]]
local dt = require "darktable"
local du = require "lib/dtutils"
-- local df = require "lib/dtutils.file"
-- local ds = require "lib/dtutils.string"
-- local dtsys = require "lib/dtutils.system"
local log = require "lib/dtutils.log"
-- local debug = require "darktable.debug"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- A P I C H E C K
-- - - - - - - - - - - - - - - - - - - - - - - -
du.check_min_api_version("9.6.0", MODULE) -- choose the minimum version that contains the features you need
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- I 1 8 N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext.gettext
local function _(msgid)
return gettext(msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- S C R I P T M A N A G E R I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local script_data = {}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
script_data.metadata = {
name = _("selected image visible"), -- visible name of script
purpose = _("make the selected image visible in lighttable"), -- purpose of script
author = "Bill Ferguson <wpferguson@gmail.com>", -- your name and optionally e-mail address
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/selected_image_visible/" -- URL to help/documentation
}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- C O N S T A N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
local MODULE <const> = "selected_image_visible"
local DEFAULT_LOG_LEVEL <const> = log.info
local TMP_DIR <const> = dt.configuration.tmp_dir
-- path separator
local PS <const> = dt.configuration.running_os == "windows" and "\\" or "/"
-- command separator
local CS <const> = dt.configuration.running_os == "windows" and "&" or ";"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- L O G L E V E L
-- - - - - - - - - - - - - - - - - - - - - - - -
log.log_level(DEFAULT_LOG_LEVEL)
-- - - - - - - - - - - - - - - - - - - - - - - -
-- N A M E S P A C E
-- - - - - - - - - - - - - - - - - - - - - - - -
local selected_image_visible = {}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- G L O B A L V A R I A B L E S
-- - - - - - - - - - - - - - - - - - - - - - - -
selected_image_visible.log_level = DEFAULT_LOG_LEVEL
-- - - - - - - - - - - - - - - - - - - - - - - -
-- P R E F E R E N C E S
-- - - - - - - - - - - - - - - - - - - - - - - -
-- - - - - - - - - - - - - - - - - - - - - - - -
-- A L I A S E S
-- - - - - - - - - - - - - - - - - - - - - - - -
local namespace = selected_image_visible
-- - - - - - - - - - - - - - - - - - - - - - - -
-- F U N C T I O N S
-- - - - - - - - - - - - - - - - - - - - - - - -
local function set_image_visible()
if dt.gui.current_view().name == "lighttable" and #dt.gui.action_images > 0 then
dt.gui.views.lighttable.set_image_visible(dt.gui.action_images[1])
end
end
local function set_button_sensitive()
if dt.gui.current_view().name == "lighttable"
and #dt.gui.selection() > 0
and not dt.gui.views.lighttable.is_image_visible(dt.gui.selection()[1]) then
dt.gui.libs.image.set_sensitive(MODULE, true)
else
dt.gui.libs.image.set_sensitive(MODULE, false)
end
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- M A I N P R O G R A M
-- - - - - - - - - - - - - - - - - - - - - - - -
-- - - - - - - - - - - - - - - - - - - - - - - -
-- U S E R I N T E R F A C E
-- - - - - - - - - - - - - - - - - - - - - - - -
dt.gui.libs.image.register_action(
MODULE, _("selected image visible"),
function(event, images) set_image_visible() end,
_("make selected image visible in lighttable")
)
set_button_sensitive()
-- - - - - - - - - - - - - - - - - - - - - - - -
-- D A R K T A B L E I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - -
local function destroy()
-- put things to destroy (events, storages, etc) here
dt.destroy_event(MODULE, "selection-changed")
dt.destroy_event(MODULE, "mouse-over-image-changed")
dt.gui.libs.image.destroy_action(MODULE)
end
script_data.destroy = destroy
-- - - - - - - - - - - - - - - - - - - - - - - -
-- E V E N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
if not dt.query_event(MODULE, "shortcut") then
dt.register_event(MODULE, "shortcut",
function(event, shortcut)
set_image_visible()
end, _("make selected image visible in lighttable")
)
end
dt.register_event(MODULE, "selection-changed",
function(event)
set_button_sensitive()
end
)
dt.register_event(MODULE, "mouse-over-image-changed",
function(event, image)
set_button_sensitive()
end
)
return script_data

View File

@@ -25,19 +25,32 @@ USAGE
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
require "official/yield"
local gettext = dt.gettext
local gettext = dt.gettext.gettext
dt.configuration.check_version(...,{2,0,2},{3,0,0},{4,0,0})
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("slideshowMusic",dt.configuration.config_dir.."/lua/locale/")
du.check_min_api_version("7.0.0", "slideshowMusic")
local function _(msgid)
return gettext.dgettext("slideshowMusic", msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("slideshow music"),
purpose = _("play music during a slideshow"),
author = "Tobias Jakobs",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/slideshowMusic"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local function playSlideshowMusic(_, old_view, new_view)
local filename, playMusic
@@ -45,7 +58,7 @@ local function playSlideshowMusic(_, old_view, new_view)
playMusic = dt.preferences.read("slideshowMusic","PlaySlideshowMusic","bool")
if not df.check_if_bin_exists("rhythmbox-client") then
dt.print_error(_("rhythmbox-client not found"))
dt.print_error("rhythmbox-client not found")
return
end
@@ -67,13 +80,24 @@ local function playSlideshowMusic(_, old_view, new_view)
end
end
function destroy()
dt.destroy_event("slideshow_music", "view-changed")
dt.preferences.destroy("slideshowMusic", "SlideshowMusic")
dt.preferences.destroy("slideshowMusic", "PlaySlideshowMusic")
end
-- Preferences
dt.preferences.register("slideshowMusic", "SlideshowMusic", "file", _("Slideshow background music file"), "", "")
dt.preferences.register("slideshowMusic", "SlideshowMusic", "file", _("slideshow background music file"), "", "")
dt.preferences.register("slideshowMusic",
"PlaySlideshowMusic",
"bool",
_("Play slideshow background music"),
_("Plays music with rhythmbox if a slideshow starts"),
_("play slideshow background music"),
_("plays music with rhythmbox if a slideshow starts"),
true)
-- Register
dt.register_event("view-changed",playSlideshowMusic)
dt.register_event("slideshow_music", "view-changed",
playSlideshowMusic)
script_data.destroy = destroy
return script_data

View File

@@ -0,0 +1,313 @@
--[[
toggle_group_view.lua - toggle only group visible in lighttable
Copyright (C) 2024 Bill Ferguson <wpferguson.com>.
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
]]
--[[
toggle_group_view - toggle only group visible in lighttable
toggle_group_view provides a way to "separate" a group from
the lighttable display and limit the display to just the group.
Pressing the shortcut again returns to the full lighttable view.
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
None
USAGE
* place the script in your lua scripts folder
* start the script with script manager
* assign a key sequence to the shortcut
BUGS, COMMENTS, SUGGESTIONS
Bill Ferguson <wpferguson.com>
CHANGES
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local log = require "lib/dtutils.log"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- C O N S T A N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
local MODULE <const> = "toggle_group_view"
local DEFAULT_LOG_LEVEL <const> = log.error
local TMP_DIR <const> = dt.configuration.tmp_dir
-- path separator
local PS <const> = dt.configuration.running_os == "windows" and "\\" or "/"
-- command separator
local CS <const> = dt.configuration.running_os == "windows" and "&" or ";"
-- - - - - - - - - - - - - - - - - - - - - - - -
-- A P I C H E C K
-- - - - - - - - - - - - - - - - - - - - - - - -
du.check_min_api_version("7.0.0", MODULE) -- choose the minimum version that contains the features you need
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- I 1 8 N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local gettext = dt.gettext.gettext
dt.gettext.bindtextdomain(MODULE , dt.configuration.config_dir .. "/lua/locale/")
local function _(msgid)
return gettext(MODULE, msgid)
end
-- - - - - - - - - - - - - - - - - - - - - - - - - -
-- S C R I P T M A N A G E R I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - - - -
local script_data = {}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
script_data.metadata = {
name = "toggle_group_view", -- name of script
purpose = _("toggle only group visible in lighttable"), -- purpose of script
author = "Bill Ferguson <wpferguson.com>", -- your name and optionally e-mail address
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/official/toggle_group_view/" -- URL to help/documentation
}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- L O G L E V E L
-- - - - - - - - - - - - - - - - - - - - - - - -
log.log_level(DEFAULT_LOG_LEVEL)
-- - - - - - - - - - - - - - - - - - - - - - - -
-- N A M E S P A C E
-- - - - - - - - - - - - - - - - - - - - - - - -
local toggle_group_view = {}
-- - - - - - - - - - - - - - - - - - - - - - - -
-- G L O B A L V A R I A B L E S
-- - - - - - - - - - - - - - - - - - - - - - - -
local group_active = false
local filmroll = ""
local collection_rules = {}
local hover_active = true
-- - - - - - - - - - - - - - - - - - - - - - - -
-- F U N C T I O N S
-- - - - - - - - - - - - - - - - - - - - - - - -
local function is_group_member(image)
if image then
if #image:get_group_members() > 1 then
return true
else
return false
end
end
end
local function is_group_displayed()
local rules = dt.gui.libs.collect.filter()
if rules[1].item == "DT_COLLECTION_PROP_GROUP_ID" then
local rule = dt.gui.libs.collect.new_rule()
rule.mode = "DT_LIB_COLLECT_MODE_AND"
rule.data = dt.collection[1].path
rule.item = "DT_COLLECTION_PROP_FILMROLL"
table.insert(collection_rules, rule)
group_active = true
end
end
local function set_button_sensitive(image)
local selected_images = dt.gui.selection()
local sensitive
if group_active then
dt.gui.libs.image.set_sensitive(MODULE, true)
return
end
if #selected_images > 0 then
if is_group_member(selected_images[1]) then
sensitive = true
end
else
if image then
if is_group_member(image) then
sensitive = true
else
sensitive = false
end
else
sensitive = false
end
end
dt.gui.libs.image.set_sensitive(MODULE, sensitive)
end
local function add_collection_rule(rule_string)
local rule = dt.gui.libs.collect.new_rule()
rule.mode = "DT_LIB_COLLECT_MODE_AND"
rule.data = rule_string
rule.item = "DT_COLLECTION_PROP_FILENAME"
table.insert(collection_rules, rule)
end
local function show_group(image)
local collection_rule_string = ""
local first = true
collection_rules = {}
local group_id = image.group_leader
local rule = dt.gui.libs.collect.new_rule()
rule.mode = "DT_LIB_COLLECT_MODE_AND"
rule.data = tostring(group_id.id)
rule.item = "DT_COLLECTION_PROP_GROUP_ID"
table.insert(collection_rules, rule)
-- dt.gui.libs.collect.filter returns the previous rule set when you install another
collection_rules = dt.gui.libs.collect.filter(collection_rules)
end
local function reset(image)
dt.gui.libs.collect.filter(collection_rules)
if image then
dt.gui.views.lighttable.set_image_visible(image)
else
log.msg(log.screen, _("no image supplied"))
end
set_button_sensitive(image)
end
-- - - - - - - - - - - - - - - - - - - - - - - -
-- M A I N
-- - - - - - - - - - - - - - - - - - - - - - - -
-- check if we are starting with a group already displayed and
-- configure appropriately
if not dt.preferences.read("darktable", "plugins/lighttable/act_on", "bool") then
hover_active = false
end
is_group_displayed()
-- - - - - - - - - - - - - - - - - - - - - - - -
-- U S E R I N T E R F A C E
-- - - - - - - - - - - - - - - - - - - - - - - -
dt.gui.libs.image.register_action(
MODULE, "toggle group view",
function(event, images)
if group_active then
local image
if dt.gui.action_images[1] then
image = dt.gui.action_images[1]
reset(dt.gui.action_images[1])
else
image = dt.collection[1]
reset(dt.collection[1])
end
group_active = false
set_button_sensitive(image)
else
show_group(dt.gui.action_images[1])
group_active = true
end
end,
_("toggle group view for selected image")
)
set_button_sensitive(nil)
-- - - - - - - - - - - - - - - - - - - - - - - -
-- D A R K T A B L E I N T E G R A T I O N
-- - - - - - - - - - - - - - - - - - - - - - - -
local function destroy()
if hover_active then
dt.destroy_event(MODULE, "mouse-over-image-changed")
end
dt.destroy_event(MODULE, "selection_changed")
dt.gui.libs.image.destroy_action(MODULE, "toggle group view")
-- leave the shortcut so it doesn't need to be reassigned
-- the next time this module starts
end
script_data.destroy = destroy
-- - - - - - - - - - - - - - - - - - - - - - - -
-- E V E N T S
-- - - - - - - - - - - - - - - - - - - - - - - -
dt.register_event(
MODULE, "shortcut",
function(event, shortcut)
if #dt.gui.action_images > 0 then
if group_active then
reset(dt.gui.action_images[1])
group_active = false
else
show_group(dt.gui.action_images[1])
group_active = true
end
end
end,
_("toggle group view for selected image")
)
---[[
if hover_active then
dt.register_event(MODULE, "mouse-over-image-changed",
function(event, image)
set_button_sensitive(image)
end
)
end
--]]
dt.register_event(MODULE, "selection-changed",
function(event)
set_button_sensitive(dt.gui.action_images[1])
end
)
return script_data

408
contrib/transfer_hierarchy.lua Executable file
View File

@@ -0,0 +1,408 @@
--[[
TRANSFER HIERARCHY
Allows the moving or copying of images from one directory
tree to another, while preserving the existing hierarchy.
AUTHOR
August Schwerdfeger (august@schwerdfeger.name)
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
None.
USAGE
darktable's native operations for moving and copying images in
batches allow only one directory to be specified as the destination
for each batch. Those wanting to move or copy images from a _hierarchy_
of directories within darktable while preserving the directory structure,
must take the laborious step of performing the operation one individual
directory at a time.
This module allows the intact moving and copying of whole directory trees.
It was designed for the specific use case of rapidly transferring images
from a customary source (e.g., a staging directory on the local disk)
to a customary destination (e.g., a directory on a NAS device).
Instructions for operation:
1. Select the set of images you want to copy.
2. Click the "calculate" button. This will calculate the
lowest directory in the hierarchy that contains every selected
file (i.e., the common prefix of all the images' pathnames), and
write its path into the "existing root" text box.
3. If (a) you have specified the "customary source root" and "customary
destination root" preferences, and (b) the selected images are all
contained under the directory specified as the customary source
root, then the "root of destination" text box will also be
automatically filled out.
For example, suppose that you have specified '/home/user/Staging'
as your customary source root and '/mnt/storage' as your customary
destination root. If all selected images fell under the directory
'/home/user/Staging/2020/Roll0001', the "root of destination" would
be automatically filled out with '/mnt/storage/2020/Roll0001'.
But if all selected images fall under a directory outside the
specified customary source root (e.g., '/opt/other'), the "root
of destination" text box must be filled out manually.
It is also possible to edit the "root of destination" further once
it has been automatically filled out.
4. Click the "move" or "copy" button.
Before moving or copying any images, the module will first
replicate the necessary directory hierarchy by creating all
destination directories that do not already exist; should a
directory creation attempt fail, the operation will be
aborted, but any directories already created will not be
removed.
During the actual move/copy operation, the module transfers an
image by taking its path and replacing the string in the "existing
root" text box with that in the "root of destination" text box
(e.g., '/home/user/Staging/2020/Roll0001/DSC_0001.jpg' would be
transferred to '/mnt/storage/2020/Roll0001/DSC_0001.jpg').
LICENSE
LGPLv2+
]]
-- Header material: BEGIN
local darktable = require("darktable")
local dtutils = require("lib/dtutils")
local dtutils_file = require("lib/dtutils.file")
local dtutils_system = require("lib/dtutils.system")
local gettext = darktable.gettext.gettext
local LIB_ID = "transfer_hierarchy"
dtutils.check_min_api_version("7.0.0", LIB_ID)
local function _(msgid)
return gettext(msgid)
end
-- return data structure for script_manager
local script_data = {}
script_data.metadata = {
name = _("transfer hierarchy"),
purpose = _("allows the moving or copying of images from one directory tree to another, while preserving the existing hierarchy"),
author = "August Schwerdfeger (august@schwerdfeger.name)",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/transfer_hierarchy"
}
script_data.destroy = nil -- function to destory the script
script_data.destroy_method = nil -- set to hide for libs since we can't destroy them commpletely yet, otherwise leave as nil
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local MKDIR_COMMAND = darktable.configuration.running_os == "windows" and "mkdir " or "mkdir -p "
local PATH_SEPARATOR = darktable.configuration.running_os == "windows" and "\\\\" or "/"
local PATH_SEGMENT_REGEX = "(" .. PATH_SEPARATOR .. "?)([^" .. PATH_SEPARATOR .. "]+)"
unpack = unpack or table.unpack
gmatch = string.gfind or string.gmatch
-- Header material: END
-- Helper functions: BEGIN
local th = {}
th.module_installed = false
th.event_registered = false
local function pathExists(path)
local success, err, errno = os.rename(path, path)
if not success then
if errno == 13 then
return true
end
end
return success, err
end
local function pathIsDirectory(path)
return pathExists(path..PATH_SEPARATOR)
end
local function createDirectory(path)
local errorlevel = dtutils_system.external_command(MKDIR_COMMAND .. dtutils_file.sanitize_filename(path))
if errorlevel == 0 and pathIsDirectory(path) then
return path
else
return nil
end
end
local function install_module()
if not th.module_installed then
darktable.register_lib(LIB_ID,
_("transfer hierarchy"), true, true, {
[darktable.gui.views.lighttable] = { "DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 700 }
}, th.transfer_widget, nil, nil)
th.module_installed = true
end
end
-- Helper functions: END
-- Widgets and business logic: BEGIN
local sourceTextBox = darktable.new_widget("entry") {
tooltip = _("lowest directory containing all selected images"),
editable = false
}
sourceTextBox.reset_callback = function() sourceTextBox.text = "" end
local destinationTextBox = darktable.new_widget("entry") {
text = ""
}
destinationTextBox.reset_callback = function() destinationTextBox.text = "" end
local function findRootPath(films)
local commonSegments = nil
local prefix = ""
for film, _ in pairs(films) do
local path = film.path
if commonSegments == nil then
commonSegments = {}
local firstMatchIndex = string.find(path, PATH_SEGMENT_REGEX)
if firstMatchIndex ~= nil then
prefix = string.sub(path, 1, firstMatchIndex-1)
end
string.gsub(path, PATH_SEGMENT_REGEX, function(w, x)
if w ~= "" then table.insert(commonSegments, w) end
table.insert(commonSegments, x)
end)
else
local matcher = gmatch(path, PATH_SEGMENT_REGEX)
local i = 1
while i < #commonSegments do
match, match2 = matcher()
if match == nil then
while i <= #commonSegments do
table.remove(commonSegments, #commonSegments)
end
break
elseif match ~= "" then
if commonSegments[i] ~= match then
while i <= #commonSegments do
table.remove(commonSegments, #commonSegments)
end
break
else
i = i+1
end
end
if match2 == nil or commonSegments[i] ~= match2 then
while i <= #commonSegments do
table.remove(commonSegments, #commonSegments)
end
break
else
i = i+1
end
end
end
end
if commonSegments == nil then
return prefix
end
if commonSegments[#commonSegments] == PATH_SEPARATOR then
table.remove(commonSegments, #commonSegments)
end
rv = prefix .. table.concat(commonSegments)
return rv
end
local function calculateRoot()
films = {}
for _,img in ipairs(darktable.gui.action_images) do
films[img.film] = true
end
return findRootPath(films), films
end
local function doCalculate()
local rootPath = calculateRoot()
if rootPath ~= nil then
sourceTextBox.text = rootPath
local sourceBase = darktable.preferences.read(LIB_ID, "source_base", "directory")
local destBase = darktable.preferences.read(LIB_ID, "destination_base", "directory")
if sourceBase ~= nil and sourceBase ~= "" and
destBase ~= nil and destBase ~= "" and
string.sub(rootPath, 1, #sourceBase) == sourceBase then
destinationTextBox.text = destBase .. string.sub(rootPath, #sourceBase+1)
end
end
end
local function stopTransfer(transferJob)
transferJob.valid = false
end
local function doTransfer(transferFunc)
rootPath, films = calculateRoot()
if rootPath ~= sourceTextBox.text then
darktable.print(_("transfer hierarchy: ERROR: existing root is out of sync -- click 'calculate' to update"))
return
end
if destinationTextBox.text == "" then
darktable.print(_("transfer hierarchy: ERROR: destination not specified"))
return
end
local sourceBase = sourceTextBox.text
local destBase = destinationTextBox.text
local destFilms = {}
for film, i in pairs(films) do
films[film] = destBase .. string.sub(film.path, #sourceBase+1)
if not pathExists(films[film]) then
if createDirectory(films[film]) == nil then
darktable.print(string.format(_("transfer hierarchy: ERROR: could not create directory: %s"), films[film]))
return
end
end
if not pathIsDirectory(films[film]) then
darktable.print(string.format(_("transfer hierarchy: ERROR: not a directory: %s"), films[film]))
return
end
destFilms[film] = darktable.films.new(films[film])
if destFilms[film] == nil then
darktable.print(string.format(_("transfer hierarchy: ERROR: could not create film: %s"), film.path))
end
end
local srcFilms = {}
for _,img in ipairs(darktable.gui.action_images) do
srcFilms[img] = img.film
end
local job = darktable.gui.create_job(string.format(_("transfer hierarchy (%d image%s)"), #(darktable.gui.action_images), (#(darktable.gui.action_images) == 1 and "" or "s")), true, stopTransfer)
job.percent = 0.0
local pctIncrement = 1.0 / #(darktable.gui.action_images)
for _,img in ipairs(darktable.gui.action_images) do
if job.valid and img.film == srcFilms[img] then
destFilm = destFilms[img.film]
transferFunc(img, destFilm)
job.percent = job.percent + pctIncrement
end
end
job.valid = false
local filterRules = darktable.gui.libs.collect.filter()
darktable.gui.libs.collect.filter(filterRules)
end
local function doMove()
doTransfer(darktable.database.move_image)
end
local function doCopy()
doTransfer(darktable.database.copy_image)
end
local function destroy()
darktable.gui.libs[LIB_ID].visible = false
end
local function restart()
darktable.gui.libs[LIB_ID].visible = true
end
th.transfer_widget = darktable.new_widget("box") {
orientation = "vertical",
darktable.new_widget("button") {
label = _("calculate"),
clicked_callback = doCalculate
},
darktable.new_widget("label") {
label = _("existing root"),
halign = "start"
},
sourceTextBox,
darktable.new_widget("label") {
label = _("root of destination"),
halign = "start"
},
destinationTextBox,
darktable.new_widget("button") {
label = _("move"),
tooltip = "Move all selected images",
clicked_callback = doMove
},
darktable.new_widget("button") {
label = _("copy"),
tooltip = _("copy all selected images"),
clicked_callback = doCopy
}
}
-- Widgets and business logic: END
-- Preferences: BEGIN
darktable.preferences.register(
LIB_ID,
"source_base",
"string",
"[transfer hierarchy] Customary source root",
"",
"")
darktable.preferences.register(
LIB_ID,
"destination_base",
"string",
"[transfer hierarchy] Customary destination root",
"",
"")
-- Preferences: END
if darktable.gui.current_view().id == "lighttable" then
install_module()
else
if not th.event_registered then
darktable.register_event(
LIB_ID, "view-changed",
function(event, old_view, new_view)
if new_view.name == "lighttable" and old_view.name == "darkroom" then
install_module()
end
end
)
th.event_registered = true
end
end
script_data.destroy = destroy
script_data.restart = restart
script_data.destroy_method = "hide"
script_data.show = restart
return script_data

1066
contrib/ultrahdr.lua Normal file

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More