Compare commits
1382 Commits
release-2.
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d109612045 | ||
|
|
0f47f46b35 | ||
|
|
1a44df7d3c | ||
|
|
aa62473cbf | ||
|
|
f7faad0962 | ||
|
|
53549f16b5 | ||
|
|
7531a29235 | ||
|
|
a4dce23ef8 | ||
|
|
8abc350d68 | ||
|
|
078011d6b4 | ||
|
|
2a16599f91 | ||
|
|
14646cf8e6 | ||
|
|
5823d015ac | ||
|
|
30e6b9459a | ||
|
|
d3e15065d2 | ||
|
|
fe722f8409 | ||
|
|
b91baebdeb | ||
|
|
5ebadd83ea | ||
|
|
01c3b7d2f6 | ||
|
|
bfee6b12dc | ||
|
|
503a59d590 | ||
|
|
78176e32e8 | ||
|
|
4d8d076d8e | ||
|
|
72f31d6208 | ||
|
|
784a6ea85d | ||
|
|
bbfd9d12e3 | ||
|
|
a55de740e5 | ||
|
|
dc31b221ef | ||
|
|
34b88490c2 | ||
|
|
d9b77bb3a2 | ||
|
|
cc198d6ca1 | ||
|
|
84582cbf29 | ||
|
|
9e7a18e290 | ||
|
|
8ff81fcfa4 | ||
|
|
b649e7a840 | ||
|
|
efa06ee34c | ||
|
|
77959422e0 | ||
|
|
0bff346b05 | ||
|
|
d05c494147 | ||
|
|
9cbbae9621 | ||
|
|
fb2aade198 | ||
|
|
7ffd8bdc27 | ||
|
|
b689dbc7ee | ||
|
|
027135a257 | ||
|
|
643057deaf | ||
|
|
a00f71f533 | ||
|
|
36d6db24e7 | ||
|
|
f62a5a817f | ||
|
|
44b40b305b | ||
|
|
97dade06cf | ||
|
|
30167631e7 | ||
|
|
8235de1f0a | ||
|
|
d67ada8300 | ||
|
|
c6788e4370 | ||
|
|
d238fcee61 | ||
|
|
28d71c989f | ||
|
|
74f020c809 | ||
|
|
80769a753a | ||
|
|
427359769e | ||
|
|
5e5b073cec | ||
|
|
c771c5fc1b | ||
|
|
7cdf1d4c7f | ||
|
|
b6ea6211db | ||
|
|
4d3924939b | ||
|
|
80ff1ef0aa | ||
|
|
af362315e8 | ||
|
|
28f3e9f6a2 | ||
|
|
4f05672809 | ||
|
|
8d8f295c77 | ||
|
|
a81ab437cf | ||
|
|
a94a0c2c90 | ||
|
|
0eda1b6ac5 | ||
|
|
58bc3a69df | ||
|
|
35398c55e5 | ||
|
|
1762b372b1 | ||
|
|
1907f9a1f5 | ||
|
|
b1dd3eca5a | ||
|
|
732d2788ca | ||
|
|
04908e3f0b | ||
|
|
3ba3facad2 | ||
|
|
cb209d1d56 | ||
|
|
36533b1004 | ||
|
|
cbbf0f413f | ||
|
|
181aea5bc2 | ||
|
|
94c6dff245 | ||
|
|
79ac6fc31e | ||
|
|
7a61d77c27 | ||
|
|
2635e261a0 | ||
|
|
d197851478 | ||
|
|
6f519b3ce8 | ||
|
|
03eb79e83a | ||
|
|
fb03b49a93 | ||
|
|
c0865c37bb | ||
|
|
6bbb619513 | ||
|
|
182a2c96c3 | ||
|
|
06522802d8 | ||
|
|
ad263fed11 | ||
|
|
ced60016fb | ||
|
|
1d6d0695fe | ||
|
|
fbe504b47a | ||
|
|
7da38b3665 | ||
|
|
08fe1ba410 | ||
|
|
088c79e140 | ||
|
|
f06eebe316 | ||
|
|
d6a1cec9fa | ||
|
|
e194ad2bc7 | ||
|
|
22e3c59d69 | ||
|
|
eb743e4b3b | ||
|
|
7a8f3afc40 | ||
|
|
2b3910c698 | ||
|
|
c584ee05c9 | ||
|
|
bb3a74feac | ||
|
|
90d2764a5a | ||
|
|
b0373f7166 | ||
|
|
c6002e7eb7 | ||
|
|
a47de82afd | ||
|
|
7f09e55525 | ||
|
|
f83ac1366a | ||
|
|
6cda27172e | ||
|
|
df78522a79 | ||
|
|
6e64d6db6f | ||
|
|
7f00cb8d6c | ||
|
|
dfeff73fcd | ||
|
|
d75f00daa0 | ||
|
|
3e430ee2be | ||
|
|
3856ae3449 | ||
|
|
d54a9f8b7e | ||
|
|
8f6cc850fb | ||
|
|
e9f18a3d36 | ||
|
|
f3a89a89bd | ||
|
|
d075fb7128 | ||
|
|
7f4bae4234 | ||
|
|
071a3527c1 | ||
|
|
22c9a7cd6e | ||
|
|
12ccefcc3b | ||
|
|
fa6014fefa | ||
|
|
e831f377bf | ||
|
|
d696e6e3f2 | ||
|
|
db505f1e0a | ||
|
|
57d15a3fa6 | ||
|
|
3c131c41d1 | ||
|
|
4d54b5eaba | ||
|
|
ffa125b134 | ||
|
|
dbf0c5d853 | ||
|
|
193a615772 | ||
|
|
056f616283 | ||
|
|
447980ddc4 | ||
|
|
8af5476f8d | ||
|
|
c95547caa7 | ||
|
|
b4d3b2901f | ||
|
|
cb6b3161d8 | ||
|
|
2d82eea237 | ||
|
|
3beee93af4 | ||
|
|
68291414f3 | ||
|
|
5662519314 | ||
|
|
28ab065293 | ||
|
|
aed3275943 | ||
|
|
d7aeb43340 | ||
|
|
ea79d10b11 | ||
|
|
e4001f984f | ||
|
|
453d744b69 | ||
|
|
b9cc0dccce | ||
|
|
84fea20ee5 | ||
|
|
e054bfc59d | ||
|
|
8cd10dce68 | ||
|
|
f8d49ccd01 | ||
|
|
25afb41924 | ||
|
|
3001a0dc1a | ||
|
|
62e932990e | ||
|
|
980fe3962c | ||
|
|
0043769946 | ||
|
|
0cb9a8872e | ||
|
|
5309ff1726 | ||
|
|
c6eee15d75 | ||
|
|
8c2d0ddf2e | ||
|
|
87d18549a6 | ||
|
|
6fdd78114f | ||
|
|
f20721373a | ||
|
|
9c0f8d63e6 | ||
|
|
ea2596ae13 | ||
|
|
a9191cf084 | ||
|
|
59b5039579 | ||
|
|
e070a1462c | ||
|
|
faa3302a37 | ||
|
|
115dbbec32 | ||
|
|
9bf7efe71f | ||
|
|
3ec9dc4963 | ||
|
|
cddb86ded0 | ||
|
|
2624338100 | ||
|
|
067fe29f76 | ||
|
|
926272b1cd | ||
|
|
363524fbaf | ||
|
|
edeceb268e | ||
|
|
252cbc96f2 | ||
|
|
b70fdc0ecf | ||
|
|
96457bc598 | ||
|
|
cd31d18075 | ||
|
|
4e140f10d1 | ||
|
|
593f8049a0 | ||
|
|
89973b3f9a | ||
|
|
deca366ce4 | ||
|
|
914a17fb4e | ||
|
|
1e33ea4192 | ||
|
|
9f3fb16161 | ||
|
|
3f064783b7 | ||
|
|
0ab4b0cd6d | ||
|
|
e2f5c993b8 | ||
|
|
3def8b43d9 | ||
|
|
7b2942ca29 | ||
|
|
bfed38f1db | ||
|
|
6d16a8778b | ||
|
|
3c67c0c693 | ||
|
|
1ba488d073 | ||
|
|
3bdbfd12bf | ||
|
|
77c405882d | ||
|
|
ecc3fb29f5 | ||
|
|
a09140c03c | ||
|
|
95e2e4924e | ||
|
|
72ce0b0f93 | ||
|
|
e4da226661 | ||
|
|
a3404b64de | ||
|
|
13ae486ab3 | ||
|
|
268aa7df42 | ||
|
|
ea7ac8e474 | ||
|
|
2a4452cd20 | ||
|
|
749db97dd5 | ||
|
|
84a1c1ddfe | ||
|
|
3791b47914 | ||
|
|
f6a1d1c20b | ||
|
|
118bbad5cb | ||
|
|
44e442e7eb | ||
|
|
08726427aa | ||
|
|
39f63cc8c5 | ||
|
|
99c3548950 | ||
|
|
7e8340c526 | ||
|
|
2e95c4837b | ||
|
|
fe6d262d9b | ||
|
|
794b12305c | ||
|
|
1a3a7f17ff | ||
|
|
496f8e704d | ||
|
|
28f87566e1 | ||
|
|
865d29fb40 | ||
|
|
1986f4e148 | ||
|
|
b963eaa38c | ||
|
|
3b520d6291 | ||
|
|
87ca8bde27 | ||
|
|
d27df0c0ed | ||
|
|
9bceb79a15 | ||
|
|
ed9f2bb0d0 | ||
|
|
b5c93e55d1 | ||
|
|
9bfda93b51 | ||
|
|
daa0877b4c | ||
|
|
da275c2a66 | ||
|
|
3fa913d68a | ||
|
|
e4e194b0ec | ||
|
|
c70ebf4297 | ||
|
|
7e3c6471ff | ||
|
|
a39f6feba7 | ||
|
|
ee7e92019a | ||
|
|
96b7ba24bc | ||
|
|
8581af29d2 | ||
|
|
ab532a724c | ||
|
|
b1e6bb8daa | ||
|
|
26e797d5e5 | ||
|
|
3941c7ab52 | ||
|
|
b7c8759af3 | ||
|
|
c5711880d3 | ||
|
|
e7dbd6e369 | ||
|
|
1b5cb1ae6e | ||
|
|
2953cf7e91 | ||
|
|
5e4ba9da5e | ||
|
|
3a1f6bbc7a | ||
|
|
21ec2883fe | ||
|
|
a0af01884d | ||
|
|
8e129d3825 | ||
|
|
d123634679 | ||
|
|
13f210bec9 | ||
|
|
8e4767c42a | ||
|
|
300bb9d443 | ||
|
|
4f8df88fec | ||
|
|
44da339202 | ||
|
|
0e37a287ca | ||
|
|
2af2530e45 | ||
|
|
99eb595f4c | ||
|
|
31cdd3f24a | ||
|
|
631d89e581 | ||
|
|
526e97a4e1 | ||
|
|
a835ab89bc | ||
|
|
da7674ca51 | ||
|
|
0e535b850c | ||
|
|
64840089e9 | ||
|
|
d754e37cf4 | ||
|
|
f6cb8091e7 | ||
|
|
e359567620 | ||
|
|
36a6a54364 | ||
|
|
ecff920537 | ||
|
|
842f2fca66 | ||
|
|
ee9384b9a7 | ||
|
|
272c35499a | ||
|
|
4165d46b33 | ||
|
|
5bed7c914c | ||
|
|
684178b27e | ||
|
|
a72abe0ad0 | ||
|
|
8863f6ade7 | ||
|
|
e0463eba83 | ||
|
|
3a2ff7a7b9 | ||
|
|
ce7ddfa472 | ||
|
|
3fb00586c3 | ||
|
|
167620fadf | ||
|
|
f0bdc890c1 | ||
|
|
abdfc9de0b | ||
|
|
c65e070a76 | ||
|
|
05c57c0247 | ||
|
|
5be3d6986e | ||
|
|
f0e3627800 | ||
|
|
ea08557a0e | ||
|
|
ac43afd8c9 | ||
|
|
ee98f96a4f | ||
|
|
a33eeddbd6 | ||
|
|
746c6a07c4 | ||
|
|
96fee48ef2 | ||
|
|
6c686128d2 | ||
|
|
6ca8f0034e | ||
|
|
3d1f12fe44 | ||
|
|
a079860cd8 | ||
|
|
b07c680332 | ||
|
|
200fc059c0 | ||
|
|
aeb1f2226c | ||
|
|
46e729b40e | ||
|
|
66b613dc29 | ||
|
|
535ba78a06 | ||
|
|
cc11c1c3b8 | ||
|
|
fba639e98a | ||
|
|
3e37c06b84 | ||
|
|
1b272be5f5 | ||
|
|
9f423eeef3 | ||
|
|
dc81c0b1c5 | ||
|
|
e8a99c8396 | ||
|
|
7c93868bf0 | ||
|
|
36023d8d4f | ||
|
|
97aa4ce363 | ||
|
|
316a89d6a8 | ||
|
|
d4a479b025 | ||
|
|
dd22c947c6 | ||
|
|
09f47b7b09 | ||
|
|
ba94914c0e | ||
|
|
3bb4e9c59a | ||
|
|
f8c076f308 | ||
|
|
94f41db6fc | ||
|
|
5727b2d251 | ||
|
|
c95f8a23b2 | ||
|
|
88e4ac1a64 | ||
|
|
a3fe02bf95 | ||
|
|
ff20098175 | ||
|
|
cdf4b743dd | ||
|
|
3efc1805ca | ||
|
|
0b46cf8abf | ||
|
|
28622e620e | ||
|
|
f21a117d29 | ||
|
|
35cbff03dd | ||
|
|
5571e2f2dc | ||
|
|
3c77f2e863 | ||
|
|
4ff1111341 | ||
|
|
abfa8e9878 | ||
|
|
bbe9109fca | ||
|
|
34d5df65b2 | ||
|
|
539f25517b | ||
|
|
5b55a3116d | ||
|
|
3e032616a0 | ||
|
|
9f2dbef4f0 | ||
|
|
2abb83b485 | ||
|
|
32e966f8d9 | ||
|
|
67538a4de2 | ||
|
|
96471ae7e7 | ||
|
|
038418b89f | ||
|
|
fe48d7498c | ||
|
|
2f330ea9cc | ||
|
|
81b0f1fb48 | ||
|
|
9088bc9144 | ||
|
|
c3ce8d532d | ||
|
|
f1d8ad7fce | ||
|
|
a3b295112f | ||
|
|
c36618f5fb | ||
|
|
fecbb39347 | ||
|
|
cbe2c5329a | ||
|
|
dcbe575e9c | ||
|
|
417c165d16 | ||
|
|
232baab86b | ||
|
|
3ed4219e6c | ||
|
|
97e33672ea | ||
|
|
7b2018412a | ||
|
|
3e2afffed8 | ||
|
|
1399e8a4b4 | ||
|
|
5c3b2777f0 | ||
|
|
bf138abeb2 | ||
|
|
284c0f9714 | ||
|
|
e41029d3f4 | ||
|
|
55e68f8cd0 | ||
|
|
ac945b9843 | ||
|
|
f6916c3a15 | ||
|
|
cd3788f012 | ||
|
|
ebd2cd7bf7 | ||
|
|
52b4508e08 | ||
|
|
b1b3392b92 | ||
|
|
19fdbc14c5 | ||
|
|
63d5aad465 | ||
|
|
9d6ff85893 | ||
|
|
125af63bda | ||
|
|
ddf0c89402 | ||
|
|
3b0ff3475a | ||
|
|
401509cfe4 | ||
|
|
9c4e906033 | ||
|
|
65c22e475a | ||
|
|
a11726889d | ||
|
|
e78e718769 | ||
|
|
86ee8adbce | ||
|
|
40949b3855 | ||
|
|
06ab263e74 | ||
|
|
bccc86c70a | ||
|
|
231e9b352b | ||
|
|
e47ab34745 | ||
|
|
1fd2ca20ab | ||
|
|
05a73d8810 | ||
|
|
12640c7d29 | ||
|
|
febc3b1659 | ||
|
|
9fdd69556c | ||
|
|
4735be470a | ||
|
|
66b33d6f48 | ||
|
|
37dba718a2 | ||
|
|
c11845cbf9 | ||
|
|
f9fe33f930 | ||
|
|
3b8e802e42 | ||
|
|
f54d449316 | ||
|
|
1b0fe4d7b9 | ||
|
|
cf1dca9e1a | ||
|
|
45d54ef4e8 | ||
|
|
8bfab0325b | ||
|
|
4b99d00ab5 | ||
|
|
a5961eb066 | ||
|
|
95e19ef163 | ||
|
|
d4eb6577bf | ||
|
|
294b693905 | ||
|
|
23835edc1f | ||
|
|
5f29211f79 | ||
|
|
025f4299ea | ||
|
|
dc50d40886 | ||
|
|
867c49b1b9 | ||
|
|
13f02c95ea | ||
|
|
d55dae73f0 | ||
|
|
34b9831472 | ||
|
|
014a0fc1c9 | ||
|
|
bf17dccd69 | ||
|
|
890168d0d0 | ||
|
|
191aecacdf | ||
|
|
44ec01b136 | ||
|
|
a177da2040 | ||
|
|
c899040688 | ||
|
|
e8af665b3c | ||
|
|
875734d455 | ||
|
|
14d5a79db2 | ||
|
|
e1b2715ee9 | ||
|
|
7ecd5ca55d | ||
|
|
931e7a4d37 | ||
|
|
1792410efe | ||
|
|
8cbd9224f1 | ||
|
|
24b552d619 | ||
|
|
68ae9326bf | ||
|
|
b4626f2787 | ||
|
|
2fc8ed78e4 | ||
|
|
236b25a235 | ||
|
|
a4f6af73ec | ||
|
|
fad74d6438 | ||
|
|
3e2d4c956d | ||
|
|
cd1d623390 | ||
|
|
9e0374d597 | ||
|
|
e47672b495 | ||
|
|
1905be8577 | ||
|
|
4726821e7d | ||
|
|
7ac37ddc1a | ||
|
|
ad10542b30 | ||
|
|
5331a38f10 | ||
|
|
c9943a2065 | ||
|
|
3889742e06 | ||
|
|
6bf3706455 | ||
|
|
612ecaff6c | ||
|
|
a85364ecff | ||
|
|
c0af03c503 | ||
|
|
9b61e4793b | ||
|
|
75a19e74a0 | ||
|
|
21d7e72b0c | ||
|
|
05d555eae5 | ||
|
|
8e412c3eb3 | ||
|
|
80147a9ebc | ||
|
|
3f6a3e25f1 | ||
|
|
800cbeef9d | ||
|
|
574f6a976f | ||
|
|
030b360e57 | ||
|
|
b883714192 | ||
|
|
d556f48168 | ||
|
|
cd7cac0eec | ||
|
|
9b31f18470 | ||
|
|
42a194b3d7 | ||
|
|
6748a7125e | ||
|
|
c2b3f29f3b | ||
|
|
572a634d90 | ||
|
|
652606ffb0 | ||
|
|
803537c63e | ||
|
|
4648c2d9af | ||
|
|
edceb3e7e9 | ||
|
|
da6bddcd77 | ||
|
|
b11f43e903 | ||
|
|
ef218a4d2e | ||
|
|
b061f27e7a | ||
|
|
8e64d54ab1 | ||
|
|
56b40a80ac | ||
|
|
d359d8ecb4 | ||
|
|
2bc55d00bb | ||
|
|
d3cf564b71 | ||
|
|
4fb8b97084 | ||
|
|
32c5cceb1d | ||
|
|
f38c14d6b5 | ||
|
|
3070ca0bc4 | ||
|
|
0122b3f717 | ||
|
|
79678fd82f | ||
|
|
034ddfbafb | ||
|
|
aebd26d03a | ||
|
|
d609823491 | ||
|
|
8f414f783a | ||
|
|
2e521553bf | ||
|
|
e93f5fc812 | ||
|
|
3dbbb7dfd5 | ||
|
|
fbb92e1023 | ||
|
|
ea4c6373f9 | ||
|
|
40b2569a21 | ||
|
|
ef6e4d8f0b | ||
|
|
28ae2ea501 | ||
|
|
657407c7a0 | ||
|
|
b254577bc8 | ||
|
|
63763bedc8 | ||
|
|
3d50d0fdb4 | ||
|
|
1ca6b18f5e | ||
|
|
b82ffc2af3 | ||
|
|
d142151055 | ||
|
|
91b78529fe | ||
|
|
7aec6884f4 | ||
|
|
7f140828bb | ||
|
|
4f13a56814 | ||
|
|
27d3ea253d | ||
|
|
5209b9899d | ||
|
|
6a40c836c0 | ||
|
|
c4df81bdef | ||
|
|
e99827d237 | ||
|
|
a0cbe8efd5 | ||
|
|
b4ee97a768 | ||
|
|
4bdaaaf1ce | ||
|
|
3cf0fea092 | ||
|
|
97e1451dc6 | ||
|
|
4cbb7724f2 | ||
|
|
8f6c2c82d3 | ||
|
|
a6d5001e84 | ||
|
|
6af180a313 | ||
|
|
86cc22d943 | ||
|
|
c1fbfd80d4 | ||
|
|
040a83fb17 | ||
|
|
2bc23a1446 | ||
|
|
97f4c911ed | ||
|
|
53d9a42a1a | ||
|
|
c96c5234c4 | ||
|
|
9a3eb7bc3e | ||
|
|
53f15ba8b8 | ||
|
|
ecdc74b5a6 | ||
|
|
422fdbe2cf | ||
|
|
887bc03f32 | ||
|
|
e32c0c70a8 | ||
|
|
440dfcadfd | ||
|
|
93cc0adb39 | ||
|
|
f8ec85ddae | ||
|
|
688333f756 | ||
|
|
8f314059e4 | ||
|
|
9386a08af0 | ||
|
|
19cd118f8f | ||
|
|
c196f98bc6 | ||
|
|
56ec258cc7 | ||
|
|
5da64a7da0 | ||
|
|
f272aeb9fe | ||
|
|
cf26b82d87 | ||
|
|
2041fb34c9 | ||
|
|
4b63240ab9 | ||
|
|
9d59479049 | ||
|
|
350cdfa436 | ||
|
|
15de64dcf5 | ||
|
|
d9c2519a83 | ||
|
|
9885e34f82 | ||
|
|
ed0adfbae1 | ||
|
|
beafb6c21b | ||
|
|
7810791991 | ||
|
|
1d10d5234f | ||
|
|
9900f46be4 | ||
|
|
0d2c4dfb3a | ||
|
|
752e27d97f | ||
|
|
33523fbe36 | ||
|
|
db47dd5110 | ||
|
|
a71097a8c9 | ||
|
|
931e448ebd | ||
|
|
abd8bf4a60 | ||
|
|
aee1f82d04 | ||
|
|
8112472df5 | ||
|
|
c9fa13b97b | ||
|
|
73cd301ff4 | ||
|
|
aa33ae0706 | ||
|
|
4e9c45c162 | ||
|
|
f35cea75d3 | ||
|
|
4053ceb9e5 | ||
|
|
448da35327 | ||
|
|
6d9c4c90ba | ||
|
|
5b8282e933 | ||
|
|
b1498aa664 | ||
|
|
2b28f021ee | ||
|
|
dc4938c377 | ||
|
|
69b846a856 | ||
|
|
1460396d4f | ||
|
|
b9804d9d48 | ||
|
|
ade7008127 | ||
|
|
da0235ab27 | ||
|
|
c17e832572 | ||
|
|
c12d6f01e7 | ||
|
|
778ad2ce20 | ||
|
|
33ef58ac97 | ||
|
|
8091ba9398 | ||
|
|
8e0bf9e991 | ||
|
|
daee82aa6a | ||
|
|
359a1fa3a9 | ||
|
|
021b32c1d4 | ||
|
|
1d1eb6a768 | ||
|
|
a9fd0718b0 | ||
|
|
6341a0a459 | ||
|
|
952b8b2eb2 | ||
|
|
b08d7f27d2 | ||
|
|
a71889021f | ||
|
|
367631af99 | ||
|
|
62753d1a50 | ||
|
|
dfe589e843 | ||
|
|
d09574bb17 | ||
|
|
2be12e5b37 | ||
|
|
d2086b6480 | ||
|
|
132668d04c | ||
|
|
0a4aa95965 | ||
|
|
af1e774d1f | ||
|
|
e5271d79a0 | ||
|
|
dfd714540e | ||
|
|
a0fd22be19 | ||
|
|
c0dc55b18e | ||
|
|
258def1cf8 | ||
|
|
b2095fd947 | ||
|
|
e51278f76e | ||
|
|
9af60063d8 | ||
|
|
37b523f989 | ||
|
|
96ba075e86 | ||
|
|
e86a3a3236 | ||
|
|
622a9ebab4 | ||
|
|
b26ec58f9f | ||
|
|
b41b2a1566 | ||
|
|
b893383353 | ||
|
|
ddcf3ed3f4 | ||
|
|
da05748393 | ||
|
|
976ad4ab17 | ||
|
|
8dcf19834c | ||
|
|
43315bb9cc | ||
|
|
4ab20d8088 | ||
|
|
485de32bb4 | ||
|
|
536b9726b2 | ||
|
|
41ae43e741 | ||
|
|
b5b49245fa | ||
|
|
d172ac7049 | ||
|
|
8808306a5f | ||
|
|
00dac577f6 | ||
|
|
85c218b350 | ||
|
|
6f71ef4d6b | ||
|
|
394cbdb454 | ||
|
|
62e2a7969d | ||
|
|
d9c284b54d | ||
|
|
bd2bc3659c | ||
|
|
f76fa01240 | ||
|
|
45d62f418c | ||
|
|
650325257b | ||
|
|
a0a8a61d56 | ||
|
|
998732287b | ||
|
|
509c7da384 | ||
|
|
771e03ce76 | ||
|
|
7d9b8dbdda | ||
|
|
912ae93d10 | ||
|
|
b613cc266a | ||
|
|
dfb8d4e7c6 | ||
|
|
b8e3ec4302 | ||
|
|
d4e21b7877 | ||
|
|
d10cf968f1 | ||
|
|
880ec7fc58 | ||
|
|
432b6b5dd7 | ||
|
|
5f5ad426bf | ||
|
|
52acdb9036 | ||
|
|
138b23674a | ||
|
|
8a710798f7 | ||
|
|
be5557080b | ||
|
|
994b9c6472 | ||
|
|
d05536bed4 | ||
|
|
cc4f1d7251 | ||
|
|
2ddd0965cd | ||
|
|
4e68e420cc | ||
|
|
50be8a9240 | ||
|
|
d1e330eee0 | ||
|
|
6aa5893b5f | ||
|
|
797d668ebb | ||
|
|
b23595ff54 | ||
|
|
7790c9700b | ||
|
|
6903f8385b | ||
|
|
e8205c6435 | ||
|
|
1d5192a39c | ||
|
|
04525e1258 | ||
|
|
c114856699 | ||
|
|
57a9a8495c | ||
|
|
53bb95e6fd | ||
|
|
a40fe3099d | ||
|
|
8d38ea0cf2 | ||
|
|
ac81c95f7e | ||
|
|
48b915b0b2 | ||
|
|
593917db9a | ||
|
|
2d49b49bec | ||
|
|
323c8b6845 | ||
|
|
e5ab30006b | ||
|
|
14b97cdbd9 | ||
|
|
8f0f0a5298 | ||
|
|
497dbc8eaa | ||
|
|
11baf14280 | ||
|
|
948e8690dd | ||
|
|
802c17d590 | ||
|
|
71e72b688f | ||
|
|
877b56ad67 | ||
|
|
87502fb17f | ||
|
|
ed3e141601 | ||
|
|
f66d3ed3aa | ||
|
|
5488e45c78 | ||
|
|
72bd66d3f5 | ||
|
|
1378441dfa | ||
|
|
26d97b8cdf | ||
|
|
2e27b812d6 | ||
|
|
fd97ac18da | ||
|
|
b9d14a2711 | ||
|
|
1c9042c496 | ||
|
|
60fa4b9ee0 | ||
|
|
4c536b41bc | ||
|
|
33f91af1af | ||
|
|
05d86e89da | ||
|
|
a02176fc63 | ||
|
|
55ced3ecc7 | ||
|
|
4a81b560f9 | ||
|
|
6a7cd31ab4 | ||
|
|
2515db31d8 | ||
|
|
54a66f9ab2 | ||
|
|
0856858e73 | ||
|
|
23131a301b | ||
|
|
aef7363bee | ||
|
|
d579b257a8 | ||
|
|
4455347930 | ||
|
|
5709cfebd4 | ||
|
|
01184bee72 | ||
|
|
8a8f6338c5 | ||
|
|
71207e8f57 | ||
|
|
749f5b8e8f | ||
|
|
88c1be09c2 | ||
|
|
c1b59256be | ||
|
|
a3f57665a9 | ||
|
|
b8d29ca831 | ||
|
|
90880ff4d1 | ||
|
|
286ef77663 | ||
|
|
0bb8b72183 | ||
|
|
28b9073010 | ||
|
|
fe97e29654 | ||
|
|
792e782e8c | ||
|
|
33b99a97e4 | ||
|
|
91ab85c825 | ||
|
|
8c75b9316d | ||
|
|
9870ddbe86 | ||
|
|
c7eb101920 | ||
|
|
2b171aef7c | ||
|
|
ec0fe0b047 | ||
|
|
bbfa81f051 | ||
|
|
bd5bef279c | ||
|
|
afa95d5d34 | ||
|
|
fb331710e1 | ||
|
|
224dce1b76 | ||
|
|
a582f0229f | ||
|
|
a8e5a9b453 | ||
|
|
2d69536489 | ||
|
|
ebd33c4c16 | ||
|
|
3f5cf06bd9 | ||
|
|
1ec9cfb772 | ||
|
|
050175802f | ||
|
|
19a1be1f74 | ||
|
|
093593dcef | ||
|
|
51f28a386b | ||
|
|
4065bd5e11 | ||
|
|
3e1746fc6e | ||
|
|
3b6dd856aa | ||
|
|
635ea3f231 | ||
|
|
48d1c62fed | ||
|
|
e97f2f3fc6 | ||
|
|
19b016a3dd | ||
|
|
576e160372 | ||
|
|
e586e0479d | ||
|
|
0b5c866df6 | ||
|
|
9828fb3934 | ||
|
|
430f443916 | ||
|
|
d32e0eb5ab | ||
|
|
f72750576f | ||
|
|
e96b78b175 | ||
|
|
4708110804 | ||
|
|
2725b82543 | ||
|
|
1eafae6c6f | ||
|
|
11e25a21fa | ||
|
|
51eda4e755 | ||
|
|
847c39749d | ||
|
|
cb0975fa69 | ||
|
|
5b977733b3 | ||
|
|
c3d13a9890 | ||
|
|
bc4c04f795 | ||
|
|
32d5240e5d | ||
|
|
64f423f3d1 | ||
|
|
18d0e974e4 | ||
|
|
c259f2dc72 | ||
|
|
5223fdf4ae | ||
|
|
a4132bd9bc | ||
|
|
bf8d147ca5 | ||
|
|
5116d645db | ||
|
|
a2850cac6b | ||
|
|
ffed4efdec | ||
|
|
cfa71927de | ||
|
|
5d7a60206e | ||
|
|
3556fef5ed | ||
|
|
252965a5d9 | ||
|
|
a7a25c0798 | ||
|
|
944087649f | ||
|
|
69c9db6dda | ||
|
|
f5e86a8d25 | ||
|
|
6a89357b54 | ||
|
|
64c8f8fc3e | ||
|
|
54ff56b021 | ||
|
|
3d3ad89fba | ||
|
|
7ee140c8c8 | ||
|
|
8afd6ccee4 | ||
|
|
e427294ec1 | ||
|
|
18283ccbc6 | ||
|
|
b7857c8462 | ||
|
|
2d231806d2 | ||
|
|
36b58333ca | ||
|
|
fc77af598d | ||
|
|
602295ae89 | ||
|
|
1c295a88ac | ||
|
|
232535faf9 | ||
|
|
10b5dee40f | ||
|
|
be48459092 | ||
|
|
cb6199c1a8 | ||
|
|
c9eb087ade | ||
|
|
87e223a854 | ||
|
|
7c7118dfad | ||
|
|
fdcd6c6dfe | ||
|
|
205cbcf05d | ||
|
|
c9ccbb2750 | ||
|
|
eacfc4b623 | ||
|
|
d3dafd4ce1 | ||
|
|
8004b96c41 | ||
|
|
7cc58d9fac | ||
|
|
f82ae6c091 | ||
|
|
6ab029e692 | ||
|
|
2c3536afc9 | ||
|
|
0fe95e91d5 | ||
|
|
cadd98dc59 | ||
|
|
92f99c3780 | ||
|
|
f1d397f908 | ||
|
|
eeaa6b478b | ||
|
|
53d6b54de8 | ||
|
|
ffd6abbe95 | ||
|
|
f08421a48c | ||
|
|
a383d1ebf8 | ||
|
|
d355095e16 | ||
|
|
a81d992552 | ||
|
|
eb13518b96 | ||
|
|
bf6e180291 | ||
|
|
fcad7a5733 | ||
|
|
7ffdf1631c | ||
|
|
a5ad5e67f3 | ||
|
|
4b3b1f7786 | ||
|
|
844e89a652 | ||
|
|
d88af9ffd9 | ||
|
|
7a3a9ba559 | ||
|
|
5d3910da49 | ||
|
|
f740d34f1f | ||
|
|
58ca70c511 | ||
|
|
ee59540648 | ||
|
|
9e97b8f5a1 | ||
|
|
95968c3d95 | ||
|
|
85c242ff0e | ||
|
|
18783e7ea5 | ||
|
|
7bc4846c0a | ||
|
|
49c4406bb4 | ||
|
|
fedf2229a7 | ||
|
|
2e5e2e9f0d | ||
|
|
fa25ec4a26 | ||
|
|
0ef9f5fc6c | ||
|
|
3df9040cfb | ||
|
|
bd3a74954c | ||
|
|
69b9a1fa5c | ||
|
|
287d9e94cf | ||
|
|
24862a26f2 | ||
|
|
a319428489 | ||
|
|
11881b3b73 | ||
|
|
5a6ee174af | ||
|
|
9183beeed4 | ||
|
|
e5537fdff0 | ||
|
|
9e0490d371 | ||
|
|
2b2a09e36d | ||
|
|
5ff36fe2ec | ||
|
|
9440085169 | ||
|
|
5c24077a30 | ||
|
|
68a8eabbbb | ||
|
|
a038333cce | ||
|
|
a5304fe74c | ||
|
|
aaf564b35c | ||
|
|
de087f743f | ||
|
|
21a8e441d2 | ||
|
|
32fc4556b1 | ||
|
|
238856ed89 | ||
|
|
8f6a236eb6 | ||
|
|
d9ce826b9d | ||
|
|
76cc1d47f6 | ||
|
|
a3d0983d33 | ||
|
|
245a7b59c4 | ||
|
|
8b714edb67 | ||
|
|
2a3d532881 | ||
|
|
5555ee278e | ||
|
|
451c7fb956 | ||
|
|
391b3b9e4f | ||
|
|
130a8edcef | ||
|
|
5fd3a56a31 | ||
|
|
b682284a2a | ||
|
|
d1676ac2e0 | ||
|
|
2cb3397d75 | ||
|
|
936f4fe254 | ||
|
|
f611213662 | ||
|
|
ff0352cfe6 | ||
|
|
4d6dfea3a5 | ||
|
|
be386e1172 | ||
|
|
2a2fbd18cd | ||
|
|
56159e91ce | ||
|
|
3675f4d7cd | ||
|
|
3a129d3c4f | ||
|
|
cc4e7197ba | ||
|
|
fc5677e7b5 | ||
|
|
19542c1640 | ||
|
|
68b5acc154 | ||
|
|
5c2c9e2a8f | ||
|
|
0376e11544 | ||
|
|
6d910ffb60 | ||
|
|
32f6310947 | ||
|
|
f464a52ea4 | ||
|
|
e3d755fb9a | ||
|
|
e05e05d866 | ||
|
|
b7ff1cd579 | ||
|
|
0550f4e28a | ||
|
|
3456dc90d8 | ||
|
|
8e006cf853 | ||
|
|
0e36af38d8 | ||
|
|
e10f3e2285 | ||
|
|
31f1614679 | ||
|
|
80e7eca064 | ||
|
|
adb85e349a | ||
|
|
52a241c1ec | ||
|
|
d092016729 | ||
|
|
11607e7e7d | ||
|
|
2d01f801bc | ||
|
|
6e15373ce9 | ||
|
|
e95ed5ad2b | ||
|
|
dc9324f322 | ||
|
|
e7adf8cfb2 | ||
|
|
5f7c49ca85 | ||
|
|
f724335b91 | ||
|
|
3a5dfbc842 | ||
|
|
380a1b66e6 | ||
|
|
c6cccf2d93 | ||
|
|
0858a19138 | ||
|
|
f42199aec0 | ||
|
|
8d746427a6 | ||
|
|
3c9b2b90d4 | ||
|
|
abc959a814 | ||
|
|
c71c289547 | ||
|
|
02bb942abd | ||
|
|
a37c33ec36 | ||
|
|
0e4926426f | ||
|
|
a309db8739 | ||
|
|
1a998581ef | ||
|
|
f49b951331 | ||
|
|
26e16ffeda | ||
|
|
9e4a72e098 | ||
|
|
a7d053648a | ||
|
|
61a55f71f5 | ||
|
|
9979d4abda | ||
|
|
5a2af47eda | ||
|
|
eab6b99155 | ||
|
|
4acba4d48a | ||
|
|
8b5a43e435 | ||
|
|
26fce03d0f | ||
|
|
1a22bfbcef | ||
|
|
050783fc8b | ||
|
|
d96d8fb4fc | ||
|
|
4b32c34ebd | ||
|
|
927bf12243 | ||
|
|
a867791165 | ||
|
|
67232094c9 | ||
|
|
b5e79abf08 | ||
|
|
84c0fd7414 | ||
|
|
850a7d8676 | ||
|
|
ded24e8037 | ||
|
|
71fbf5705c | ||
|
|
87b78717f3 | ||
|
|
1cd9a34761 | ||
|
|
b9072cccba | ||
|
|
18fb3a68fd | ||
|
|
c0b89e51d7 | ||
|
|
f2ac2595f9 | ||
|
|
b241007d4f | ||
|
|
2b1af40bd1 | ||
|
|
66f85a1f35 | ||
|
|
22633d6130 | ||
|
|
8ed4d838ee | ||
|
|
9175916771 | ||
|
|
7acf2b9cac | ||
|
|
965d8791d8 | ||
|
|
f961e6aa6b | ||
|
|
b8182cfde5 | ||
|
|
78f0e367dc | ||
|
|
aca0224263 | ||
|
|
c74636e2c0 | ||
|
|
f113bc5b8a | ||
|
|
befae8b191 | ||
|
|
1767e8f074 | ||
|
|
44081b772f | ||
|
|
3051eddd2e | ||
|
|
5266aa7547 | ||
|
|
7e57f61947 | ||
|
|
1c587d3726 | ||
|
|
b4ea97ce37 | ||
|
|
83c1a5789a | ||
|
|
841026661a | ||
|
|
692441e1d5 | ||
|
|
46ba555a20 | ||
|
|
de18432a7d | ||
|
|
497b6cb59c | ||
|
|
c073ecf0dd | ||
|
|
2ea4db8e38 | ||
|
|
fe942100a4 | ||
|
|
79eb1428b0 | ||
|
|
467365dcbb | ||
|
|
33a323fe85 | ||
|
|
4ad9e77a7e | ||
|
|
5d57347730 | ||
|
|
54572de8d9 | ||
|
|
0e57a0804a | ||
|
|
95077f639b | ||
|
|
493dcc7ef7 | ||
|
|
f86b16735b | ||
|
|
0c1de20a1a | ||
|
|
e9d0f706ed | ||
|
|
d297718358 | ||
|
|
b406b36cda | ||
|
|
570732a9b2 | ||
|
|
92b5507e0e | ||
|
|
73897b8ee7 | ||
|
|
2d9cdc5a24 | ||
|
|
234e5bc5fc | ||
|
|
664496b430 | ||
|
|
67d92bd070 | ||
|
|
d6e53cc005 | ||
|
|
2c77712ab4 | ||
|
|
10c1eff1b6 | ||
|
|
4c26465dde | ||
|
|
d29e5f49f4 | ||
|
|
0191558d26 | ||
|
|
d3692bcc09 | ||
|
|
befa83bee8 | ||
|
|
b4347e5701 | ||
|
|
c4ed6c2b97 | ||
|
|
6b5f650aac | ||
|
|
63b38c1f53 | ||
|
|
33b6f0d72e | ||
|
|
a6f8070f65 | ||
|
|
29aaaf55cf | ||
|
|
b47da137c1 | ||
|
|
8e6552ee9c | ||
|
|
024e016df2 | ||
|
|
97dd8a1257 | ||
|
|
83fc339c4b | ||
|
|
693c535428 | ||
|
|
d74f2eba92 | ||
|
|
d0ec941009 | ||
|
|
178528508b | ||
|
|
20a31b39e0 | ||
|
|
fc252d5e7e | ||
|
|
4090266989 | ||
|
|
19b7d29483 | ||
|
|
af4e3884bb | ||
|
|
d3742bb410 | ||
|
|
75cb1a5fdd | ||
|
|
8436c878e8 | ||
|
|
63d3a34f46 | ||
|
|
6cda97c335 | ||
|
|
a40d8b8bc5 | ||
|
|
15a492cfa3 | ||
|
|
445e882579 | ||
|
|
d4b155d0c2 | ||
|
|
65f4960302 | ||
|
|
dc9e8d406d | ||
|
|
4d76006c2d | ||
|
|
731a6d0410 | ||
|
|
e4542aa451 | ||
|
|
ecc4a29be4 | ||
|
|
0f0b3d6df5 | ||
|
|
a826c1725b | ||
|
|
4e3b461fd3 | ||
|
|
d8a9dfafb2 | ||
|
|
ede621bea7 | ||
|
|
2f7da8356f | ||
|
|
d555cb2c94 | ||
|
|
750d70bfff | ||
|
|
dcc205ec4f | ||
|
|
356756286e | ||
|
|
79511d9b42 | ||
|
|
bff2df018b | ||
|
|
2562a218a0 | ||
|
|
d46b7e4aaf | ||
|
|
dee7ee1dde | ||
|
|
01fc339da5 | ||
|
|
ef46cd9b45 | ||
|
|
ac3ccb287b | ||
|
|
f52292e8d1 | ||
|
|
693c9858c2 | ||
|
|
c8d5e9d9d2 | ||
|
|
50668817db | ||
|
|
91758b61c3 | ||
|
|
39ae92a0fa | ||
|
|
95c203793c | ||
|
|
c7ac974ab9 | ||
|
|
51931d2b01 | ||
|
|
d271f6d46d | ||
|
|
efcd48f1d9 | ||
|
|
76daa583b3 | ||
|
|
3425a85fd0 | ||
|
|
9a6c1510fd | ||
|
|
44c391cb5a | ||
|
|
6085be7589 | ||
|
|
7d9bf8c729 | ||
|
|
1d72457dc1 | ||
|
|
0e32d2b1b4 | ||
|
|
75165e8838 | ||
|
|
d9536f1294 | ||
|
|
44e4c3ddc5 | ||
|
|
f67755f3b5 | ||
|
|
68d768cbd3 | ||
|
|
0be268c01f | ||
|
|
1831db530d | ||
|
|
8a32bf21d0 | ||
|
|
81c5bb4d52 | ||
|
|
93796bf4a8 | ||
|
|
4c34113f78 | ||
|
|
e4b189a06e | ||
|
|
0ebc885eb1 | ||
|
|
b4658ddf76 | ||
|
|
b38e2964ca | ||
|
|
5021e512b9 | ||
|
|
6d927540c8 | ||
|
|
6168767766 | ||
|
|
5af200a29d | ||
|
|
8b333c1ab5 | ||
|
|
d1f34ec136 | ||
|
|
c887a0d2b5 | ||
|
|
1168ba4557 | ||
|
|
e389420f07 | ||
|
|
0590beb876 | ||
|
|
d30c0d0213 | ||
|
|
eb774d37c6 | ||
|
|
cade6d5e0b | ||
|
|
19b71c5782 | ||
|
|
5f802a8179 | ||
|
|
99e1141446 | ||
|
|
3bd76b4fb5 | ||
|
|
3fb4ef34f4 | ||
|
|
f7c2abdcd7 | ||
|
|
cc6006e226 | ||
|
|
2816c2bcf5 | ||
|
|
abc8061cd7 | ||
|
|
a30c4d6be5 | ||
|
|
0bd5b6ba5d | ||
|
|
4ea3a500e8 | ||
|
|
56925c1eed | ||
|
|
71e7269927 | ||
|
|
6babff1be1 | ||
|
|
fec000086f | ||
|
|
bddf4cedb4 | ||
|
|
91c62e208b | ||
|
|
1e0424a83f | ||
|
|
c74d29e020 | ||
|
|
eadfff9cd0 | ||
|
|
93e30a8542 | ||
|
|
85ccc663c8 | ||
|
|
dab02823ff | ||
|
|
4fccfbf51d | ||
|
|
b04e322df8 | ||
|
|
f550822943 | ||
|
|
564fd20f23 | ||
|
|
45e38a9a2d | ||
|
|
e51f1e0a82 | ||
|
|
b4b82906ea | ||
|
|
a254ac87f7 | ||
|
|
ae8727ad96 | ||
|
|
de823f0430 | ||
|
|
c6ced0b1ea | ||
|
|
e76a883053 | ||
|
|
f967e96aa5 | ||
|
|
c8713a7f38 | ||
|
|
73e274cf0b | ||
|
|
c75c3d0734 | ||
|
|
e74b253f64 | ||
|
|
45009aedff | ||
|
|
870ba65662 | ||
|
|
80ace33af1 | ||
|
|
f69455bdb7 | ||
|
|
4ed6dc276e | ||
|
|
3dd415697a | ||
|
|
f7ce368b28 | ||
|
|
168236780d | ||
|
|
549e9ccd0b | ||
|
|
21f31b403b | ||
|
|
3b42503bd3 | ||
|
|
95e15fc40c | ||
|
|
74e546c2ce | ||
|
|
0c0f97560e | ||
|
|
8392f6f5a6 | ||
|
|
9a5ede0e6d | ||
|
|
33417454ed | ||
|
|
d79237958f | ||
|
|
6ef06467b6 | ||
|
|
a85d2222eb | ||
|
|
2325d24d6f | ||
|
|
4397e07d7f | ||
|
|
f5a624cfb2 | ||
|
|
d2762fae73 | ||
|
|
22d7107305 | ||
|
|
e22df23bc9 | ||
|
|
200ef9a45e | ||
|
|
783194e253 | ||
|
|
204868d733 | ||
|
|
f61a710e9b | ||
|
|
457731700c | ||
|
|
3dcb08cca3 | ||
|
|
e3f1ff7d70 | ||
|
|
623b506691 | ||
|
|
6e5dbc0b83 | ||
|
|
9c40a22c50 | ||
|
|
9dbd1d9bda | ||
|
|
9693b017c4 | ||
|
|
670915ab36 | ||
|
|
8224913b01 | ||
|
|
2b577f9755 | ||
|
|
4556c9a055 | ||
|
|
679ce8b6ab | ||
|
|
59eeb60594 | ||
|
|
6c4f9b2c03 | ||
|
|
f6e2037a1b | ||
|
|
0c9d4a5de4 | ||
|
|
5006c9d6ea | ||
|
|
17a8c4f3d5 | ||
|
|
98cb1c2315 | ||
|
|
6cc5aa08e3 | ||
|
|
ebda3865dc | ||
|
|
fb171a459e | ||
|
|
027a249837 | ||
|
|
2a2bb7199e | ||
|
|
f64892d010 | ||
|
|
d023d7f3e4 | ||
|
|
ef96bfa98c | ||
|
|
b2ee46804b | ||
|
|
7c9c277cf8 | ||
|
|
3e376ebc74 | ||
|
|
102ea2da7a | ||
|
|
e1a2fbfaa6 | ||
|
|
c1aecf2b37 | ||
|
|
b2754e3036 | ||
|
|
abbb740753 | ||
|
|
7504224c2f | ||
|
|
57b990409a | ||
|
|
cff5e06d62 | ||
|
|
a543b409cb | ||
|
|
e57d2f4afa | ||
|
|
9da0173e05 | ||
|
|
a21b171d96 | ||
|
|
2569e7ed8e | ||
|
|
25d2eade8c | ||
|
|
43b949966d | ||
|
|
08205b96cd | ||
|
|
e2e63bbfc8 | ||
|
|
24d1a7dd67 | ||
|
|
9b4e46b625 | ||
|
|
e47a335dec | ||
|
|
d46f7023d5 | ||
|
|
19bef60752 | ||
|
|
5ff73657e1 | ||
|
|
fb8da04a18 | ||
|
|
3ee50a290f | ||
|
|
71ea05598f | ||
|
|
96d5c71e0d | ||
|
|
07318eb7aa | ||
|
|
2ef235dddd | ||
|
|
f7cc9865cc | ||
|
|
c323ce6cbb | ||
|
|
5d2ddc490a | ||
|
|
40463290a6 | ||
|
|
6b4faac2cb | ||
|
|
077a7de605 | ||
|
|
180bc06c06 | ||
|
|
72a97ecbd6 | ||
|
|
87a6ed3e46 | ||
|
|
95d8e777db | ||
|
|
d028ecfc55 | ||
|
|
225da821e4 | ||
|
|
7cd4023f5c | ||
|
|
2379832cc2 | ||
|
|
cb46e090dd | ||
|
|
a656f0f304 | ||
|
|
564fa313f1 | ||
|
|
47cd618bf4 | ||
|
|
ae709a1d9b | ||
|
|
0812d96068 | ||
|
|
86911933db | ||
|
|
69d5c139f6 | ||
|
|
405b9a19f9 | ||
|
|
c4a696cbc4 | ||
|
|
bb0e4997de | ||
|
|
bc1b908063 | ||
|
|
29c522484c | ||
|
|
5b6585b115 | ||
|
|
3715c69c02 | ||
|
|
3d3b457c92 | ||
|
|
e4f5d44658 | ||
|
|
fc7a25ca4d | ||
|
|
1d3a44a157 | ||
|
|
319b44f153 | ||
|
|
98a4144403 | ||
|
|
a819140c88 | ||
|
|
cba5c65608 | ||
|
|
eff4a3abcb | ||
|
|
2e0ccef3f5 | ||
|
|
429a157715 | ||
|
|
76065ee93f | ||
|
|
97def2240f | ||
|
|
15cd18a5c4 | ||
|
|
0b3b095eac | ||
|
|
38bda12c4b | ||
|
|
d2a34226a6 | ||
|
|
92dcb29010 | ||
|
|
d4cc869227 | ||
|
|
291ff86686 | ||
|
|
895ad62757 | ||
|
|
4acfa36b57 | ||
|
|
fe18256c25 | ||
|
|
39531eb4f0 | ||
|
|
28d73b44a6 | ||
|
|
3983a8a1ba | ||
|
|
08151e7e21 | ||
|
|
446927f947 | ||
|
|
5d72904849 | ||
|
|
ff1f076536 | ||
|
|
c56766ef85 | ||
|
|
eff8953207 | ||
|
|
2ba1ae7a23 |
184
ChangeLog.md
Normal file
184
ChangeLog.md
Normal 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
280
README.md
@@ -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` (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 "official/hello_world"` to your `~/.config/darktable/luarc` file which will enable the example script in `official/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
225
contrib/AutoGrouper.lua
Normal 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
258
contrib/CollectHelper.lua
Normal 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
486
contrib/HDRMerge.lua
Normal 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
296
contrib/LabelsToTags.lua
Normal 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
261
contrib/OpenInExplorer.lua
Normal 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
272
contrib/RL_out_sharp.lua
Normal 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
132
contrib/auto_snapshot.lua
Normal 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
|
||||
129
contrib/auto_tag_modified.lua
Normal file
129
contrib/auto_tag_modified.lua
Normal 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
|
||||
@@ -28,6 +28,8 @@ USAGE
|
||||
> exiftool -AutoDynamicRange XE021351.RAF
|
||||
Auto Dynamic Range : 200%
|
||||
|
||||
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
|
||||
* exiftool
|
||||
|
||||
LICENSE
|
||||
GPLv2
|
||||
@@ -35,91 +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})
|
||||
|
||||
-- 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
|
||||
local script_data = {}
|
||||
|
||||
-- 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
|
||||
local have_not_printed_config_message = true
|
||||
|
||||
-- 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
|
||||
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/"
|
||||
}
|
||||
|
||||
|
||||
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'))
|
||||
-- yield to other lua threads until data is ready to be read
|
||||
coroutine.yield("FILE_READABLE",fd)
|
||||
darktable.control.read(fd)
|
||||
-- slurp the whole file
|
||||
local data = assert(fd:read('*a'))
|
||||
|
||||
@@ -133,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
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
Copyright 2014 by Tobias Jakobs.
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
darktable calc distance script
|
||||
|
||||
This script calcs the distance between two images using the GPS data in the metadata
|
||||
|
||||
USAGE
|
||||
* require this script from your main lua file
|
||||
* register a shortcut
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
dt.configuration.check_version(...,{2,0,1})
|
||||
|
||||
local function calcDistance()
|
||||
local sel_images = dt.gui.selection()
|
||||
|
||||
local lat1 = 0;
|
||||
local lon1 = 0;
|
||||
local lat2 = 0;
|
||||
local lon2 = 0;
|
||||
local i = 0;
|
||||
|
||||
local sel_images = dt.gui.selection()
|
||||
|
||||
for _,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
|
||||
|
||||
i = i + 1;
|
||||
|
||||
if (i == 1) then
|
||||
lat1 = image.latitude;
|
||||
lon1 = image.longitude;
|
||||
end
|
||||
|
||||
lat2 = image.latitude;
|
||||
lon2 = image.longitude;
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
-- I used code from here:
|
||||
-- http://stackoverflow.com/questions/27928/how-do-i-calculate-distance-between-two-latitude-longitude-points
|
||||
|
||||
local earthRadius = 6371; -- Radius of the earth in km
|
||||
local dLat = math.rad(lat2-lat1); -- deg2rad below
|
||||
local dLon = math.rad(lon2-lon1);
|
||||
local a =
|
||||
math.sin(dLat/2) * math.sin(dLat/2) +
|
||||
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 distance = earthRadius * angle; -- Distance in km
|
||||
|
||||
dt.print(distance.." km")
|
||||
|
||||
|
||||
end
|
||||
|
||||
-- Register
|
||||
dt.register_event("shortcut",calcDistance,"Calculate the distance from latitude and longitude in km")
|
||||
205
contrib/change_group_leader.lua
Normal file
205
contrib/change_group_leader.lua
Normal 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
|
||||
97
contrib/clear_GPS.lua
Normal file
97
contrib/clear_GPS.lua
Normal file
@@ -0,0 +1,97 @@
|
||||
--[[
|
||||
|
||||
clear_GPS.lua - plugin for Darktable
|
||||
|
||||
Copyright (C) 2016 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/>.
|
||||
]]
|
||||
--[[
|
||||
clear_GPS - clear GPS data from selected image(s)
|
||||
|
||||
This shortcut removes the GPS coordinate data from the selected images.
|
||||
|
||||
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
|
||||
* None
|
||||
|
||||
USAGE
|
||||
* require this script from your main lua file
|
||||
* select an image or images
|
||||
* click the shortcut, clear GPS data
|
||||
|
||||
BUGS, COMMENTS, SUGGESTIONS
|
||||
* Send to Bill Ferguson, wpferguson@gmail.com
|
||||
|
||||
CHANGES
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
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
|
||||
|
||||
du.check_min_api_version("7.0.0", "clear_GPS")
|
||||
|
||||
local function clear_GPS(images)
|
||||
for _, image in ipairs(images) do
|
||||
-- set the location information to Not a Number (NaN) so it displays correctly
|
||||
image.elevation = NaN
|
||||
image.latitude = NaN
|
||||
image.longitude = NaN
|
||||
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", _("clear GPS data"),
|
||||
function(event, images) clear_GPS(images) end,
|
||||
_("clear GPS data from selected images")
|
||||
)
|
||||
|
||||
dt.register_event(
|
||||
"clear_GPS", "shortcut",
|
||||
function(event, shortcut) clear_GPS(dt.gui.action_images) end,
|
||||
_("clear GPS data from selected images")
|
||||
)
|
||||
|
||||
return script_data
|
||||
377
contrib/color_profile_manager.lua
Normal file
377
contrib/color_profile_manager.lua
Normal 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
|
||||
@@ -1,6 +1,7 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
copyright 2014-2015 by Christian Kanzian.
|
||||
Copyright 2014-2016 by Christian Kanzian
|
||||
Copyright 2016 by 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
|
||||
@@ -17,8 +18,9 @@
|
||||
]]
|
||||
|
||||
--[[
|
||||
(MULTI-)COPY ATTACH DETACH TAG
|
||||
A simple script that will create three shortcuts to copy, attach and detach image tags.
|
||||
(MULTI-)COPY ATTACH DETACH REPLACE TAGS
|
||||
This script that will create four shortcuts and add a modul in lighttable mode to copy,
|
||||
paste, replace and remove tags from images.
|
||||
|
||||
INSTALATION
|
||||
* copy this file in $CONFIGDIR/lua/ where CONFIGDIR is your darktable configuration directory
|
||||
@@ -27,17 +29,53 @@ INSTALATION
|
||||
USAGE
|
||||
* set the shortcuts for copy, attach and detach in the preferences dialog
|
||||
* <your shortcut1> copy will create a list of tags from all selected images
|
||||
* <your shortcut2> attaches copied tags to selected images, whereby
|
||||
* <your shortcut2> paste copied tags to selected images, whereby
|
||||
darktable internal tags starting with 'darktable|' will not be touched
|
||||
* <your shortcut3> detach removes all expect darktable internal tags from selected images
|
||||
|
||||
* <your shortcut3> removes all expect darktable internal tags from selected images
|
||||
* <your shortcut4> replaces all tags expect darktable internals
|
||||
* A module reset will empty the clipboard
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
dt.configuration.check_version(...,{2,0,0})
|
||||
local du = require "lib/dtutils"
|
||||
local debug = require "darktable.debug"
|
||||
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
du.check_min_api_version("7.0.0", "copy_attach_detach_tags")
|
||||
|
||||
local function _(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 = {}
|
||||
|
||||
|
||||
local taglist_label = dt.new_widget("label"){selectable = true, ellipsize = "middle", halign = "start"}
|
||||
taglist_label.label = ""
|
||||
|
||||
local function mcopy_tags()
|
||||
local sel_images = dt.gui.action_images
|
||||
local tag_list_tmp = {}
|
||||
@@ -56,7 +94,7 @@ local function mcopy_tags()
|
||||
|
||||
--remove duplicate and 'darktable|' tags create final image_tags
|
||||
for _,k in ipairs(tag_list_tmp) do
|
||||
|
||||
|
||||
if not string.match(tostring(k), 'darktable|') then
|
||||
if not hash[k] then
|
||||
image_tags[#image_tags+1] = k
|
||||
@@ -65,23 +103,38 @@ local function mcopy_tags()
|
||||
end
|
||||
end
|
||||
|
||||
dt.print("Image tags copied ...")
|
||||
return(image_tags)
|
||||
dt.print(_('image tags copied ...'))
|
||||
|
||||
--create UI tag list
|
||||
local taglist = ""
|
||||
|
||||
for _,tag in ipairs(image_tags) do
|
||||
if taglist == "" then
|
||||
taglist = tostring(tag)
|
||||
else
|
||||
taglist = taglist.."\n"..tostring(tag)
|
||||
end
|
||||
end
|
||||
|
||||
taglist_label.label = taglist
|
||||
|
||||
return(image_tags)
|
||||
end
|
||||
|
||||
|
||||
-- attach copied tags to all selected images
|
||||
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
|
||||
|
||||
|
||||
local sel_images = dt.gui.action_images
|
||||
|
||||
for _,image in ipairs(sel_images) do
|
||||
local present_image_tags = {}
|
||||
present_image_tags = dt.tags.get_tags(image)
|
||||
|
||||
|
||||
for _,ct in ipairs(image_tags) do
|
||||
-- check if image has tags and attach
|
||||
if next(present_image_tags) == nil then
|
||||
@@ -96,43 +149,175 @@ local function attach_tags()
|
||||
end
|
||||
end
|
||||
end
|
||||
dt.print("Tags attached ...")
|
||||
dt.print(_('tags attached ...'))
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
local function detach_tags()
|
||||
local sel_images = dt.gui.action_images
|
||||
|
||||
for _,image in ipairs(sel_images) do
|
||||
local present_image_tags = {}
|
||||
present_image_tags = dt.tags.get_tags(image)
|
||||
|
||||
|
||||
for _,present_tag in ipairs(present_image_tags) do
|
||||
if not string.match(tostring(present_tag), 'darktable|') then
|
||||
dt.tags.detach(present_tag,image)
|
||||
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'))
|
||||
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
|
||||
taglist_label.reset_callback = mcopy_tags
|
||||
|
||||
-- create buttons and elements
|
||||
local taglabel = dt.new_widget("label") {
|
||||
label = _('tag clipboard'),
|
||||
selectable = false,
|
||||
ellipsize = "middle",
|
||||
halign = "start"}
|
||||
|
||||
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
|
||||
|
||||
cadt.widget_table[1] = box1
|
||||
cadt.widget_table[#cadt.widget_table+1] = box2
|
||||
|
||||
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
|
||||
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)")
|
||||
_('copy tags from selected image(s)'))
|
||||
|
||||
-- shortcut for attach
|
||||
dt.register_event("shortcut",
|
||||
dt.register_event("cadt_at", "shortcut",
|
||||
attach_tags,
|
||||
"attach tags to selected image(s)")
|
||||
_('paste tags to selected image(s)'))
|
||||
|
||||
-- shortcut for detaching tags
|
||||
dt.register_event("shortcut",
|
||||
dt.register_event("cadt_dt", "shortcut",
|
||||
detach_tags,
|
||||
"detach tags to selected image(s)")
|
||||
_('remove tags from selected image(s)'))
|
||||
|
||||
-- shortcut for replace tags
|
||||
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;
|
||||
|
||||
@@ -33,9 +33,31 @@ USAGE
|
||||
]]
|
||||
|
||||
local darktable = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
-- Tested with darktable 1.6.2
|
||||
darktable.configuration.check_version(...,{2,0,2})
|
||||
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 = coroutine.yield("RUN_COMMAND", "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
|
||||
|
||||
162
contrib/cycle_group_leader.lua
Normal file
162
contrib/cycle_group_leader.lua
Normal 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
|
||||
334
contrib/dbmaint.lua
Normal file
334
contrib/dbmaint.lua
Normal 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
1175
contrib/enfuseAdvanced.lua
Normal file
File diff suppressed because it is too large
Load Diff
204
contrib/exportLUT.lua
Normal file
204
contrib/exportLUT.lua
Normal 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
515
contrib/ext_editor.lua
Normal 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;
|
||||
540
contrib/face_recognition.lua
Normal file
540
contrib/face_recognition.lua
Normal 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
|
||||
156
contrib/fujifilm_dynamic_range.lua
Normal file
156
contrib/fujifilm_dynamic_range.lua
Normal 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
|
||||
95
contrib/fujifilm_ratings.lua
Normal file
95
contrib/fujifilm_ratings.lua
Normal file
@@ -0,0 +1,95 @@
|
||||
--[[ fujifilm_ratings-0.1
|
||||
|
||||
Support for importing Fujifilm in-camera ratings in darktable.
|
||||
|
||||
Copyright (C) 2017 Ben Mendis <ben.mendis@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 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.
|
||||
|
||||
Dependencies:
|
||||
- exiftool (https://www.sno.phy.queensu.ca/~phil/exiftool/)
|
||||
|
||||
--]]
|
||||
|
||||
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_ratings")
|
||||
|
||||
local function _(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 string.match(image.filename, "%.RAF$") and not string.match(image.filename, "%.raf$") then
|
||||
return
|
||||
end
|
||||
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_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_log("using JPEG rating: " .. jpeg_result)
|
||||
return
|
||||
end
|
||||
command = "exiftool -Rating " .. RAF_filename
|
||||
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_log("using RAF rating: " .. raf_result)
|
||||
end
|
||||
end
|
||||
|
||||
local function destroy()
|
||||
dt.destroy_event("fujifilm_rat", "post-import-image")
|
||||
end
|
||||
|
||||
dt.register_event("fujifilm_rat", "post-import-image",
|
||||
detect_rating)
|
||||
|
||||
script_data.destroy = destroy
|
||||
return script_data
|
||||
350
contrib/geoJSON_export.lua
Normal file
350
contrib/geoJSON_export.lua
Normal file
@@ -0,0 +1,350 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
Copyright 2016 by Tobias Jakobs.
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
darktable geoJSON export script
|
||||
|
||||
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
|
||||
* mkdir
|
||||
* convert (ImageMagick)
|
||||
* xdg-open
|
||||
* xdg-user-dir
|
||||
|
||||
WARNING
|
||||
This script is only tested with Linux
|
||||
|
||||
USAGE
|
||||
* require this script from your main Lua file
|
||||
|
||||
]]
|
||||
|
||||
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", "geoJSON_export")
|
||||
|
||||
local function _(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
|
||||
local keys = {}
|
||||
for _key in pairs(_table) do keys[#keys + 1] = _key end
|
||||
|
||||
-- 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
|
||||
|
||||
-- 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
|
||||
|
||||
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 create_geoJSON_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
|
||||
end
|
||||
|
||||
dt.print_error("Will try to export geoJSON file now")
|
||||
|
||||
local exportDirectory = dt.preferences.read("geoJSON_export","ExportDirectory","string")
|
||||
|
||||
-- Creates dir if not exsists
|
||||
local imageFoldername = "files/"
|
||||
local mkdirCommand = "mkdir -p "..exportDirectory.."/"..imageFoldername
|
||||
dt.control.execute( mkdirCommand)
|
||||
|
||||
-- Create the thumbnails
|
||||
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 path, filename, filetype = string.match(exported_image, "(.-)([^\\/]-%.?([^%.\\/]*))$")
|
||||
filename = string.upper(string.gsub(filename,"%.%w*", ""))
|
||||
|
||||
-- convert -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 concertCommand = "convert -size 438x438 "..exported_image.." -resize 438x438 +profile \"*\" "..exportDirectory.."/"..imageFoldername..filename..".jpg"
|
||||
dt.control.execute( concertCommand)
|
||||
end
|
||||
|
||||
-- delete the original image
|
||||
os.remove(exported_image)
|
||||
|
||||
local pattern = "[/]?([^/]+)$"
|
||||
filmName = string.match(image.film.path, pattern)
|
||||
end
|
||||
|
||||
local exportgeoJSONFilename = filmName..".geoJSON"
|
||||
local exportMapBoxHTMLFilename = filmName..".html"
|
||||
|
||||
-- Create the geoJSON file
|
||||
local geoJSON_file = [[
|
||||
{
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
]]
|
||||
|
||||
for image,exported_image in pairs(image_table) do
|
||||
--filename = string.upper(string.gsub(image.filename,"%.", "_"))
|
||||
-- Extract filename, e.g DSC9784.ARW -> DSC9784
|
||||
filename = string.upper(string.gsub(image.filename,"%.%w*", ""))
|
||||
-- Extract extension from exported image (user can choose JPG or PNG), e.g DSC9784.JPG -> .JPG
|
||||
extension = string.match(exported_image,"%.%w*$")
|
||||
|
||||
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 image_title, image_description
|
||||
if (image.title and image.title ~= "") then
|
||||
image_title = image.title
|
||||
else
|
||||
image_title = image.filename
|
||||
end
|
||||
image_description = image.description
|
||||
|
||||
geoJSON_file = geoJSON_file..
|
||||
[[ {
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
]]
|
||||
geoJSON_file = geoJSON_file.." \"coordinates\": ["..string.gsub(tostring(image.longitude),",", ".")..","..string.gsub(tostring(image.latitude),",", ".").."]\n"
|
||||
geoJSON_file = geoJSON_file..
|
||||
[[ },
|
||||
"properties": {
|
||||
"title": "]]..image_title..[[",
|
||||
"description": "]]..image_description..[[",
|
||||
"image": "]]..imageFoldername..filename..[[.jpg",
|
||||
"icon": {
|
||||
"iconUrl": "]]..imageFoldername.."thumb_"..filename..[[.jpg",
|
||||
"iconSize": [96, 65],
|
||||
"iconAnchor": [48, 32],
|
||||
"popupAnchor": [0, -32],
|
||||
"className": "dot"
|
||||
}
|
||||
}
|
||||
}
|
||||
,]]
|
||||
end
|
||||
end
|
||||
|
||||
geoJSON_file = geoJSON_file:sub(0,geoJSON_file:len()-1)
|
||||
geoJSON_file = geoJSON_file..
|
||||
[[
|
||||
]
|
||||
}
|
||||
]]
|
||||
|
||||
|
||||
--HTML
|
||||
if ( dt.preferences.read("geoJSON_export","CreateMapBoxHTMLFile","bool") == true ) then
|
||||
local mapBoxKey = dt.preferences.read("geoJSON_export","mapBoxKey","string")
|
||||
local mapBoxHTML_file = [[
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=utf-8 />
|
||||
<title>]]..filmName..[[</title>
|
||||
<script src='https://api.tiles.mapbox.com/mapbox.js/v2.2.4/mapbox.js'></script>
|
||||
<link href='https://api.tiles.mapbox.com/mapbox.js/v2.2.4/mapbox.css' rel='stylesheet' />
|
||||
<style>
|
||||
body { margin:0; padding:0; }
|
||||
.map { position:absolute; top:0; bottom:0; width:100%; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='map-tooltips-js' class='map'> </div>
|
||||
|
||||
<script>
|
||||
L.mapbox.accessToken = ']]..mapBoxKey..[[';
|
||||
var mapTooltipsJS = L.mapbox.map('map-tooltips-js', 'mapbox.light')
|
||||
.setView([0,0], 5);
|
||||
|
||||
var myLayer = L.mapbox.featureLayer()
|
||||
.loadURL(']]..exportgeoJSONFilename..[[')
|
||||
.addTo(mapTooltipsJS);
|
||||
|
||||
// Set a custom icon on each marker based on feature properties.
|
||||
myLayer.on('layeradd', function(e) {
|
||||
var marker = e.layer,
|
||||
feature = marker.feature;
|
||||
marker.setIcon(L.icon(feature.properties.icon));
|
||||
var content = '<h2>'+ feature.properties.title+'<\/h2>' + '<p>'+ feature.properties.description+'<\/p>' + '<img src="'+feature.properties.image+'" alt="">';
|
||||
marker.bindPopup(content,{minWidth: 457});
|
||||
});
|
||||
// Center on click
|
||||
myLayer.on('click', function(e) {
|
||||
mapTooltipsJS.panTo(e.layer.getLatLng());
|
||||
});
|
||||
|
||||
// https://www.mapbox.com/mapbox.js/example/v1.0.0/fit-map-to-markers/
|
||||
// Especially with dynamic data, it's useful to automatically fit all markers
|
||||
// in the map bounds instead of guessing and checking center and zoom values
|
||||
|
||||
// Since this layer is loaded with the asynchronous method loadURL, that uses
|
||||
// AJAX in the background, we wait for all of the markers to be loaded by
|
||||
// waiting for the ready event. If you don't load your markers with an async
|
||||
// method and instead set them with setGeoJSON or similar, you don't need
|
||||
// to do this.
|
||||
myLayer.on('ready', function() {
|
||||
// featureLayer.getBounds() returns the corners of the furthest-out markers,
|
||||
// and map.fitBounds() makes sure that the map contains these.
|
||||
mapTooltipsJS.fitBounds(myLayer.getBounds());
|
||||
});
|
||||
|
||||
// Lines
|
||||
// https://www.mapbox.com/mapbox.js/example/v1.0.0/line-marker/
|
||||
myLayer.on('ready', function(e) {
|
||||
var line = [];
|
||||
|
||||
this.eachLayer(function(marker) {
|
||||
line.push(marker.getLatLng());
|
||||
});
|
||||
|
||||
var polyline_options = {
|
||||
color: '#FF0000'
|
||||
};
|
||||
|
||||
var polyline = L.polyline(line, polyline_options).addTo(mapTooltipsJS);
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
]]
|
||||
|
||||
local file = io.open(exportDirectory.."/"..exportMapBoxHTMLFilename, "w")
|
||||
file:write(mapBoxHTML_file)
|
||||
file:close()
|
||||
end
|
||||
|
||||
local file = io.open(exportDirectory.."/"..exportgeoJSONFilename, "w")
|
||||
file:write(geoJSON_file)
|
||||
file:close()
|
||||
|
||||
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
|
||||
local geoJSONFileOpenCommand
|
||||
geoJSONFileOpenCommand = "xdg-open "..exportDirectory.."/\""..exportgeoJSONFilename.."\""
|
||||
dt.control.execute( geoJSONFileOpenCommand)
|
||||
end
|
||||
|
||||
|
||||
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 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",
|
||||
'' )
|
||||
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"),
|
||||
false )
|
||||
|
||||
local handle = io.popen("xdg-user-dir DESKTOP")
|
||||
local result = handle:read()
|
||||
handle:close()
|
||||
if (result == nil) then
|
||||
result = ""
|
||||
end
|
||||
dt.preferences.register("geoJSON_export",
|
||||
"ExportDirectory",
|
||||
"directory",
|
||||
_("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
|
||||
793
contrib/geoToolbox.lua
Normal file
793
contrib/geoToolbox.lua
Normal file
@@ -0,0 +1,793 @@
|
||||
--[[
|
||||
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
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
|
||||
USAGE
|
||||
* require this script from your main lua file
|
||||
To do this add this line to the file .config/darktable/luarc:
|
||||
require "geoToolbox"
|
||||
|
||||
* it creates a new geoToolbox lighttable module
|
||||
]]
|
||||
|
||||
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", "geoToolbox")
|
||||
|
||||
local function _(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:")
|
||||
|
||||
local checkbox_copy_gps_lat = dt.new_widget("check_button")
|
||||
{
|
||||
value = true
|
||||
}
|
||||
local entry_gps_lat = dt.new_widget("entry")
|
||||
{
|
||||
tooltip = _("latitude (editable)"),
|
||||
placeholder = _("latitude")
|
||||
}
|
||||
local checkbox_copy_gps_lon = dt.new_widget("check_button")
|
||||
{
|
||||
value = true
|
||||
}
|
||||
local entry_gps_lon = dt.new_widget("entry")
|
||||
{
|
||||
tooltip = _("longitude (editable)"),
|
||||
placeholder = _("longitude")
|
||||
}
|
||||
local checkbox_copy_gps_ele = dt.new_widget("check_button")
|
||||
{
|
||||
value = true
|
||||
}
|
||||
local entry_gps_ele = dt.new_widget("entry")
|
||||
{
|
||||
tooltip = _("elevation (editable)"),
|
||||
placeholder = _("elevation")
|
||||
}
|
||||
-- </GUI>
|
||||
|
||||
local function select_with_gps()
|
||||
local selection = {}
|
||||
job = dt.gui.create_job(_("GPS selection"), true, stop_selection)
|
||||
|
||||
for key,image in ipairs(dt.collection) do
|
||||
if job.valid then
|
||||
job.percent = (key-1)/#dt.collection
|
||||
|
||||
if (image.longitude and image.latitude) then
|
||||
table.insert(selection,image)
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
dt.gui.selection(selection)
|
||||
job.valid = false
|
||||
end
|
||||
|
||||
local function select_without_gps()
|
||||
local selection = {}
|
||||
job = dt.gui.create_job(_("GPS selection"), true, stop_selection)
|
||||
|
||||
for key,image in ipairs(dt.collection) do
|
||||
if job.valid then
|
||||
job.percent = (key-1)/#dt.collection
|
||||
|
||||
if (not image.longitude and not image.latitude) then
|
||||
table.insert(selection,image)
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
dt.gui.selection(selection)
|
||||
job.valid = false
|
||||
end
|
||||
|
||||
local function stop_selection(job)
|
||||
job.valid = false
|
||||
end
|
||||
|
||||
-- This is used for older images in the DB
|
||||
function isnan(x) return x ~= x end
|
||||
|
||||
-- Function from:
|
||||
-- https://forums.coronalabs.com/topic/29019-convert-string-to-date/
|
||||
-- This looks much scarier than it really is. The goal is to turn that string
|
||||
-- into a Unix timestamp (number of seconds since Jan 1, 1970, the standard
|
||||
-- used by most systems). So we use the string.match() method to fetch the
|
||||
-- various date and time parts into their own variables: xyear, xmonth,etc.
|
||||
function make_time_stamp(dateString)
|
||||
local convertedTimestamp
|
||||
--dt.print_error(dateString)
|
||||
if (dateString) then
|
||||
local pattern = "(%d+)%:(%d+)%:(%d+) (%d+):(%d+):(%d+)"
|
||||
local xyear, xmonth, xday, xhour, xminute, xseconds = dateString:match(pattern)
|
||||
--dt.print_error(xyear)
|
||||
convertedTimestamp = os.time({
|
||||
year = xyear,
|
||||
month = xmonth,
|
||||
day = xday,
|
||||
hour = xhour,
|
||||
min = xminute,
|
||||
sec = xseconds})
|
||||
else
|
||||
convertedTimestamp = 0
|
||||
end
|
||||
|
||||
return convertedTimestamp
|
||||
end
|
||||
|
||||
local first_have_data = false
|
||||
local first_latitude = ''
|
||||
local first_longitude = ''
|
||||
local first_elevation = ''
|
||||
local first_image_date = 0
|
||||
|
||||
local function get_first_coordinate()
|
||||
local sel_images = dt.gui.action_images
|
||||
|
||||
first_latitude = ''
|
||||
first_longitude = ''
|
||||
first_elevation = ''
|
||||
first_image_date = 0
|
||||
|
||||
for jj,image in ipairs(sel_images) do
|
||||
if not image then
|
||||
first_have_data = false
|
||||
else
|
||||
image_date = image.exif_datetime_taken
|
||||
first_have_data = true
|
||||
if (image.latitude) then
|
||||
first_latitude = image.latitude
|
||||
end
|
||||
if (image.longitude) then
|
||||
first_longitude = image.longitude
|
||||
end
|
||||
if (image.elevation) then
|
||||
first_elevation = image.elevation
|
||||
end
|
||||
if (image.exif_datetime_taken) then
|
||||
first_image_date = make_time_stamp(image.exif_datetime_taken)
|
||||
--dt.print_error(image.exif_datetime_taken)
|
||||
--dt.print_error(first_image_date)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local second_have_data = false
|
||||
local second_latitude = ''
|
||||
local second_longitude = ''
|
||||
local second_elevation = ''
|
||||
local second_image_date = 0
|
||||
|
||||
local function get_second_coordinate()
|
||||
local sel_images = dt.gui.action_images
|
||||
|
||||
second_latitude = ''
|
||||
second_longitude = ''
|
||||
second_elevation = ''
|
||||
second_image_date = 0
|
||||
|
||||
for jj,image in ipairs(sel_images) do
|
||||
if not image then
|
||||
second_have_data = false
|
||||
else
|
||||
image_date = image.exif_datetime_taken
|
||||
second_have_data = true
|
||||
if (image.latitude) then
|
||||
second_latitude = image.latitude
|
||||
end
|
||||
if (image.longitude) then
|
||||
second_longitude = image.longitude
|
||||
end
|
||||
if (image.elevation) then
|
||||
second_elevation = image.elevation
|
||||
end
|
||||
if (image.exif_datetime_taken) then
|
||||
second_image_date = make_time_stamp(image.exif_datetime_taken)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local calc_in_between_slider = dt.new_widget("slider")
|
||||
{
|
||||
label = "Position between",
|
||||
soft_min = 0, -- The soft minimum value for the slider, the slider can't go beyond this point
|
||||
soft_max = 100, -- The soft maximum value for the slider, the slider can't go beyond this point
|
||||
hard_min = -100, -- The hard minimum value for the slider, the user can't manually enter a value beyond this point
|
||||
hard_max = 200, -- The hard maximum value for the slider, the user can't manually enter a value beyond this point
|
||||
value = 50 -- The current value of the slider
|
||||
}
|
||||
|
||||
--ToDo: this needs more love
|
||||
local function calc_in_between()
|
||||
local sel_images = dt.gui.action_images
|
||||
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
|
||||
local start_new = 0
|
||||
local end_new = second_image_date - first_image_date
|
||||
local image_date_new = image_date - first_image_date
|
||||
|
||||
local percent_in_between
|
||||
if (end_new == 0) then
|
||||
percent_in_between = 1
|
||||
else
|
||||
percent_in_between = image_date_new/end_new
|
||||
end
|
||||
calc_in_between_slider.value = percent_in_between * 100
|
||||
dt.print_error(percent_in_between)
|
||||
local in_between_latitude = first_latitude + (second_latitude - first_latitude) * percent_in_between
|
||||
local in_between_longitude = first_longitude + (second_longitude - first_longitude) * percent_in_between
|
||||
|
||||
if (first_elevation and second_elevation) then
|
||||
local in_between_elevation = first_elevation + (second_elevation - first_elevation) * percent_in_between
|
||||
|
||||
dt.print_error(first_image_date)
|
||||
dt.print_error(second_image_date)
|
||||
dt.print_error(image_date)
|
||||
dt.print_error(first_elevation)
|
||||
dt.print_error(second_elevation)
|
||||
dt.print_error(in_between_elevation)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local copy_gps_have_data = false
|
||||
local copy_gps_latitude = ''
|
||||
local copy_gps_longitude = ''
|
||||
local copy_gps_elevation = ''
|
||||
|
||||
local function copy_gps()
|
||||
local sel_images = dt.gui.action_images
|
||||
|
||||
copy_gps_latitude = ''
|
||||
copy_gps_longitude = ''
|
||||
copy_gps_elevation = ''
|
||||
|
||||
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 checkbox_copy_gps_lat.value) then
|
||||
copy_gps_latitude = image.latitude
|
||||
end
|
||||
if (image.longitude and checkbox_copy_gps_lon.value) then
|
||||
copy_gps_longitude = image.longitude
|
||||
end
|
||||
if (image.elevation and checkbox_copy_gps_ele.value) then
|
||||
copy_gps_elevation = image.elevation
|
||||
end
|
||||
end
|
||||
|
||||
entry_gps_lat.text = copy_gps_latitude
|
||||
entry_gps_lon.text = copy_gps_longitude
|
||||
entry_gps_ele.text = copy_gps_elevation
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local function paste_gps(image)
|
||||
local sel_images = dt.gui.action_images
|
||||
|
||||
for jj,image in ipairs(sel_images) do
|
||||
if (checkbox_copy_gps_lat.value) then
|
||||
image.latitude = entry_gps_lat.text
|
||||
end
|
||||
if (checkbox_copy_gps_lon.value) then
|
||||
image.longitude = entry_gps_lon.text
|
||||
end
|
||||
if (checkbox_copy_gps_ele.value) then
|
||||
image.elevation = entry_gps_ele.text
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function open_location_in_gnome_maps()
|
||||
|
||||
if not df.check_if_bin_exists("gnome-maps") then
|
||||
dt.print_error(_("gnome-maps not found"))
|
||||
return
|
||||
end
|
||||
|
||||
local sel_images = dt.gui.action_images
|
||||
|
||||
local lat1 = 0;
|
||||
local lon1 = 0;
|
||||
local i = 0;
|
||||
|
||||
-- Use the first image with geo information
|
||||
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
|
||||
lat1 = string.gsub(image.latitude, ",", ".");
|
||||
lon1 = string.gsub(image.longitude, ",", ".");
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local startCommand
|
||||
startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\""
|
||||
dt.print_error(startCommand)
|
||||
|
||||
dt.control.execute(startCommand)
|
||||
|
||||
end
|
||||
|
||||
-- Trim Funktion from: http://lua-users.org/wiki/StringTrim
|
||||
local function trim12(s)
|
||||
local from = s:match"^%s*()"
|
||||
return from > #s and "" or s:match(".*%S", from)
|
||||
end
|
||||
|
||||
local function reverse_geocode()
|
||||
|
||||
if not df.check_if_bin_exists("curl") then
|
||||
dt.print_error("curl not found")
|
||||
return
|
||||
end
|
||||
|
||||
if not df.check_if_bin_exists("jq") then
|
||||
dt.print_error("jq not found")
|
||||
return
|
||||
end
|
||||
|
||||
local sel_images = dt.gui.selection() --action_images
|
||||
|
||||
local lat1 = 0;
|
||||
local lon1 = 0;
|
||||
local i = 0;
|
||||
|
||||
-- Use the first image with geo information
|
||||
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
|
||||
lat1 = string.gsub(image.latitude, ",", ".");
|
||||
lon1 = string.gsub(image.longitude, ",", ".");
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local startCommand
|
||||
|
||||
local tokan = dt.preferences.read("geoToolbox","mapBoxKey","string")
|
||||
local types = "country";
|
||||
local types = "region";
|
||||
local types = "place";
|
||||
local types = "poi";
|
||||
|
||||
-- MapBox documentation
|
||||
-- https://www.mapbox.com/api-documentation/#retrieve-places-near-a-location
|
||||
-- curl -s, --silent Silent mode (don't output anything)
|
||||
-- jq could be replaced with a Lua JSON parser
|
||||
startCommand = string.format("curl --silent \"https://api.mapbox.com/geocoding/v5/mapbox.places/%s,%s.json?types=%s&access_token=%s\" | jq '.features | .[0] | '.text''", lon1, lat1, types, tokan)
|
||||
|
||||
local handle = io.popen(startCommand)
|
||||
local result = trim12(handle:read("*a"))
|
||||
handle:close()
|
||||
|
||||
-- Errorhandling would be nice
|
||||
--dt.print_error("startCommand: "..startCommand)
|
||||
--dt.print_error("result: '"..result.."'")
|
||||
|
||||
if (result ~= "null") then
|
||||
dt.print(string.sub(result, 2, string.len(result)-2))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- I used code from here:
|
||||
-- http://stackoverflow.com/questions/27928/how-do-i-calculate-distance-between-two-latitude-longitude-points
|
||||
local function get_distance(lat1, lon1, ele1, lat2, lon2, ele2)
|
||||
|
||||
local earthRadius = 6371; -- Radius of the earth in km
|
||||
local dLat = math.rad(lat2-lat1); -- deg2rad below
|
||||
local dLon = math.rad(lon2-lon1);
|
||||
local a =
|
||||
math.sin(dLat/2) * math.sin(dLat/2) +
|
||||
math.cos(math.rad(lat1)) * math.cos(math.rad(lat2)) *
|
||||
math.sin(dLon/2) * math.sin(dLon/2)
|
||||
;
|
||||
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
|
||||
local elevation = 0
|
||||
elevation = math.abs(ele1 - ele2) / 1000; --in km
|
||||
|
||||
if (elevation > 0) then
|
||||
distance = math.sqrt(math.pow(elevation,2) + math.pow(distance,2) )
|
||||
end
|
||||
return distance
|
||||
end
|
||||
|
||||
local function calc_distance()
|
||||
|
||||
local lat1 = 0;
|
||||
local lon1 = 0;
|
||||
local lat2 = 0;
|
||||
local lon2 = 0;
|
||||
local ele1 = 0;
|
||||
local ele2 = 0;
|
||||
local i = 0;
|
||||
|
||||
local sel_images = dt.gui.selection()
|
||||
|
||||
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
|
||||
|
||||
i = i + 1;
|
||||
|
||||
if (i == 1) then
|
||||
lat1 = image.latitude
|
||||
lon1 = image.longitude
|
||||
if (image.elevation) then
|
||||
ele1 = image.elevation
|
||||
else
|
||||
ele1 = 0
|
||||
end
|
||||
end
|
||||
|
||||
lat2 = image.latitude
|
||||
lon2 = image.longitude
|
||||
if (image.elevation) then
|
||||
ele2 = image.elevation
|
||||
else
|
||||
ele2 = 0;
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
local distance = get_distance(lat1, lon1, ele1, lat2, lon2, ele2)
|
||||
|
||||
if (distance < 1) then
|
||||
distance = distance * 1000
|
||||
distanceUnit = "m"
|
||||
else
|
||||
distanceUnit = "km"
|
||||
end
|
||||
|
||||
return string.format(_("distance: %.2f %s"), distance, distanceUnit)
|
||||
end
|
||||
|
||||
local function print_calc_distance()
|
||||
dt.print(calc_distance())
|
||||
end
|
||||
|
||||
local function toolbox_calc_distance()
|
||||
labelDistance.label = calc_distance()
|
||||
end
|
||||
|
||||
local altitude_file_chooser_button = dt.new_widget("file_chooser_button")
|
||||
{
|
||||
title = _("export altitude CSV"), -- The title of the window when choosing a file
|
||||
value = "", -- The currently selected file
|
||||
is_directory = true -- True if the file chooser button only allows directories to be selecte
|
||||
}
|
||||
|
||||
local altitude_filename = dt.new_widget("entry")
|
||||
{
|
||||
text = "altitude.csv",
|
||||
placeholder = "altitude.csv",
|
||||
editable = true,
|
||||
tooltip = _("name of the exported file"),
|
||||
reset_callback = function(self) self.text = "text" end
|
||||
}
|
||||
|
||||
local function altitude_profile()
|
||||
dt.print(_("start export"))
|
||||
local sel_images = dt.gui.action_images
|
||||
|
||||
local lat1 = 0;
|
||||
local lon1 = 0;
|
||||
local lat2 = 0;
|
||||
local lon2 = 0;
|
||||
local ele1 = 0;
|
||||
local ele2 = 0;
|
||||
local i = 0;
|
||||
local csv_file = '';
|
||||
csv_file = "km;m".."\n";
|
||||
|
||||
local distance = 0;
|
||||
local distanceFromStart = 0;
|
||||
local elevation = 0;
|
||||
local elevationAdd = 0;
|
||||
|
||||
local sel_images = dt.gui.action_images
|
||||
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
|
||||
|
||||
i = i + 1;
|
||||
|
||||
if (i == 1) then
|
||||
lat1 = image.latitude
|
||||
lon1 = image.longitude
|
||||
ele1 = image.elevation
|
||||
else
|
||||
lat1 = lat2
|
||||
lon1 = lon2
|
||||
ele1 = ele2
|
||||
end
|
||||
|
||||
lat2 = image.latitude
|
||||
lon2 = image.longitude
|
||||
ele2 = image.elevation
|
||||
|
||||
if (i == 1) then
|
||||
distanceFromStart = 0
|
||||
else
|
||||
local distance = get_distance(lat1, lon1, ele1, lat2, lon2, ele2)
|
||||
distanceFromStart = distanceFromStart + distance;
|
||||
end
|
||||
|
||||
csv_file = csv_file .. distanceFromStart..";"..image.elevation.."\n";
|
||||
|
||||
end
|
||||
|
||||
end --for
|
||||
|
||||
local exportDirectory = altitude_file_chooser_button.value
|
||||
local exportFilename = altitude_filename.text
|
||||
if (exportFilename == '') then
|
||||
exportFilename = altitude_filename.placeholder
|
||||
end
|
||||
file = io.open(exportDirectory.."/"..exportFilename, "w")
|
||||
file:write(csv_file)
|
||||
file:close()
|
||||
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"){}
|
||||
local separator3 = dt.new_widget("separator"){}
|
||||
local separator4 = dt.new_widget("separator"){}
|
||||
local separator5 = dt.new_widget("separator"){}
|
||||
|
||||
gT.widget = dt.new_widget("box")
|
||||
{
|
||||
orientation = "vertical",
|
||||
dt.new_widget("button")
|
||||
{
|
||||
label = _("select geo images"),
|
||||
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"),
|
||||
clicked_callback = select_without_gps
|
||||
},
|
||||
separator,--------------------------------------------------------
|
||||
dt.new_widget("button")
|
||||
{
|
||||
label = _("copy GPS data"),
|
||||
tooltip = _("copy GPS data"),
|
||||
clicked_callback = copy_gps
|
||||
},
|
||||
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 = _("apply GPS data to image"),
|
||||
tooltip = _("apply GPS data to image"),
|
||||
clicked_callback = paste_gps
|
||||
},
|
||||
separator2,--------------------------------------------------------
|
||||
--ToDo: This need a better UI
|
||||
--[[
|
||||
dt.new_widget("button")
|
||||
{
|
||||
label = "get 1st coordinate",
|
||||
tooltip = "Select first image and click this button",
|
||||
clicked_callback = get_first_coordinate
|
||||
},
|
||||
dt.new_widget("button")
|
||||
{
|
||||
label = "get 2nd coordinate",
|
||||
tooltip = "Select second image and click this button",
|
||||
clicked_callback = get_second_coordinate
|
||||
},
|
||||
dt.new_widget("button")
|
||||
{
|
||||
label = "calc in between",
|
||||
tooltip = "Select third image and click this button",
|
||||
clicked_callback = calc_in_between
|
||||
},
|
||||
calc_in_between_slider,
|
||||
separator3,--------------------------------------------------------
|
||||
]]
|
||||
dt.new_widget("button")
|
||||
{
|
||||
label = _("open 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"),
|
||||
clicked_callback = reverse_geocode
|
||||
},
|
||||
separator5,--------------------------------------------------------
|
||||
dt.new_widget("label"){label = _("altitude CSV export")},
|
||||
altitude_file_chooser_button,
|
||||
altitude_filename,
|
||||
dt.new_widget("button")
|
||||
{
|
||||
label = _("export altitude CSV file"),
|
||||
tooltip = _("create an altitude profile using the GPS data in the metadata"),
|
||||
clicked_callback = altitude_profile
|
||||
},
|
||||
labelDistance
|
||||
}
|
||||
|
||||
|
||||
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",
|
||||
'' )
|
||||
|
||||
-- Register
|
||||
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"))
|
||||
|
||||
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;
|
||||
225
contrib/gimp.lua
Normal file
225
contrib/gimp.lua
Normal file
@@ -0,0 +1,225 @@
|
||||
--[[
|
||||
|
||||
gimp.lua - export and edit with GIMP
|
||||
|
||||
Copyright (C) 2016 Bill Ferguson <wpferguson@gmail.com>.
|
||||
|
||||
Portions are lifted from hugin.lua and thus are
|
||||
|
||||
Copyright (c) 2014 Wolfgang Goetz
|
||||
Copyright (c) 2015 Christian Kanzian
|
||||
Copyright (c) 2015 Tobias Jakobs
|
||||
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
gimp - export an image and open with GIMP for editing
|
||||
|
||||
This script provides another storage (export target) for darktable. Selected
|
||||
images are exported in the specified format to temporary storage. GIMP is launched
|
||||
and opens the files. After editing, the exported images are overwritten to save the
|
||||
changes. When GIMP exits, the exported files are moved into the current collection
|
||||
and imported into the database. The imported files then show up grouped with the
|
||||
originally selected images.
|
||||
|
||||
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
|
||||
* GIMP - http://www.gimp.org
|
||||
|
||||
USAGE
|
||||
* 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. 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
|
||||
* The edited image will be imported and grouped with the original image
|
||||
|
||||
CAVEATS
|
||||
* Developed and tested on Ubuntu 14.04 LTS with darktable 2.0.3 and GIMP 2.9.3 (development version with
|
||||
> 8 bit color)
|
||||
* There is no provision for dealing with the xcf files generated by GIMP, since darktable doesn't deal with
|
||||
them. You may want to save the xcf file if you intend on doing further edits to the image or need to save
|
||||
the layers used. Where you save them is up to you.
|
||||
|
||||
BUGS, COMMENTS, SUGGESTIONS
|
||||
* Send to Bill Ferguson, wpferguson@gmail.com
|
||||
|
||||
CHANGES
|
||||
* 20160823 - os.rename doesn't work across filesystems. Added fileCopy and fileMove functions to move the file
|
||||
from the temporary location to the collection location irregardless of what filesystem it is on. If an
|
||||
issue is encountered, a message is printed back to the UI so the user isn't left wondering what happened.
|
||||
]]
|
||||
|
||||
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 gimp_widget = nil
|
||||
|
||||
du.check_min_api_version("7.0.0", "gimp")
|
||||
|
||||
local function _(msgid)
|
||||
return gettext(msgid)
|
||||
end
|
||||
|
||||
-- return data structure for script_manager
|
||||
|
||||
local script_data = {}
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
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 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_log(image.filename .. " is a member")
|
||||
if image.filename == new_img.filename then
|
||||
is_member = true
|
||||
dt.print_log("Already in group")
|
||||
end
|
||||
end
|
||||
if not is_member then
|
||||
dt.print_log("group leader is "..img.group_leader.filename)
|
||||
new_img:group_with(img.group_leader)
|
||||
dt.print_log("Added to group")
|
||||
end
|
||||
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 gimp_edit(storage, image_table, extra_data) --finalize
|
||||
|
||||
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
|
||||
|
||||
-- reset and create image list
|
||||
img_list = ""
|
||||
|
||||
for _,exp_img in pairs(image_table) do
|
||||
exp_img = df.sanitize_filename(exp_img)
|
||||
img_list = img_list ..exp_img.. " "
|
||||
end
|
||||
|
||||
dt.print(_("launching GIMP..."))
|
||||
|
||||
local gimpStartCommand
|
||||
gimpStartCommand = gimp_executable .. " " .. img_list
|
||||
|
||||
if run_detached then
|
||||
if dt.configuration.running_os == "windows" then
|
||||
gimpStartCommand = "start /b \"\" " .. gimpStartCommand
|
||||
else
|
||||
gimpStartCommand = gimpStartCommand .. " &"
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
-- then import the image into the database which will group it with the original
|
||||
-- and then copy over any tags other than darktable tags
|
||||
|
||||
for image,exported_image in pairs(image_table) do
|
||||
|
||||
local myimage_name = image.path .. "/" .. df.get_filename(exported_image)
|
||||
|
||||
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(df.get_basename(myimage_name), "_(d-)$") == "99" then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
dt.print_log("moving " .. exported_image .. " to " .. myimage_name)
|
||||
local result = df.file_move(exported_image, myimage_name)
|
||||
|
||||
if result then
|
||||
dt.print_log("importing file")
|
||||
local myimage = dt.database.import(myimage_name)
|
||||
|
||||
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_log("attaching tag")
|
||||
dt.tags.attach(tag,myimage)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function destroy()
|
||||
dt.destroy_storage("module_gimp")
|
||||
end
|
||||
|
||||
-- Register
|
||||
|
||||
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
|
||||
@@ -1,51 +0,0 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
Copyright 2014 by Tobias Jakobs.
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
darktable select images with or without GPS informations
|
||||
|
||||
USAGE
|
||||
* require this script from your main lua file
|
||||
* register a shortcuts
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
dt.configuration.check_version(...,{2,0,1})
|
||||
table = require "table"
|
||||
|
||||
local function selectWithGPS()
|
||||
local selection = {}
|
||||
for _,image in ipairs(dt.database) do
|
||||
if (image.longitude and image.latitude) then
|
||||
table.insert(selection,image)
|
||||
end
|
||||
end
|
||||
dt.gui.selection(selection)
|
||||
end
|
||||
|
||||
local function selectWithoutGPS()
|
||||
local selection = {}
|
||||
for _,image in ipairs(dt.database) do
|
||||
if (not image.longitude and not image.latitude) then
|
||||
table.insert(selection,image)
|
||||
end
|
||||
end
|
||||
dt.gui.selection(selection)
|
||||
end
|
||||
|
||||
dt.register_event("shortcut", selectWithGPS, "Select all images with GPS information")
|
||||
dt.register_event("shortcut", selectWithoutGPS, "Select all images without GPS information")
|
||||
213
contrib/gpx_export.lua
Normal file
213
contrib/gpx_export.lua
Normal 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
|
||||
97
contrib/harmonic_armature_guide.lua
Normal file
97
contrib/harmonic_armature_guide.lua
Normal 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
|
||||
200
contrib/hif_group_leader.lua
Normal file
200
contrib/hif_group_leader.lua
Normal 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
|
||||
@@ -1,119 +1,248 @@
|
||||
--[[
|
||||
Hugin storage for darktable
|
||||
|
||||
copyright (c) 2014 Wolfgang Goetz
|
||||
copyright (c) 2015 Christian Kanzian
|
||||
copyright (c) 2015 Tobias Jakobs
|
||||
|
||||
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/>.
|
||||
]]
|
||||
|
||||
--[[
|
||||
HUGIN
|
||||
Add a new storage option to send images to hugin.
|
||||
Images are exported to darktable tmp dir first.
|
||||
|
||||
ADDITIANAL SOFTWARE NEEDED FOR THIS SCRIPT
|
||||
* hugin
|
||||
|
||||
USAGE
|
||||
* require this file from your main luarc config file.
|
||||
|
||||
This plugin will add a new storage option and calls hugin after export.
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
|
||||
-- should work with darktable API version 2.0.0
|
||||
dt.configuration.check_version(...,{2,0,0})
|
||||
|
||||
local function checkIfBinExists(bin)
|
||||
local handle = io.popen("which "..bin)
|
||||
local result = handle:read()
|
||||
local ret
|
||||
handle:close()
|
||||
if (result) then
|
||||
dt.print_error("true checkIfBinExists: "..bin)
|
||||
ret = true
|
||||
else
|
||||
dt.print_error(bin.." not found")
|
||||
ret = false
|
||||
end
|
||||
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
local function show_status(storage, image, format, filename,
|
||||
number, total, high_quality, extra_data)
|
||||
dt.print("Export to Hugin "..tostring(number).."/"..tostring(total))
|
||||
end
|
||||
|
||||
local function create_panorama(storage, image_table, extra_data) --finalize
|
||||
if not checkIfBinExists("hugin") then
|
||||
darktable.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 (checkIfBinExists("hugin_executor") and checkIfBinExists("pto_gen")) then
|
||||
hugin_executor = true
|
||||
end
|
||||
|
||||
-- list of exported images
|
||||
local img_list
|
||||
|
||||
-- reset and create image list
|
||||
img_list = ""
|
||||
|
||||
for _,v in pairs(image_table) do
|
||||
img_list = img_list ..v.. " "
|
||||
end
|
||||
|
||||
dt.print("Will try to stitch now")
|
||||
|
||||
local huginStartCommand
|
||||
if (hugin_executor) then
|
||||
huginStartCommand = "pto_gen "..img_list.." -o "..dt.configuration.tmp_dir.."/project.pto"
|
||||
dt.print("Creating pto file")
|
||||
coroutine.yield("RUN_COMMAND", huginStartCommand)
|
||||
|
||||
dt.print("Running Assistent")
|
||||
huginStartCommand = "hugin_executor --assistant "..dt.configuration.tmp_dir.."/project.pto"
|
||||
coroutine.yield("RUN_COMMAND", huginStartCommand)
|
||||
|
||||
huginStartCommand = "hugin "..dt.configuration.tmp_dir.."/project.pto"
|
||||
else
|
||||
huginStartCommand = "hugin "..img_list
|
||||
end
|
||||
|
||||
dt.print_error(huginStartCommand)
|
||||
|
||||
if coroutine.yield("RUN_COMMAND", huginStartCommand)
|
||||
then
|
||||
dt.print("Command hugin failed ...")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Register
|
||||
dt.register_storage("module_hugin", "Hugin Panorama", show_status, create_panorama)
|
||||
|
||||
--
|
||||
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
|
||||
--[[
|
||||
Hugin storage for darktable
|
||||
|
||||
copyright (c) 2014 Wolfgang Goetz
|
||||
copyright (c) 2015 Christian Kanzian
|
||||
copyright (c) 2015 Tobias Jakobs
|
||||
|
||||
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/>.
|
||||
]]
|
||||
|
||||
--[[
|
||||
HUGIN
|
||||
Add a new storage option to send images to hugin.
|
||||
Images are exported to darktable tmp dir first.
|
||||
|
||||
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
|
||||
* hugin
|
||||
|
||||
USAGE
|
||||
* 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"
|
||||
local log = require "lib/dtutils.log"
|
||||
local dtsys = require "lib/dtutils.system"
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
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"}
|
||||
|
||||
-- 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(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(string.format(_("exporting to hugin: %d / %d"), number, total))
|
||||
end
|
||||
|
||||
local function create_panorama(storage, image_table, extra_data) --finalize
|
||||
-- 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
|
||||
|
||||
-- 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_set = {}
|
||||
|
||||
-- reset and create image list
|
||||
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
|
||||
|
||||
log.msg(log.info, "img_list is ", img_list)
|
||||
|
||||
-- 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
|
||||
|
||||
if first_file == nil then
|
||||
dt.print(_("no file selected"))
|
||||
return
|
||||
end
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
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
607
contrib/image_stack.lua
Normal 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
|
||||
602
contrib/image_time.lua
Normal file
602
contrib/image_time.lua
Normal file
@@ -0,0 +1,602 @@
|
||||
--[[
|
||||
|
||||
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 <const> = dt.configuration.runnin_os == "windows" and "\\" or "/"
|
||||
local ERROR <const> = -1
|
||||
local HAS_INTERNAL_METADATA = dt.metadata.exists("Exif.Image.DataTime")
|
||||
|
||||
-- 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 datestring = nil
|
||||
|
||||
if HAS_INTERNAL_METADATA then
|
||||
datestring = image.DateString
|
||||
else
|
||||
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
|
||||
datestring = line
|
||||
end
|
||||
end
|
||||
p:close()
|
||||
else
|
||||
dt.print(string.format(_("unable to get information for %s"), image.filename))
|
||||
datetime = ERROR
|
||||
end
|
||||
end
|
||||
if datestring then
|
||||
local mo, day, yr, hr, min, apm = string.match(datestring, "(%d+)/(%d+)/(%d+) (%d-):(%d+) (%S+)")
|
||||
if apm == "PM" then
|
||||
hr = hr + 12
|
||||
end
|
||||
datetime = vars2exiftime(yr, mo, day, hr, min, 0)
|
||||
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
|
||||
200
contrib/jpg_group_leader.lua
Normal file
200
contrib/jpg_group_leader.lua
Normal 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
|
||||
@@ -1,255 +1,394 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
Copyright 2014 by Tobias Jakobs.
|
||||
This file is part of darktable,
|
||||
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
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
]]
|
||||
--[[
|
||||
darktable KML export script
|
||||
|
||||
ADDITIANAL SOFTWARE NEEDED FOR THIS SCRIPT
|
||||
* mkdir
|
||||
* zip (only if you create KMZ files)
|
||||
* convert (ImageMagick)
|
||||
* xdg-open
|
||||
* xdg-user-dir
|
||||
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
|
||||
* zip (at the moment Linux only and only if you create KMZ files)
|
||||
* magick (ImageMagick)
|
||||
* xdg-user-dir (Linux)
|
||||
|
||||
WARNING
|
||||
This script is only testet with Linux
|
||||
This script is only tested with Linux
|
||||
|
||||
USAGE
|
||||
* require this script from your main lua file
|
||||
* 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"
|
||||
dt.configuration.check_version(...,{2,0,1})
|
||||
local du = require "lib/dtutils"
|
||||
local df = require "lib/dtutils.file"
|
||||
local ds = require "lib/dtutils.string"
|
||||
local dsys = require "lib/dtutils.system"
|
||||
|
||||
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
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
-- 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 PS = dt.configuration.running_os == "windows" and "\\" or "/"
|
||||
|
||||
-- return the iterator function
|
||||
local i = 0
|
||||
return function()
|
||||
i = i + 1
|
||||
if keys[i] then
|
||||
return keys[i], _table[keys[i]]
|
||||
end
|
||||
end
|
||||
du.check_min_api_version("7.0.0", "kml_export")
|
||||
|
||||
local function _(msgid)
|
||||
return gettext(msgid)
|
||||
end
|
||||
|
||||
-- return data structure for script_manager
|
||||
|
||||
local script_data = {}
|
||||
|
||||
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("Export Image "..tostring(number).."/"..tostring(total))
|
||||
dt.print(string.format(_("export image %i/%i"), number, total))
|
||||
end
|
||||
|
||||
local function checkIfBinExists(bin)
|
||||
local handle = io.popen("which "..bin)
|
||||
local result = handle:read()
|
||||
local ret
|
||||
handle:close()
|
||||
if (not result) then
|
||||
dt.print_error(bin.." not found")
|
||||
ret = false
|
||||
-- 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
|
||||
ret = true
|
||||
return ret
|
||||
filename = filename..index
|
||||
end
|
||||
|
||||
return filename
|
||||
end
|
||||
|
||||
local function create_kml_file(storage, image_table, extra_data)
|
||||
|
||||
if not checkIfBinExists("mkdir") then
|
||||
return
|
||||
end
|
||||
if not checkIfBinExists("convert") then
|
||||
return
|
||||
end
|
||||
if not checkIfBinExists("xdg-open") then
|
||||
return
|
||||
end
|
||||
if not checkIfBinExists("xdg-user-dir") then
|
||||
return
|
||||
end
|
||||
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
|
||||
and dt.configuration.running_os == "linux") then
|
||||
if not df.check_if_bin_exists("zip") then
|
||||
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"..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
|
||||
(image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data
|
||||
) then
|
||||
local path, filename, filetype = string.match(exported_image, "(.-)([^\\/]-%.?([^%.\\/]*))$")
|
||||
filename = string.upper(string.gsub(filename,"%.%w*", ""))
|
||||
|
||||
-- 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 = 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)
|
||||
|
||||
if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true ) then
|
||||
if not checkIfBinExists("zip") then
|
||||
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
|
||||
coroutine.yield("RUN_COMMAND", mkdirCommand)
|
||||
-- Remove exported image if it has no GPS data
|
||||
os.remove(exported_image)
|
||||
end
|
||||
|
||||
local pattern = "[/]?([^/]+)$"
|
||||
filmName = string.match(image.film.path, pattern)
|
||||
|
||||
-- Create the thumbnails
|
||||
for _,image in pairs(image_table) do
|
||||
local path, filename, filetype = string.match(image, "(.-)([^\\/]-%.?([^%.\\/]*))$")
|
||||
filename = string.upper(string.gsub(filename,"%.", "_"))
|
||||
|
||||
-- convert -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.
|
||||
-- Strip accents from the filename, because GoogleEarth can't open them
|
||||
-- https://github.com/darktable-org/lua-scripts/issues/54
|
||||
filmName = ds.strip_accents(filmName)
|
||||
|
||||
local concertToThumbCommand = "convert -size 96x96 "..image.." -resize 92x92 -mattecolor \"#FFFFFF\" -frame 2x2 +profile \"*\" "..exportDirectory.."/"..imageFoldername.."thumb_"..filename..".jpg"
|
||||
-- USE coroutine.yield. It does not block the UI
|
||||
coroutine.yield("RUN_COMMAND", concertToThumbCommand)
|
||||
local concertCommand = "convert -size 438x438 "..image.." -resize 438x438 +profile \"*\" "..exportDirectory.."/"..imageFoldername..filename..".jpg"
|
||||
coroutine.yield("RUN_COMMAND", concertCommand)
|
||||
-- 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
|
||||
|
||||
local pattern = "[/]?([^/]+)$"
|
||||
filmName = string.match(_.film.path, pattern)
|
||||
end
|
||||
exportKMLFilename = filmName..".kml"
|
||||
exportKMZFilename = filmName..".kmz"
|
||||
|
||||
exportKMLFilename = filmName..".kml"
|
||||
exportKMZFilename = filmName..".kmz"
|
||||
-- Create the KML file
|
||||
local kml_file = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
kml_file = kml_file.."<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n"
|
||||
kml_file = kml_file.."<Document>\n"
|
||||
|
||||
-- Create the KML file
|
||||
kml_file = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
kml_file = kml_file.."<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n"
|
||||
kml_file = kml_file.."<Document>\n"
|
||||
--image_table = dt.gui.selection();
|
||||
kml_file = kml_file.."<name>"..filmName.."</name>\n"
|
||||
kml_file = kml_file.." <description>Exported from darktable</description>\n"
|
||||
|
||||
--image_table = dt.gui.selection();
|
||||
kml_file = kml_file.."<name>"..filmName.."</name>\n"
|
||||
kml_file = kml_file.." <description>Exported from darktable</description>\n"
|
||||
|
||||
for image,_ in pairs(image_table) do
|
||||
filename = string.upper(string.gsub(image.filename,"%.", "_"))
|
||||
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*$")
|
||||
|
||||
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
|
||||
kml_file = kml_file.." <Placemark>\n"
|
||||
kml_file = kml_file.." <name>"..image.filename.."</name>\n"
|
||||
--kml_file = kml_file.." <description></description>\n"
|
||||
|
||||
kml_file = kml_file.." <Style>\n"
|
||||
kml_file = kml_file.." <IconStyle>\n"
|
||||
kml_file = kml_file.." <Icon>\n"
|
||||
kml_file = kml_file.." <href>"..imageFoldername.."thumb_"..filename..".jpg</href>\n"
|
||||
kml_file = kml_file.." </Icon>\n"
|
||||
kml_file = kml_file.." </IconStyle>\n"
|
||||
kml_file = kml_file.." <BalloonStyle>\n"
|
||||
kml_file = kml_file.." <text><![CDATA[<img src=\""..imageFoldername..filename..".jpg\"><br/>]]></text>\n"
|
||||
kml_file = kml_file.." <textColor>ff000000</textColor>\n"
|
||||
kml_file = kml_file.." <displayMode>default</displayMode>\n"
|
||||
kml_file = kml_file.." </BalloonStyle>\n"
|
||||
kml_file = kml_file.." </Style>\n"
|
||||
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
|
||||
kml_file = kml_file.." <Placemark>\n"
|
||||
|
||||
kml_file = kml_file.." <Point>\n"
|
||||
kml_file = kml_file.." <extrude>1</extrude>\n"
|
||||
kml_file = kml_file.." <coordinates>"..string.gsub(tostring(image.longitude),",", ".")..","..string.gsub(tostring(image.latitude),",", ".")..",0</coordinates>\n"
|
||||
kml_file = kml_file.." <TimeStamp>\n"
|
||||
kml_file = kml_file.." <when>"..string.gsub(image.exif_datetime_taken," ", "T").."Z".."</when>\n"
|
||||
kml_file = kml_file.." </TimeStamp>\n"
|
||||
kml_file = kml_file.." </Point>\n"
|
||||
|
||||
kml_file = kml_file.." </Placemark>\n"
|
||||
end
|
||||
end
|
||||
|
||||
-- Connects all images with an path
|
||||
if ( dt.preferences.read("kml_export","CreatePath","bool") == true ) then
|
||||
kml_file = kml_file.." <Placemark>\n"
|
||||
kml_file = kml_file.." <name>Path</name>\n" -- ToDo: I think a better name would be nice
|
||||
--kml_file = kml_file.." <description></description>\n"
|
||||
|
||||
kml_file = kml_file.." <Style>\n"
|
||||
kml_file = kml_file.." <LineStyle>\n"
|
||||
kml_file = kml_file.." <color>ff0000ff</color>\n"
|
||||
kml_file = kml_file.." <width>5</width>\n"
|
||||
kml_file = kml_file.." </LineStyle>\n"
|
||||
kml_file = kml_file.." </Style>\n"
|
||||
|
||||
kml_file = kml_file.." <LineString>\n"
|
||||
kml_file = kml_file.." <coordinates>\n"
|
||||
|
||||
for image,_ in spairs(image_table, function(t,a,b) return t[b] < t[a] 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
|
||||
kml_file = kml_file.." "..string.gsub(tostring(image.longitude),",", ".")..","..string.gsub(tostring(image.latitude),",", ".")..",0\n"
|
||||
end
|
||||
local image_title, image_description
|
||||
if (image.title and image.title ~= "") then
|
||||
image_title = ds.escape_xml_characters(image.title)
|
||||
else
|
||||
image_title = filename..extension
|
||||
end
|
||||
kml_file = kml_file.." </coordinates>\n"
|
||||
kml_file = kml_file.." </LineString>\n"
|
||||
-- Characters should not be escaped in CDATA, but we are using HTML fragment, so we must escape them
|
||||
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"
|
||||
kml_file = kml_file.." <Style>\n"
|
||||
kml_file = kml_file.." <IconStyle>\n"
|
||||
kml_file = kml_file.." <Icon>\n"
|
||||
kml_file = kml_file.." <href>"..imageFoldername.."thumb_"..filename..".jpg</href>\n"
|
||||
kml_file = kml_file.." </Icon>\n"
|
||||
kml_file = kml_file.." </IconStyle>\n"
|
||||
kml_file = kml_file.." <BalloonStyle>\n"
|
||||
kml_file = kml_file.." <text><![CDATA[<p><b>"..image_title.."</b></p><img src=\""..imageFoldername..filename..extension.."\"><p>"..image_description.."</p>]]></text>\n"
|
||||
kml_file = kml_file.." <textColor>ff000000</textColor>\n"
|
||||
kml_file = kml_file.." <displayMode>default</displayMode>\n"
|
||||
kml_file = kml_file.." </BalloonStyle>\n"
|
||||
kml_file = kml_file.." </Style>\n"
|
||||
|
||||
kml_file = kml_file.." <Point>\n"
|
||||
kml_file = kml_file.." <extrude>1</extrude>\n"
|
||||
kml_file = kml_file.." <coordinates>"..string.gsub(tostring(image.longitude),",", ".")..","..string.gsub(tostring(image.latitude),",", ".")..",0</coordinates>\n"
|
||||
kml_file = kml_file.." <TimeStamp>\n"
|
||||
kml_file = kml_file.." <when>"..string.gsub(image.exif_datetime_taken," ", "T").."Z".."</when>\n"
|
||||
kml_file = kml_file.." </TimeStamp>\n"
|
||||
kml_file = kml_file.." </Point>\n"
|
||||
|
||||
kml_file = kml_file.." </Placemark>\n"
|
||||
end
|
||||
end
|
||||
|
||||
kml_file = kml_file.."</Document>\n"
|
||||
kml_file = kml_file.."</kml>"
|
||||
-- Connects all images with an path
|
||||
if ( dt.preferences.read("kml_export","CreatePath","bool") == true ) then
|
||||
kml_file = kml_file.." <Placemark>\n"
|
||||
kml_file = kml_file.." <name>Path</name>\n" -- ToDo: I think a better name would be nice
|
||||
--kml_file = kml_file.." <description></description>\n"
|
||||
|
||||
file = io.open(exportDirectory.."/"..exportKMLFilename, "w")
|
||||
file:write(kml_file)
|
||||
file:close()
|
||||
kml_file = kml_file.." <Style>\n"
|
||||
kml_file = kml_file.." <LineStyle>\n"
|
||||
kml_file = kml_file.." <color>ff0000ff</color>\n"
|
||||
kml_file = kml_file.." <width>5</width>\n"
|
||||
kml_file = kml_file.." </LineStyle>\n"
|
||||
kml_file = kml_file.." </Style>\n"
|
||||
|
||||
dt.print("KML file created in "..exportDirectory)
|
||||
kml_file = kml_file.." <LineString>\n"
|
||||
kml_file = kml_file.." <coordinates>\n"
|
||||
|
||||
-- Compress the files to create a KMZ file
|
||||
if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true ) then
|
||||
exportDirectory = dt.preferences.read("kml_export","ExportDirectory","string")
|
||||
-- USE coroutine.yield. It does not block the UI
|
||||
local createKMZCommand = "zip --test --move --junk-paths "
|
||||
createKMZCommand = createKMZCommand .."\""..exportDirectory.."/"..exportKMZFilename.."\" "
|
||||
createKMZCommand = createKMZCommand .."\""..dt.configuration.tmp_dir.."/"..exportKMLFilename.."\" \""..dt.configuration.tmp_dir.."/"..imageFoldername.."\"*"
|
||||
coroutine.yield("RUN_COMMAND", createKMZCommand)
|
||||
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
|
||||
local altitude = 0;
|
||||
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
|
||||
|
||||
-- Open the file with the standard programm
|
||||
if ( dt.preferences.read("kml_export","OpenKmlFile","bool") == true ) then
|
||||
local kmlFileOpenCommand
|
||||
kml_file = kml_file.." </coordinates>\n"
|
||||
kml_file = kml_file.." </LineString>\n"
|
||||
|
||||
if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true ) then
|
||||
kmlFileOpenCommand = "xdg-open "..exportDirectory.."/\""..exportKMZFilename.."\""
|
||||
else
|
||||
kmlFileOpenCommand = "xdg-open "..exportDirectory.."/\""..exportKMLFilename.."\""
|
||||
end
|
||||
coroutine.yield("RUN_COMMAND", kmlFileOpenCommand)
|
||||
kml_file = kml_file.." </Placemark>\n"
|
||||
end
|
||||
|
||||
kml_file = kml_file.."</Document>\n"
|
||||
kml_file = kml_file.."</kml>"
|
||||
|
||||
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
|
||||
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..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..PS..imageFoldername.."thumb_"..filename..".jpg\" " -- thumbnails
|
||||
createKMZCommand = createKMZCommand .."\""..exported_image.."\" " -- images
|
||||
end
|
||||
end
|
||||
|
||||
dt.control.execute(createKMZCommand)
|
||||
end
|
||||
|
||||
-- Open the file with the standard programm
|
||||
if ( dt.preferences.read("kml_export","OpenKmlFile","bool") == true ) then
|
||||
local path
|
||||
|
||||
if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true
|
||||
and dt.configuration.running_os == "linux") then
|
||||
path = exportDirectory..PS..exportKMZFilename
|
||||
else
|
||||
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
|
||||
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 programm for KML files", false )
|
||||
if dt.configuration.running_os == "windows" then
|
||||
dt.preferences.register("kml_export",
|
||||
"OpenKmlFile",
|
||||
"bool",
|
||||
_("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 )
|
||||
end
|
||||
|
||||
local handle = io.popen("xdg-user-dir DESKTOP")
|
||||
local result = handle:read()
|
||||
handle:close()
|
||||
dt.preferences.register("kml_export", "ExportDirectory", "directory", "KML export: Export directory", "A directory that will be used to export the KML/KMZ files", result )
|
||||
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", "CreatePath", "bool", "KML export: Connect images with path", "connect all images with a path", false )
|
||||
dt.preferences.register("kml_export", "CreateKMZ", "bool", "KML export: Create KMZ file", "Compress all imeges to one KMZ file", true )
|
||||
|
||||
dt.preferences.register("kml_export",
|
||||
"ExportDirectory",
|
||||
"directory",
|
||||
_("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"),
|
||||
_("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"),
|
||||
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;
|
||||
|
||||
114
contrib/passport_guide.lua
Normal file
114
contrib/passport_guide.lua
Normal file
@@ -0,0 +1,114 @@
|
||||
--[[
|
||||
Passport cropping guide for darktable
|
||||
|
||||
copyright (c) 2017 Kåre Hampf
|
||||
|
||||
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 photos based on documents from the Finnish police
|
||||
(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
|
||||
* add the following line in the file $CONFIGDIR/luarc
|
||||
require "passport_guide"
|
||||
* (optional) add the line:
|
||||
"plugins/darkroom/clipping/extra_aspect_ratios/passport 36x47mm=47:36"
|
||||
to $CONFIGDIR/darktablerc
|
||||
|
||||
USAGE
|
||||
* when using the cropping tool, select "passport" as guide and if you added the line in yout rc
|
||||
select "passport 36x47mm" 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")
|
||||
|
||||
local function _(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)
|
||||
local _width, _height
|
||||
|
||||
-- get the max 36x47 rectangle
|
||||
local aspect_ratio = 47 / 36
|
||||
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 / 36, _height / 47)
|
||||
|
||||
-- the outer rectangle
|
||||
cairo:rectangle( 0, 0, 36, 47)
|
||||
|
||||
-- vertical bars
|
||||
cairo:draw_line(16.5, 8, 16.5, 36)
|
||||
cairo:draw_line(19.5, 8, 19.5, 36)
|
||||
|
||||
-- long horisontal bars
|
||||
cairo:draw_line(6, 4, 30, 4)
|
||||
cairo:draw_line(6, 40, 30, 40)
|
||||
|
||||
-- short horisontal bars
|
||||
cairo:draw_line(9, 6, 27, 6)
|
||||
cairo:draw_line(9, 38, 27, 38)
|
||||
|
||||
cairo:restore()
|
||||
end,
|
||||
-- gui
|
||||
function()
|
||||
return dt.new_widget("label"){label = _("ISO 19794-5/ICAO 9309 passport"), halign = "start"}
|
||||
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
|
||||
125
contrib/passport_guide_germany.lua
Normal file
125
contrib/passport_guide_germany.lua
Normal 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
|
||||
267
contrib/pdf_slideshow.lua
Normal file
267
contrib/pdf_slideshow.lua
Normal file
@@ -0,0 +1,267 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
copyright (c) 2017 Pascal Obry
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
SELECTION_TO_PDF
|
||||
Generates a PDF slideshow (via Latex) containing all selected images
|
||||
one per slide.
|
||||
|
||||
ADDITIANAL SOFTWARE NEEDED FOR THIS SCRIPT
|
||||
* a PDF-Viewer
|
||||
* pdflatex (Latex)
|
||||
|
||||
USAGE
|
||||
* require this file from your main lua config file:
|
||||
|
||||
This plugin will add a new exporter that will allow you to generate a pdf slideshow.
|
||||
The interface will let you add:
|
||||
- a global title for the slideshow (prefix in all slide label)
|
||||
- a delay for the transition between each slide
|
||||
|
||||
Each slide will contain a single picture with a label at the bottom with the
|
||||
format (all fields can be the empty string):
|
||||
|
||||
<global title> / <image creator> / <image title>
|
||||
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
local df = require "lib/dtutils.file"
|
||||
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
local function _(msgid)
|
||||
return gettext(msgid)
|
||||
end
|
||||
|
||||
if not df.check_if_bin_exists("pdflatex") then
|
||||
dt.print_error("pdflatex not found")
|
||||
return
|
||||
end
|
||||
|
||||
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",
|
||||
_("a pdf viewer"),
|
||||
_("can be an absolute pathname or the tool may be in the PATH"),
|
||||
"xdg-open")
|
||||
|
||||
local title_widget = dt.new_widget("entry") {
|
||||
placeholder=_("slideshow title")
|
||||
}
|
||||
local delay_widget = dt.new_widget("slider")
|
||||
{
|
||||
label = _("transition delay (s)"),
|
||||
soft_min = 1, -- The soft minimum value for the slider, the slider can't go beyond this point
|
||||
soft_max = 20, -- The soft maximum value for the slider, the slider can't go beyond this point
|
||||
hard_min = 1, -- The hard minimum value for the slider, the user can't manually enter a value beyond this point
|
||||
hard_max = 60, -- The hard maximum value for the slider, the user can't manually enter a value beyond this point
|
||||
value = 5, -- The current value of the slider
|
||||
step = 1,
|
||||
digits = 0
|
||||
}
|
||||
local check_button_title = dt.new_widget("check_button")
|
||||
{
|
||||
label = _('include image title'),
|
||||
value = true,
|
||||
tooltip = _('whether to include the image title (if defined) into the slide')
|
||||
}
|
||||
local check_button_author = dt.new_widget("check_button")
|
||||
{
|
||||
label = _('include image author'),
|
||||
value = true,
|
||||
tooltip = _('whether to include the image author (if defined) into the slide')
|
||||
}
|
||||
local widget = dt.new_widget("box") {
|
||||
orientation=horizontal,
|
||||
dt.new_widget("label"){label = _("slideshow title")},
|
||||
title_widget,
|
||||
dt.new_widget("label"){label = ""},
|
||||
delay_widget,
|
||||
check_button_author,
|
||||
check_button_title
|
||||
}
|
||||
|
||||
local ending = [[
|
||||
\end{document}
|
||||
]]
|
||||
|
||||
-- only jpeg files are supported by latex
|
||||
local function support_format(storage, format)
|
||||
fmt = string.lower(format.name)
|
||||
if string.match(fmt,"jpeg") ~= nil and string.match(fmt,"2000") == nil then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local filename =dt.configuration.tmp_dir.."/pdfout.tex"
|
||||
|
||||
local function my_write(latexfile,arg)
|
||||
local res,errmsg = latexfile:write(arg)
|
||||
if not res then
|
||||
error(errmsg)
|
||||
end
|
||||
end
|
||||
|
||||
local function img_filename(file,i)
|
||||
local dir=string.gsub(file, "(.*)(%/.*%..*)", "%1")
|
||||
local ext=string.gsub(file, "(.*)(%..*)", "%2")
|
||||
local lfile = dir.."/slide"..i..ext
|
||||
return lfile
|
||||
end
|
||||
|
||||
local function slide(latexfile,i,image,file)
|
||||
local title = ""
|
||||
if title_widget.text ~= "" then
|
||||
title = title_widget.text
|
||||
end
|
||||
if check_button_author.value == true and image.creator ~= "" then
|
||||
if title ~= "" then
|
||||
title = title.." / "
|
||||
end
|
||||
title = title..image.creator
|
||||
end
|
||||
if check_button_title.value == true and image.title ~= "" then
|
||||
if title ~= "" then
|
||||
title = title.." / "
|
||||
end
|
||||
title = title..image.title
|
||||
end
|
||||
|
||||
-- make sure there is no non-printable characters in the title
|
||||
title = string.gsub(title, "\n", "")
|
||||
title = string.gsub(title, "\r", "")
|
||||
title = string.gsub(title, "\t", "")
|
||||
|
||||
local lfile = img_filename(file,i)
|
||||
os.rename(file, lfile)
|
||||
|
||||
my_write(latexfile,"\\begin{figure}\n")
|
||||
my_write(latexfile,"\\begin{measuredfigure}\n")
|
||||
my_write(latexfile,"\\includegraphics[height=0.92\\textheight]{"..lfile.."}\n")
|
||||
my_write(latexfile,"\\end{measuredfigure}\n")
|
||||
my_write(latexfile,"\\caption{{\\color{white}"..title.."}}\n")
|
||||
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)
|
||||
|
||||
local preamble = [[
|
||||
\documentclass[a4paper,12pt,landscape]{beamer}
|
||||
\usetheme{default}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{threeparttable}
|
||||
\usepackage[space]{grffile} % needed to support filename with spaces
|
||||
\pagestyle{empty}
|
||||
\parindent0pt
|
||||
\usepackage{geometry}
|
||||
\usepackage{color}
|
||||
\pagecolor{black!100}
|
||||
\color{white}
|
||||
\geometry{a4paper,landscape,left=2mm,right=2mm, top=2mm, bottom=2mm}
|
||||
\mode<presentation>
|
||||
\transduration{]]..string.gsub(delay_widget.value, ",", ".")..[[}
|
||||
\setbeamertemplate{footline}{}
|
||||
\setbeamertemplate{headline}{}
|
||||
\setbeamertemplate{frametitle}{}
|
||||
\setbeamertemplate{navigation symbols}{}
|
||||
\setbeamercolor{background canvas}{fg=white,bg=black!100}
|
||||
\setbeamercolor{normal text}{fg=white}
|
||||
\hypersetup{pdfstartpage=1,pdfpagemode=FullScreen}
|
||||
\setbeamertemplate{caption}{\insertcaption}
|
||||
\begin{document}
|
||||
]]
|
||||
|
||||
local errmsg
|
||||
local latexfile
|
||||
latexfile,errmsg=io.open(filename,"w")
|
||||
if not latexfile then
|
||||
error(errmsg)
|
||||
end
|
||||
my_write(latexfile,preamble)
|
||||
local i = 1
|
||||
for img,file in pairs(image_table) do
|
||||
slide(latexfile,i,img,file)
|
||||
my_write(latexfile,"\n\\bigskip\n")
|
||||
i = i+1
|
||||
end
|
||||
my_write(latexfile,ending)
|
||||
latexfile:close()
|
||||
|
||||
-- convert to PDF
|
||||
local dir=string.gsub(filename, "(.*/)(.*)", "%1")
|
||||
local locfile=string.gsub(filename, "(.*/)(.*)", "%2")
|
||||
local command = "pdflatex -halt-on-error -output-directory "..dir.." "..locfile
|
||||
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)
|
||||
end
|
||||
|
||||
-- open the PDF
|
||||
local pdffile=string.gsub(filename, ".tex", ".pdf")
|
||||
command = dt.preferences.read("pdf_slideshow","open with","string")
|
||||
command = command.." "..pdffile
|
||||
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)
|
||||
end
|
||||
|
||||
-- finally do some clean-up
|
||||
local i = 1
|
||||
for img,file in pairs(image_table) do
|
||||
local lfile = img_filename(file,i)
|
||||
os.remove(lfile)
|
||||
i = i+1
|
||||
end
|
||||
end,
|
||||
support_format,
|
||||
nil,
|
||||
widget)
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
--
|
||||
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
|
||||
507
contrib/photils.lua
Normal file
507
contrib/photils.lua
Normal 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
|
||||
318
contrib/quicktag.lua
Normal file
318
contrib/quicktag.lua
Normal file
@@ -0,0 +1,318 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
Copyright (C) 2017 by Christian Kanzian
|
||||
|
||||
Thanks to
|
||||
Copyright (C) 2016 Bill Ferguson
|
||||
Copyright (C) 2017 Tobias Jakobs
|
||||
|
||||
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/>.
|
||||
]]
|
||||
|
||||
--[[
|
||||
QUICKTAG
|
||||
For faster attaching your favorite tags, the script adds shortcuts and
|
||||
the module "quicktag" in lighttable mode with a changeable number of buttons.
|
||||
To each button a tag can be assigned. If the tags do not exist in your database,
|
||||
they are added to the database once they get the first time attached to an image.
|
||||
|
||||
The number of buttons/shortcuts can be changed in the lua preferences.
|
||||
Changes in the number require a restart of darktable.
|
||||
|
||||
INSTALATION
|
||||
* copy this file in $CONFIGDIR/lua/ where CONFIGDIR is your darktable configuration directory
|
||||
* add the following line in the file $CONFIGDIR/luarc require "quicktag"
|
||||
|
||||
USAGE
|
||||
* set the number of quicktags between 2 and 10 in the preferences dialog and restart darktable
|
||||
* if wanted set the shortcuts in the preferences dialog
|
||||
* to add or change a quicktag, first select the old tag with the combobox "old quicktag",
|
||||
enter a new tag in the "new quicktag" filed and press "set quicktag"
|
||||
* use a shortcut or button to attach the tag to selected images
|
||||
]]
|
||||
|
||||
|
||||
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.gettext
|
||||
|
||||
local function _(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",
|
||||
"integer", -- type
|
||||
_("max. length of button labels"), -- label
|
||||
_("may range from 15 to 60 - needs a restart"), -- tooltip
|
||||
25, -- default
|
||||
15, -- min
|
||||
60)
|
||||
|
||||
|
||||
|
||||
local max_label_length = dt.preferences.read("quickTag", "labellength", "integer")
|
||||
|
||||
-- register number of quicktags
|
||||
dt.preferences.register("quickTag",
|
||||
"quickTagnumber",
|
||||
"integer", -- type
|
||||
_("number of quicktag fields"), -- label
|
||||
_("may range from 2 to 20 - needs a restart"), -- tooltip
|
||||
5, -- default
|
||||
2, -- min
|
||||
20)
|
||||
|
||||
local qnr = dt.preferences.read("quickTag", "quickTagnumber", "integer")
|
||||
|
||||
|
||||
|
||||
-- get quicktags from the preferences
|
||||
local quicktag_table = {}
|
||||
|
||||
|
||||
local function read_pref_tags()
|
||||
for j=1,qnr do
|
||||
quicktag_table[j] = dt.preferences.read("quickTag", "quicktag"..j, "string")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local quicktag_label = {}
|
||||
|
||||
|
||||
local function abbrevate_tags(t)
|
||||
for i=1,qnr do
|
||||
local taglength = string.len(t[i])
|
||||
if taglength > max_label_length then
|
||||
local max_2 = math.floor(max_label_length/2)
|
||||
quicktag_label[i] = string.sub(t[i],0,max_2).."..."..string.sub(t[i],taglength - max_2)
|
||||
else
|
||||
quicktag_label[i] = t[i]
|
||||
end
|
||||
-- print(quicktag_label[i])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- quicktag function to attach tags
|
||||
local function tagattach(tag,qtagnr)
|
||||
if tag == "" then
|
||||
dt.print(string.format(_("quicktag %i is empty, please set a tag"), qtagnr))
|
||||
return true
|
||||
end
|
||||
|
||||
local tagnr = dt.tags.find(tag)
|
||||
|
||||
--create tag if it does not exist
|
||||
if tagnr == nil then
|
||||
dt.tags.create(tag)
|
||||
tagnr = dt.tags.find(tag)
|
||||
end
|
||||
|
||||
local sel_images = dt.gui.action_images
|
||||
|
||||
if next(sel_images) == nil then
|
||||
dt.print(_("no images selected"))
|
||||
return true
|
||||
end
|
||||
|
||||
local counter = 0
|
||||
|
||||
for _,image in ipairs(sel_images) do
|
||||
dt.tags.attach(tagnr,image)
|
||||
counter = counter+1
|
||||
end
|
||||
dt.print(string.format(_("tag \"%s\" attached to %i image(s)"), tag, counter))
|
||||
end
|
||||
|
||||
|
||||
-- create quicktag module elements
|
||||
-- read tags from preferences for initialization
|
||||
read_pref_tags()
|
||||
abbrevate_tags(quicktag_table)
|
||||
|
||||
|
||||
local button = {}
|
||||
|
||||
-- function to create buttons with tags as labels
|
||||
for j = 1, qnr do
|
||||
button[#button+1] = dt.new_widget("button") {
|
||||
label = j..": "..quicktag_table[j],
|
||||
clicked_callback = function() tagattach(tostring(quicktag_table[j]),j) end}
|
||||
end
|
||||
|
||||
|
||||
local old_quicktag = dt.new_widget("combobox"){
|
||||
label = _("old tag"),
|
||||
tooltip = _("select the quicktag to replace")
|
||||
}
|
||||
|
||||
local function update_quicktag_list()
|
||||
-- abrevate long tags for the labels
|
||||
abbrevate_tags(quicktag_table)
|
||||
for j=1,qnr do
|
||||
button[j].label = j..": "..quicktag_label[j]
|
||||
old_quicktag[j] = j..": "..quicktag_table[j]
|
||||
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 = false,
|
||||
editable = true,
|
||||
tooltip = _("enter your tag here")
|
||||
}
|
||||
|
||||
local set_quicktag_button = dt.new_widget("button") {
|
||||
label = _("set tag"),
|
||||
clicked_callback = function()
|
||||
local old_tag = quicktag_table[old_quicktag.selected]
|
||||
if new_quicktag.text == "" then
|
||||
dt.print(_("new quicktag is empty!"))
|
||||
else
|
||||
quicktag_table[old_quicktag.selected] = new_quicktag.text
|
||||
dt.preferences.write("quickTag", "quicktag"..old_quicktag.selected, "string", new_quicktag.text)
|
||||
dt.print(string.format(_("quicktag \"%s\" replaced by \"%s\""), old_tag, new_quicktag.text))
|
||||
update_quicktag_list()
|
||||
new_quicktag.text = ""
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
local new_qt_widget = dt.new_widget ("box") {
|
||||
orientation = "horizontal",
|
||||
dt.new_widget("label") { label = _("new tag") },
|
||||
new_quicktag,
|
||||
set_quicktag_button
|
||||
}
|
||||
|
||||
|
||||
-- back UI elements in a table
|
||||
-- thanks to wpferguson for the hint
|
||||
|
||||
for i=1,qnr do
|
||||
qt.widget_table[#qt.widget_table + 1] = button[i]
|
||||
end
|
||||
|
||||
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
|
||||
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("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;
|
||||
132
contrib/rate_group.lua
Normal file
132
contrib/rate_group.lua
Normal file
@@ -0,0 +1,132 @@
|
||||
--[[
|
||||
|
||||
Rate Group:
|
||||
|
||||
Script to provide shortcuts for rating or rejecting all images within a group;
|
||||
particularly useful for RAW+JPEG shooters employing a star rating workflow
|
||||
like the below:
|
||||
|
||||
http://blog.chasejarvis.com/blog/2011/03/photo-editing-101/
|
||||
|
||||
|
||||
Installation and usage:
|
||||
|
||||
1. Copy this file into ~/.config/darktable/lua/
|
||||
|
||||
2. Add `require "rate_group"` to new line in ~/.config/darktable/luarc
|
||||
|
||||
3. Restart darktable
|
||||
|
||||
4. Assign a keyboard shortcut to each action via settings > shortcuts > lua
|
||||
|
||||
I use the following shortcuts:
|
||||
|
||||
* Reject group: Ctrl+R
|
||||
* Rate group 1: Ctrl+1
|
||||
* Rate group 2: Ctrl+2
|
||||
* Rate group 3: Ctrl+3
|
||||
* Rate group 4: Ctrl+4
|
||||
* Rate group 5: Ctrl+5
|
||||
* Rate group 0: Ctrl+0
|
||||
|
||||
|
||||
Author: Dom H (dom@hxy.io)
|
||||
License: GPLv2
|
||||
|
||||
This script is based on Thibault Jouannic's `reject_group` script:
|
||||
http://redmine.darktable.org/issues/8968#note-20
|
||||
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
-- added version check
|
||||
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
|
||||
for _, i in ipairs(images) do
|
||||
local members = i:get_group_members()
|
||||
for _, m in ipairs(members) do
|
||||
m.rating = rating
|
||||
end
|
||||
end
|
||||
if rating < 0 then
|
||||
dt.print(_("rejecting group(s)"))
|
||||
else
|
||||
dt.print(string.format(_("applying rating %d to group(s)"), rating))
|
||||
end
|
||||
end
|
||||
|
||||
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"))
|
||||
|
||||
dt.register_event("rg0", "shortcut",
|
||||
function(event, shortcut)
|
||||
apply_rating(0)
|
||||
end, string.format(_("rate group %d"), 0)
|
||||
)
|
||||
|
||||
dt.register_event("rg1", "shortcut",
|
||||
function(event, shortcut)
|
||||
apply_rating(1)
|
||||
end, string.format(_("rate group %d"), 1))
|
||||
|
||||
dt.register_event("rg2", "shortcut",
|
||||
function(event, shortcut)
|
||||
apply_rating(2)
|
||||
end, string.format(_("rate group %d"), 2))
|
||||
|
||||
dt.register_event("rg3", "shortcut",
|
||||
function(event, shortcut)
|
||||
apply_rating(3)
|
||||
end, string.format(_("rate group %d"), 3))
|
||||
|
||||
dt.register_event("rg4", "shortcut",
|
||||
function(event, shortcut)
|
||||
apply_rating(4)
|
||||
end, string.format(_("rate group %d"), 4))
|
||||
|
||||
dt.register_event("rg5", "shortcut",
|
||||
function(event, shortcut)
|
||||
apply_rating(5)
|
||||
end, string.format(_("rate group %d"), 5))
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
188
contrib/rename-tags.lua
Normal file
188
contrib/rename-tags.lua
Normal file
@@ -0,0 +1,188 @@
|
||||
--[[
|
||||
Copyright (c) 2016 Sebastian Witt <se.witt@gmx.net>
|
||||
Copyright (c) 2018 Bill Ferguson <wpferguson@gmail.com>
|
||||
]]
|
||||
--[[
|
||||
Rename tags
|
||||
|
||||
AUTHOR
|
||||
Sebastian Witt (se.witt@gmx.net)
|
||||
|
||||
INSTALLATION
|
||||
* copy this file in $CONFIGDIR/lua/ where CONFIGDIR
|
||||
is your darktable configuration directory
|
||||
* add the following line in the file $CONFIGDIR/luarc
|
||||
require "rename-tags"
|
||||
|
||||
USAGE
|
||||
* In lighttable there is a new entry: 'rename tag'
|
||||
* Enter old tag (this one gets deleted!)
|
||||
* Enter new tag name
|
||||
|
||||
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 function rename_reset()
|
||||
old_tag.text = ''
|
||||
new_tag.text = ''
|
||||
end
|
||||
|
||||
-- This function does the renaming
|
||||
local function rename_tags()
|
||||
-- If entries are empty, return
|
||||
if old_tag.text == '' then
|
||||
darktable.print (_("old tag can't be empty"))
|
||||
return
|
||||
end
|
||||
if new_tag.text == '' then
|
||||
darktable.print (_("new tag can't be empty"))
|
||||
return
|
||||
end
|
||||
|
||||
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"))
|
||||
return
|
||||
end
|
||||
|
||||
-- Show job
|
||||
local job = darktable.gui.create_job (_("renaming tag"), true)
|
||||
|
||||
old_tag.editable = false
|
||||
new_tag.editable = false
|
||||
|
||||
-- Create if it does not exists
|
||||
local nt = darktable.tags.create (new_tag.text)
|
||||
|
||||
-- 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
|
||||
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 (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") },
|
||||
old_tag
|
||||
}
|
||||
|
||||
local new_widget = darktable.new_widget ("box") {
|
||||
orientation = "horizontal",
|
||||
darktable.new_widget("label") { label = _("new tag") },
|
||||
new_tag
|
||||
}
|
||||
|
||||
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 }
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
||||
236
contrib/rename_images.lua
Normal file
236
contrib/rename_images.lua
Normal 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
|
||||
124
contrib/select_non_existing.lua
Normal file
124
contrib/select_non_existing.lua
Normal 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
|
||||
90
contrib/select_untagged.lua
Normal file
90
contrib/select_untagged.lua
Normal file
@@ -0,0 +1,90 @@
|
||||
--[[
|
||||
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/>.
|
||||
]]
|
||||
|
||||
--[[
|
||||
Enable selection of untagged images (darktable|* tags are ignored)
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
du.check_min_api_version("7.0.0", "select_untagged")
|
||||
|
||||
local function _(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(event, images)
|
||||
job = dt.gui.create_job(_("select untagged images"), true, stop_job)
|
||||
|
||||
local selection = {}
|
||||
|
||||
for key,image in ipairs(images) do
|
||||
if(job.valid) then
|
||||
job.percent = (key - 1)/#images
|
||||
local tags = dt.tags.get_tags(image)
|
||||
local hasTags = false
|
||||
for _,tag in ipairs(tags) do
|
||||
if not string.match(tag.name, "darktable|") then
|
||||
hasTags = true
|
||||
end
|
||||
end
|
||||
if hasTags == false then
|
||||
table.insert(selection, image)
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
job.valid = false
|
||||
-- return table of images to set the selection to
|
||||
return selection
|
||||
end
|
||||
|
||||
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
|
||||
199
contrib/selected_image_visible.lua
Normal file
199
contrib/selected_image_visible.lua
Normal 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
|
||||
@@ -23,30 +23,42 @@ You need rhythmbox-client installed to use this script
|
||||
USAGE
|
||||
* require this script from your main lua file
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
dt.configuration.check_version(...,{2,0,2})
|
||||
|
||||
local function checkIfBinExists(bin)
|
||||
local handle = io.popen("which "..bin)
|
||||
local result = handle:read()
|
||||
local ret
|
||||
handle:close()
|
||||
if (not result) then
|
||||
dt.print_error(bin.." not found")
|
||||
ret = false
|
||||
end
|
||||
ret = true
|
||||
return ret
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
local df = require "lib/dtutils.file"
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
du.check_min_api_version("7.0.0", "slideshowMusic")
|
||||
|
||||
local function _(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
|
||||
|
||||
filename = dt.preferences.read("slideshowMusic","SlideshowMusic","string")
|
||||
playMusic = dt.preferences.read("slideshowMusic","PlaySlideshowMusic","bool")
|
||||
|
||||
if not checkIfBinExists("rhythmbox-client") then
|
||||
if not df.check_if_bin_exists("rhythmbox-client") then
|
||||
dt.print_error("rhythmbox-client not found")
|
||||
return
|
||||
end
|
||||
|
||||
@@ -55,26 +67,37 @@ local function playSlideshowMusic(_, old_view, new_view)
|
||||
|
||||
if (new_view.id == "slideshow") then
|
||||
playCommand = 'rhythmbox-client --play-uri="'..filename..'"'
|
||||
|
||||
|
||||
--dt.print_error(playCommand)
|
||||
coroutine.yield("RUN_COMMAND", playCommand)
|
||||
dt.control.execute( playCommand)
|
||||
else
|
||||
if (old_view.id == "slideshow") then
|
||||
if (old_view and old_view.id == "slideshow") then
|
||||
stopCommand = "rhythmbox-client --pause"
|
||||
--dt.print_error(stopCommand)
|
||||
coroutine.yield("RUN_COMMAND", stopCommand)
|
||||
dt.control.execute(stopCommand)
|
||||
end
|
||||
end
|
||||
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",
|
||||
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
|
||||
|
||||
313
contrib/toggle_group_view.lua
Normal file
313
contrib/toggle_group_view.lua
Normal 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
408
contrib/transfer_hierarchy.lua
Executable 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
1066
contrib/ultrahdr.lua
Normal file
File diff suppressed because it is too large
Load Diff
485
contrib/video_ffmpeg.lua
Normal file
485
contrib/video_ffmpeg.lua
Normal file
@@ -0,0 +1,485 @@
|
||||
--[[Timelapse video plugin based on ffmpeg for darktable 2.4.X and 2.6.X
|
||||
|
||||
copyright (c) 2018, 2019 Dominik Markiewicz
|
||||
|
||||
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 will add the new export module "video ffmpeg".
|
||||
|
||||
----REQUIRED SOFTWARE----
|
||||
ffmpeg
|
||||
|
||||
----USAGE----
|
||||
1. Go to Lighttable
|
||||
2. Select images you want to use as a video ffmpeg frames
|
||||
3. In image export module select "video ffmpeg"
|
||||
4. Configure you video settings
|
||||
5. Export
|
||||
|
||||
----WARNING----
|
||||
This script has been tested under Linux only
|
||||
]]
|
||||
|
||||
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
|
||||
|
||||
du.check_min_api_version("7.0.0", "video_ffmpeg")
|
||||
|
||||
local function _(msgid)
|
||||
return gettext(msgid)
|
||||
end
|
||||
|
||||
-- return data structure for script_manager
|
||||
|
||||
local script_data = {}
|
||||
|
||||
script_data.metadata = {
|
||||
name = _("video ffmpeg"),
|
||||
purpose = _("timelapse video plugin based on ffmpeg"),
|
||||
author = "Dominik Markiewicz",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contib/video_ffmpeg"
|
||||
}
|
||||
|
||||
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 MODULE_NAME = "video_ffmpeg"
|
||||
|
||||
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
|
||||
|
||||
---- DECLARATIONS
|
||||
|
||||
local resolutions = {
|
||||
["QVGA"] = {
|
||||
["label"] = "QVGA 320x240 (4:3)",
|
||||
["w"] = 320,
|
||||
["h"] = 240
|
||||
},
|
||||
["HVGA"] = {
|
||||
["label"] = "HVGA 480x320 (3:2)",
|
||||
["w"] = 480,
|
||||
["h"] = 320
|
||||
},
|
||||
["VGA"] = {
|
||||
["label"] = "VGA 640x480 (4:3)",
|
||||
["w"] = 640,
|
||||
["h"] = 480
|
||||
},
|
||||
["HDTV 720p"] = {
|
||||
["label"] = "HDTV 720p 1280x720 (16:9)",
|
||||
["w"] = 1280,
|
||||
["h"] = 720
|
||||
},
|
||||
["HDTV 1080p"] = {
|
||||
["label"] = "HDTV 1080p 1920x1080 (16:9)",
|
||||
["w"] = 1920,
|
||||
["h"] = 1080
|
||||
},
|
||||
["Cinema TV"] = {
|
||||
["label"] = "Cinema TV 2560x1080 (21:9)",
|
||||
["w"] = 2560,
|
||||
["h"] = 1080
|
||||
},
|
||||
["2K"] = {
|
||||
["label"] = "2K 2048x1152 (16:9)",
|
||||
["w"] = 2048,
|
||||
["h"] = 1152
|
||||
},
|
||||
["4K"] = {
|
||||
["label"] = "4K 4096x2304 (16:9)",
|
||||
["w"] = 4096,
|
||||
["h"] = 2304
|
||||
}
|
||||
}
|
||||
|
||||
local framerates = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "15", "16", "23.98", "24", "25", "29,97", "30", "48", "50", "59.94", "60", "120", "240", "300"}
|
||||
|
||||
local formats = {
|
||||
["AVI"] = {
|
||||
["extension"] = "avi",
|
||||
["codecs"] = {"mpeg4", "h263p", "h264", "mpeg2video", "hevc", "vp9"}
|
||||
},
|
||||
["Matroska"] = {
|
||||
["extension"] = "mkv",
|
||||
["codecs"] = {"h264", "h263p", "mpeg4", "mpeg2video", "hevc", "vp9"}
|
||||
},
|
||||
["WebM"] = {
|
||||
["extension"] = "webm",
|
||||
["codecs"] = {"vp9", "h263p", "h264", "mpeg4", "mpeg2video", "hevc"}
|
||||
},
|
||||
["MP4"] = {
|
||||
["extension"] = "mp4",
|
||||
["codecs"] = {"h264", "h263p", "mpeg4", "mpeg2video"}
|
||||
},
|
||||
["QuickTime"] = {
|
||||
["extension"] = "mov",
|
||||
["codecs"] = {"h264", "h263p", "mpeg4", "mpeg2video"}
|
||||
}
|
||||
}
|
||||
|
||||
local res_list = {}
|
||||
for i, v in pairs(resolutions) do
|
||||
table.insert(res_list, v["label"])
|
||||
end
|
||||
|
||||
table.sort(res_list)
|
||||
|
||||
-- inital fulfill list of all available formats
|
||||
local format_list = {}
|
||||
for i,v in pairs(formats) do
|
||||
table.insert(format_list, i)
|
||||
end
|
||||
table.sort(format_list)
|
||||
|
||||
-- initial fulfill list of all available codecs for the first (default if nothig saved yet) format
|
||||
-- if format was changed and stored in preferences, this list will be replaced by one matching selected format
|
||||
local codec_list = formats[format_list[1]]["codecs"]
|
||||
table.sort(codec_list)
|
||||
|
||||
local function extract_resolution(description)
|
||||
for _, v in pairs(resolutions) do
|
||||
if v["label"] == description then
|
||||
return v["w"].."x"..v["h"]
|
||||
end
|
||||
end
|
||||
return "100x100"
|
||||
end
|
||||
|
||||
---- GENERIC UTILS
|
||||
|
||||
local function replace_combobox_elements(combobox, new_items, to_select)
|
||||
if to_select == nil then
|
||||
to_select = combobox.value
|
||||
end
|
||||
|
||||
to_select_idx = 1
|
||||
for i , name in ipairs(new_items) do
|
||||
if name == to_select then
|
||||
to_select_idx = i
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local old_elements_count = #combobox
|
||||
for i, name in ipairs(new_items) do
|
||||
combobox[i] = name
|
||||
end
|
||||
if old_elements_count > #new_items then
|
||||
for j = old_elements_count, #new_items + 1, -1 do
|
||||
combobox[j] = nil
|
||||
end
|
||||
end
|
||||
|
||||
combobox.value = to_select_idx
|
||||
end
|
||||
|
||||
--[[
|
||||
This function allow to format string by substitute tokens like `{label}` by value provided in `symbols` table
|
||||
ex:
|
||||
```lua
|
||||
format_string("I like {bananas} and {potatos}. {bananas}!", {["bananas"]: "darktable", ["potatos"]: "lua"})
|
||||
-> "I like darktable and lua. darktable!"
|
||||
```
|
||||
|
||||
I you want to preserve given currly braces, you need to escape it by backslash like so:
|
||||
```lua
|
||||
format_string("it preserve \\{label\\} but substitute {label}", {["label"]: "this"})
|
||||
-> "It preserve {label} but substitute "
|
||||
```
|
||||
--]]
|
||||
local function format_string(label, symbols)
|
||||
local es1, es2 = "\u{ffe0}", "\u{ffe1}" -- for simplicity, just some strange utf characters
|
||||
local result = label:gsub("\\{", es1):gsub("\\}", es2)
|
||||
for s,v in pairs(symbols) do
|
||||
result = result:gsub("{"..s.."}", v)
|
||||
end
|
||||
return result:gsub(es1, "{"):gsub(es2, "}")
|
||||
end
|
||||
|
||||
----- COMPONENTS
|
||||
|
||||
local function combobox_pref_read(name, all_values)
|
||||
local value = dt.preferences.read(MODULE_NAME, name, "string")
|
||||
for i,v in pairs(all_values) do
|
||||
if v == value then return i end
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
local function combobox_pref_write(name)
|
||||
local writer = function(widget)
|
||||
dt.preferences.write(MODULE_NAME, name, "string", widget.value)
|
||||
end
|
||||
return writer
|
||||
end
|
||||
|
||||
local function string_pref_read(name, default)
|
||||
local value = dt.preferences.read(MODULE_NAME, name, "string")
|
||||
if value ~= nil and value ~= "" then return value end
|
||||
return default
|
||||
end
|
||||
|
||||
local function string_pref_write(name, widget_attribute)
|
||||
widget_attribute = widget_attribute or "value"
|
||||
local writer = function(widget)
|
||||
dt.preferences.write(MODULE_NAME, name, "string", widget[widget_attribute])
|
||||
end
|
||||
return writer
|
||||
end
|
||||
|
||||
local framerates_selector = dt.new_widget("combobox"){
|
||||
label = _("frame rate"),
|
||||
tooltip = _("select frame rate of output video"),
|
||||
value = combobox_pref_read("framerate", framerates),
|
||||
changed_callback = combobox_pref_write("framerate"),
|
||||
table.unpack(framerates)
|
||||
}
|
||||
|
||||
local res_selector = dt.new_widget("combobox"){
|
||||
label = _("resolution"),
|
||||
tooltip = _("select resolution of output video"),
|
||||
value = combobox_pref_read("resolution", res_list),
|
||||
changed_callback = combobox_pref_write("resolution"),
|
||||
table.unpack(res_list)
|
||||
}
|
||||
|
||||
local codec_selector = dt.new_widget("combobox"){
|
||||
label = _("codec"),
|
||||
tooltip = _("select codec"),
|
||||
value = combobox_pref_read("codec", codec_list),
|
||||
changed_callback = combobox_pref_write("codec"),
|
||||
table.unpack(codec_list)
|
||||
}
|
||||
|
||||
local format_selector = dt.new_widget("combobox"){
|
||||
label = _("format container"),
|
||||
tooltip = _("select format of output video"),
|
||||
value = combobox_pref_read("format", format_list),
|
||||
changed_callback = function(widget)
|
||||
combobox_pref_write("format")(widget)
|
||||
codec_list = formats[widget.value]["codecs"]
|
||||
table.sort(codec_list)
|
||||
replace_combobox_elements(codec_selector, codec_list)
|
||||
end,
|
||||
table.unpack(format_list)
|
||||
}
|
||||
|
||||
local destination_label = dt.new_widget("section_label"){
|
||||
label = _("output file destination"),
|
||||
tooltip = _("settings of output file destination and name")
|
||||
}
|
||||
|
||||
local defaultVideoDir = ''
|
||||
if dt.configuration.running_os == "windows" then
|
||||
defaultVideoDir = os.getenv("USERPROFILE")..PS .."videos"
|
||||
elseif dt.configuration.running_os == "macos" then
|
||||
defaultVideoDir = os.getenv("HOME")..PS.."Videos"
|
||||
else
|
||||
local handle = io.popen("xdg-user-dir VIDEOS")
|
||||
defaultVideoDir = handle:read()
|
||||
handle:close()
|
||||
end
|
||||
|
||||
local output_directory_chooser = dt.new_widget("file_chooser_button"){
|
||||
title = _("select export path"),
|
||||
is_directory = true,
|
||||
tooltip =_("select the target directory for the timelapse. \nthe filename is created automatically."),
|
||||
value = string_pref_read("export_path", defaultVideoDir),
|
||||
changed_callback = string_pref_write("export_path")
|
||||
}
|
||||
|
||||
local auto_output_directory_btn = dt.new_widget("check_button") {
|
||||
label = "",
|
||||
tooltip = _("if selected, output video will be placed in the same directory as first of selected images"),
|
||||
value = not dt.preferences.read(MODULE_NAME, "not_auto_output_directory", "bool"), -- reverse, for true as default
|
||||
clicked_callback = function (widget)
|
||||
dt.preferences.write(MODULE_NAME, "not_auto_output_directory", "bool", not widget.value)
|
||||
output_directory_chooser.sensitive = not output_directory_chooser.sensitive
|
||||
end
|
||||
}
|
||||
|
||||
local destination_box = dt.new_widget("box") {
|
||||
orientation = "horizontal",
|
||||
auto_output_directory_btn,
|
||||
output_directory_chooser
|
||||
}
|
||||
|
||||
local override_output_cb = dt.new_widget("check_button"){
|
||||
label = _("override output file on conflict"),
|
||||
tooltip = _("if checked, in case of file name conflict, the file will be overwritten"),
|
||||
value = dt.preferences.read(MODULE_NAME, "override_output", "bool"),
|
||||
clicked_callback = function (widget)
|
||||
dt.preferences.write(MODULE_NAME, "override_output", "bool", widget.value)
|
||||
end
|
||||
}
|
||||
|
||||
local filename_entry = dt.new_widget("entry"){
|
||||
tooltip = _("enter output file name without extension.\n\n"..
|
||||
"You can use some placeholders:\n"..
|
||||
"- {time} - time in format HH-mm-ss\n"..
|
||||
"- {date} - date in foramt YYYY-mm-dd\n"..
|
||||
"- {first_file} - name of first input file\n"..
|
||||
"- {last_file} - name of last last_file"
|
||||
),
|
||||
text = string_pref_read("filename_entry","timelapse_{date}_{time}"),
|
||||
-- changed_callback = string_pref_write("filename_entry", "text") -- Not imlemented yet
|
||||
}
|
||||
|
||||
local output_box = dt.new_widget("box"){
|
||||
orientation="vertical",
|
||||
destination_label,
|
||||
override_output_cb,
|
||||
destination_box,
|
||||
filename_entry,
|
||||
}
|
||||
|
||||
local open_after_export_cb = dt.new_widget("check_button"){
|
||||
label = _(" open after export"),
|
||||
tooltip = _("open video file after successful export"),
|
||||
value = dt.preferences.read(MODULE_NAME, "open_after_export", "bool"),
|
||||
clicked_callback = function (widget)
|
||||
dt.preferences.write(MODULE_NAME, "open_after_export", "bool", widget.value)
|
||||
end
|
||||
}
|
||||
|
||||
local widgets_list = {}
|
||||
if not df.check_if_bin_exists("ffmpeg") then
|
||||
table.insert(widgets_list, df.executable_path_widget({"ffmpeg"}))
|
||||
end
|
||||
table.insert(widgets_list, res_selector)
|
||||
table.insert(widgets_list, framerates_selector)
|
||||
table.insert(widgets_list, format_selector)
|
||||
table.insert(widgets_list, codec_selector)
|
||||
table.insert(widgets_list, output_box)
|
||||
table.insert(widgets_list, open_after_export_cb)
|
||||
|
||||
|
||||
local module_widget = dt.new_widget("box") {
|
||||
orientation = "vertical",
|
||||
table.unpack(widgets_list)
|
||||
}
|
||||
|
||||
---- EXPORT & REGISTRATION
|
||||
|
||||
local function show_status(enf_storage, image, format, filename, number, total, high_quality, extra_data)
|
||||
dt.print(string.format(_("export %d / %d", number), total))
|
||||
end
|
||||
|
||||
local function init_export(storage, img_format, images, high_quality, extra_data)
|
||||
-- store filename preference here cause there is no changed_callback on entry yet
|
||||
string_pref_write("filename_entry", "text")(filename_entry)
|
||||
|
||||
extra_data["images"] = images -- needed, to preserve images order
|
||||
extra_data["tmp_dir"] = dt.configuration.tmp_dir..PS..MODULE_NAME.."_"..os.time()
|
||||
extra_data["fps"] = framerates_selector.value
|
||||
extra_data["res"] = extract_resolution(res_selector.value)
|
||||
extra_data["codec"] = codec_selector.value
|
||||
extra_data["img_ext"] = "."..img_format.extension
|
||||
local override_output = override_output_cb.value
|
||||
local output_directory = auto_output_directory_btn.value and images[1].path or output_directory_chooser.value
|
||||
local filename_mappings = {
|
||||
date = os.date("%Y-%m-%d"),
|
||||
time = os.date("%H-%M-%S"),
|
||||
first_file = images[1].filename,
|
||||
last_file = images[#images].filename
|
||||
}
|
||||
local output_extension = "."..formats[format_selector.value]["extension"]
|
||||
local filename = format_string(filename_entry.text, filename_mappings)
|
||||
local path = output_directory..PS..filename..output_extension
|
||||
if not override_output then
|
||||
path = df.create_unique_filename(path)
|
||||
end
|
||||
|
||||
extra_data["output_file"] = path
|
||||
extra_data["open_after_export"] = open_after_export_cb.value
|
||||
end
|
||||
|
||||
local function export(extra_data)
|
||||
local ffmpeg_path = df.check_if_bin_exists("ffmpeg")
|
||||
if not ffmpeg_path then
|
||||
dt.print_error("ffmpeg not found")
|
||||
dt.print(_("ERROR - ffmpeg not found"))
|
||||
return
|
||||
end
|
||||
local dir = extra_data["tmp_dir"]
|
||||
local fps = extra_data["fps"]
|
||||
local res = extra_data["res"]
|
||||
local codec = extra_data["codec"]
|
||||
local img_ext = extra_data["img_ext"]
|
||||
local output_file = extra_data["output_file"]
|
||||
|
||||
local dir_create_result = df.mkdir(df.sanitize_filename(df.get_path(output_file)))
|
||||
if dir_create_result ~= 0 then return dir_create_result end
|
||||
|
||||
local cmd = ffmpeg_path.." -y -r "..fps.." -i "..dir..PS.."%d"..img_ext.." -s:v "..res.." -c:v "..codec.." -crf 18 -preset veryslow "..df.sanitize_filename(output_file)
|
||||
return dsys.external_command(cmd), output_file
|
||||
end
|
||||
|
||||
local function finalize_export(storage, images_table, extra_data)
|
||||
local tmp_dir = extra_data["tmp_dir"]
|
||||
|
||||
dt.print(_("prepare merge process"))
|
||||
|
||||
local result = df.mkdir(df.sanitize_filename(tmp_dir))
|
||||
if result ~= 0 then dt.print(_("ERROR: cannot create temp directory")) end
|
||||
|
||||
local images = extra_data["images"]
|
||||
-- rename all images to consecutive numbers
|
||||
for i, file in pairs(images) do
|
||||
local filename = images_table[file]
|
||||
dt.print_error(filename, file.filename)
|
||||
df.file_move(filename, tmp_dir .. PS .. i .. extra_data["img_ext"])
|
||||
end
|
||||
dt.print(_("start video building..."))
|
||||
local result, path = export(extra_data)
|
||||
if result ~= 0 then
|
||||
dt.print(_("ERROR: cannot build image, see console for more info"))
|
||||
else
|
||||
dt.print(_("SUCCESS"))
|
||||
if extra_data["open_after_export"] then
|
||||
dsys.launch_default_app(df.sanitize_filename(path))
|
||||
end
|
||||
end
|
||||
|
||||
df.rmdir(df.sanitize_filename(tmp_dir))
|
||||
end
|
||||
|
||||
-- script_manager integration
|
||||
|
||||
local function destroy()
|
||||
dt.destroy_storage("module_video_ffmpeg")
|
||||
end
|
||||
|
||||
dt.register_storage(
|
||||
"module_video_ffmpeg",
|
||||
_("video ffmpeg"),
|
||||
show_status,
|
||||
finalize_export,
|
||||
nil,
|
||||
init_export,
|
||||
module_widget
|
||||
)
|
||||
|
||||
-- script_manager integration
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
@@ -1,120 +0,0 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
Copyright 2014 by Tobias Jakobs.
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
darktable video export script
|
||||
|
||||
ADDITIANAL SOFTWARE NEEDED FOR THIS SCRIPT
|
||||
* mencoder (MEncoder is from the MPlayer Team)
|
||||
* xdg-open
|
||||
* xdg-user-dir
|
||||
|
||||
WARNING
|
||||
This script is only testet with Linux
|
||||
|
||||
USAGE
|
||||
* require this script from your main lua file
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
dt.configuration.check_version(...,{2,0,1})
|
||||
|
||||
local function show_status(storage, image, format, filename, number, total, high_quality, extra_data)
|
||||
dt.print("Export Image "..tostring(number).."/"..tostring(total))
|
||||
end
|
||||
|
||||
local function checkIfBinExists(bin)
|
||||
local handle = io.popen("which "..bin)
|
||||
local result = handle:read()
|
||||
local ret
|
||||
handle:close()
|
||||
if (result) then
|
||||
--dt.print_error("true checkIfBinExists: "..bin)
|
||||
ret = true
|
||||
else
|
||||
dt.print_error(bin.." not found")
|
||||
ret = false
|
||||
end
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
local function create_video_mencoder(storage, image_table, extra_data)
|
||||
if not checkIfBinExists("mencoder") then
|
||||
return
|
||||
end
|
||||
if not checkIfBinExists("xdg-open") then
|
||||
return
|
||||
end
|
||||
if not checkIfBinExists("xdg-user-dir") then
|
||||
return
|
||||
end
|
||||
|
||||
exportDirectory = dt.preferences.read("video_mencoder","ExportDirectory","string")
|
||||
exportFilename = "output.avi"
|
||||
framsePerSecond = dt.preferences.read("video_mencoder","FramesPerSecond","integer")
|
||||
|
||||
dt.print_error("Will try to create video now")
|
||||
-- Set the codec
|
||||
local codec = ""
|
||||
local codecPreferences = ""
|
||||
|
||||
codecPreferences = dt.preferences.read("video_mencoder","Codec","string")
|
||||
if (codecPreferences == "H.264 encoding") then
|
||||
codec = 'x264'
|
||||
end
|
||||
if (codecPreferences == "XviD encoding") then
|
||||
codec = 'xvid'
|
||||
end
|
||||
if not codecPreferences then
|
||||
codec = 'x264'
|
||||
end
|
||||
|
||||
-- Create the command
|
||||
local command = "mencoder -idx -nosound -noskip -ovc "..codec.." -lavcopts vcodec=mjpeg -o "..exportDirectory.."/"..exportFilename.." -mf fps="..framsePerSecond .." mf://"
|
||||
|
||||
for _,v in pairs(image_table) do
|
||||
command = command..v..","
|
||||
end
|
||||
|
||||
dt.print_error("this is the command: "..command)
|
||||
-- USE coroutine.yield. It does not block the UI
|
||||
coroutine.yield("RUN_COMMAND", command)
|
||||
|
||||
dt.print("Video created in "..exportDirectory)
|
||||
|
||||
if ( dt.preferences.read("video_mencoder","OpenVideo","bool") == true ) then
|
||||
-- USE coroutine.yield. It does not block the UI
|
||||
local playVideoCommand = "xdg-open "..exportDirectory.."/"..exportFilename
|
||||
coroutine.yield("RUN_COMMAND", playVideoCommand)
|
||||
end
|
||||
end
|
||||
|
||||
-- Preferences
|
||||
dt.preferences.register("video_mencoder", "FramesPerSecond", "float", "Video exort (MEncoder): Frames per second", "Frames per Second in the Video export", 15, 1, 99, 0.1 )
|
||||
dt.preferences.register("video_mencoder", "OpenVideo", "bool", "Video exort (MEncoder): Open video after export", "Opens the Video after the export with the standard video player", false )
|
||||
|
||||
local handle = io.popen("xdg-user-dir VIDEOS")
|
||||
local result = handle:read()
|
||||
handle:close()
|
||||
dt.preferences.register("video_mencoder", "ExportDirectory", "directory", "Video exort (MEncoder): Video export directory","A directory that will be used to export a Video",result)
|
||||
|
||||
-- Get the MEncoder codec list with: mencoder -ovc help
|
||||
dt.preferences.register("video_mencoder", "Codec", "enum", "Video exort (MEncoder): Codec","Video codec","H.264 encoding","H.264 encoding","XviD encoding")
|
||||
|
||||
-- Register
|
||||
dt.register_storage("video_mencoder", "Video Export (MEncoder)", show_status, create_video)
|
||||
294
contrib/website_gallery_export.lua
Normal file
294
contrib/website_gallery_export.lua
Normal file
@@ -0,0 +1,294 @@
|
||||
--[[Export module to create a web gallery from selected images
|
||||
|
||||
copyright (c) 2025 Tino Mettler
|
||||
|
||||
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 this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
]]
|
||||
|
||||
--[[
|
||||
TODO:
|
||||
- Lua: remove images dir if already existent
|
||||
- Lua: translations
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
local df = require "lib/dtutils.file"
|
||||
|
||||
local PS <const> = dt.configuration.running_os == "windows" and "\\" or "/"
|
||||
|
||||
local temp = dt.preferences.read('web_gallery', 'title', 'string')
|
||||
if temp == nil then temp = 'Darktable gallery' end
|
||||
|
||||
local function _(msgid)
|
||||
return dt.gettext.gettext(msgid)
|
||||
end
|
||||
|
||||
local title_widget = dt.new_widget("entry")
|
||||
{
|
||||
text = temp
|
||||
}
|
||||
|
||||
local temp = dt.preferences.read('web_gallery', 'destination_dir', 'string')
|
||||
if temp == nil then temp = '' end
|
||||
|
||||
local dest_dir_widget = dt.new_widget("file_chooser_button")
|
||||
{
|
||||
title = _("select output folder"),
|
||||
tooltip = _("select output folder"),
|
||||
value = temp,
|
||||
is_directory = true,
|
||||
changed_callback = function(this) dt.preferences.write('web_gallery', 'destination_dir', 'string', this.value) end
|
||||
}
|
||||
|
||||
local gallery_widget = dt.new_widget("box")
|
||||
{
|
||||
orientation=vertical,
|
||||
dt.new_widget("label"){label = _("gallery title")},
|
||||
title_widget,
|
||||
dt.new_widget("label"){label = _("destination directory")},
|
||||
dest_dir_widget
|
||||
}
|
||||
|
||||
local function get_file_name(file)
|
||||
return file:match("[^" .. PS .. "]*.$")
|
||||
end
|
||||
|
||||
function escape_js_string(str)
|
||||
local replacements = {
|
||||
['\\'] = '\\\\',
|
||||
['"'] = '\\"',
|
||||
["'"] = "\\'",
|
||||
['\n'] = '\\n',
|
||||
['\r'] = '\\r',
|
||||
['\t'] = '\\t',
|
||||
['\b'] = '\\b',
|
||||
['\f'] = '\\f',
|
||||
['\v'] = '\\v'
|
||||
}
|
||||
return (str:gsub('[\\\"\n\r\t\b\f\v\']', replacements))
|
||||
end
|
||||
|
||||
local function export_thumbnail(image, filename)
|
||||
exporter = dt.new_format("jpeg")
|
||||
exporter.quality = 90
|
||||
exporter.max_height = 512
|
||||
exporter.max_width = 512
|
||||
exporter:write_image(image, filename, true)
|
||||
end
|
||||
|
||||
local function write_image(image, dest_dir, filename)
|
||||
df.file_move(filename, dest_dir.. PS .. "images" .. PS .. get_file_name(filename))
|
||||
export_thumbnail(image, dest_dir .. PS .. "thumbnails" .. PS .. "thumb_" .. get_file_name(filename))
|
||||
end
|
||||
|
||||
function exiftool_get_image_dimensions(filename)
|
||||
local handle = io.popen("exiftool " .. filename)
|
||||
local result = handle:read("*a")
|
||||
handle:close()
|
||||
for line in result:gmatch("[^\r\n]+") do
|
||||
local w = line:match("^Image Width%s*:%s*(%d+)")
|
||||
if w then
|
||||
width = tonumber(w)
|
||||
end
|
||||
local h = line:match("^Image Height%s*:%s*(%d+)")
|
||||
if h then
|
||||
height = tonumber(h)
|
||||
end
|
||||
end
|
||||
if width and height then
|
||||
return width, height
|
||||
else
|
||||
return nil, nil
|
||||
end
|
||||
end
|
||||
|
||||
local function stop_job(job)
|
||||
job.valid = false
|
||||
end
|
||||
|
||||
local function fill_gallery_table(images_ordered, images_table, title, dest_dir, sizes, exiftool)
|
||||
local gallery_data = { name = escape_js_string(title) }
|
||||
|
||||
local images = {}
|
||||
local index = 1
|
||||
local job = dt.gui.create_job(_("exporting thumbnail images"), true, stop_job)
|
||||
|
||||
for i, image in pairs(images_ordered) do
|
||||
local filename = df.sanitize_filename(images_table[image])
|
||||
dt.print(_("export thumbnail image ") .. index .. "/" .. #images_ordered)
|
||||
write_image(image, dest_dir, filename)
|
||||
|
||||
if exiftool then
|
||||
width, height = exiftool_get_image_dimensions(df.sanitize_filename(dest_dir .. PS .. "images" .. PS .. get_file_name(filename)))
|
||||
else
|
||||
width = sizes[index].width
|
||||
height = sizes[index].height
|
||||
end
|
||||
|
||||
local entry = { filename = "images" .. PS .. get_file_name(filename),
|
||||
width = width, height = height }
|
||||
|
||||
images[index] = entry
|
||||
job.percent = index / #images_ordered
|
||||
index = index + 1
|
||||
end
|
||||
|
||||
stop_job(job)
|
||||
gallery_data.images = images
|
||||
return gallery_data
|
||||
end
|
||||
|
||||
local function generate_javascript_gallery_object(gallery)
|
||||
local js = 'const gallery_data = {\n'
|
||||
js = js .. ' name: "' .. gallery.name .. '",\n'
|
||||
js = js .. ' images: [\n'
|
||||
|
||||
for i, img in ipairs(gallery.images) do
|
||||
js = js .. string.format(' { filename: "%s",\n height: %d,\n width: %d }', img.filename, img.height, img.width)
|
||||
if i < #gallery.images then
|
||||
js = js .. ',\n'
|
||||
else
|
||||
js = js .. '\n'
|
||||
end
|
||||
end
|
||||
|
||||
js = js .. ' ]\n};\n'
|
||||
|
||||
return(js)
|
||||
end
|
||||
|
||||
local function write_javascript_file(gallery_table, dest_dir)
|
||||
dt.print(_("write JavaScript file"))
|
||||
javascript_object = generate_javascript_gallery_object(gallery_table)
|
||||
|
||||
local fileOut, errr = io.open(dest_dir .. PS .. "js" .. PS .. "images.js", 'w+')
|
||||
if fileOut then
|
||||
fileOut:write(javascript_object)
|
||||
else
|
||||
log.msg(log.error, errr)
|
||||
end
|
||||
fileOut:close()
|
||||
end
|
||||
|
||||
local function copy_static_files(dest_dir)
|
||||
|
||||
gfsrc = dt.configuration.config_dir .. PS .. "lua" .. PS .. "data" .. PS .. "website_gallery"
|
||||
local gfiles = {
|
||||
"index.html",
|
||||
"css" .. PS .. "gallery.css",
|
||||
"css" .. PS .. "modal.css",
|
||||
"css" .. PS .. "style.css",
|
||||
"js" .. PS .. "gallery.js",
|
||||
"js" .. PS .. "modal.js",
|
||||
"js" .. PS .. "fullscreen.js"
|
||||
}
|
||||
|
||||
dt.print(_("copy static gallery files"))
|
||||
for _, file in ipairs(gfiles) do
|
||||
df.file_copy(gfsrc .. PS .. file, dest_dir .. PS .. file)
|
||||
end
|
||||
end
|
||||
|
||||
local function build_gallery(storage, images_table, extra_data)
|
||||
local dest_dir = dest_dir_widget.value
|
||||
df.mkdir(df.sanitize_filename(dest_dir))
|
||||
df.mkdir(df.sanitize_filename(dest_dir .. PS .. "images"))
|
||||
df.mkdir(df.sanitize_filename(dest_dir .. PS .. "thumbnails"))
|
||||
df.mkdir(df.sanitize_filename(dest_dir .. PS .. "css"))
|
||||
df.mkdir(df.sanitize_filename(dest_dir .. PS .. "js"))
|
||||
|
||||
local images_ordered = extra_data["images"] -- process images in the correct order
|
||||
local sizes = extra_data["sizes"]
|
||||
local title = _("Darktable export")
|
||||
if title_widget.text ~= "" then
|
||||
title = title_widget.text
|
||||
end
|
||||
local exiftool = df.check_if_bin_exists("exiftool");
|
||||
gallerydata = fill_gallery_table(images_ordered, images_table, title, dest_dir, sizes, exiftool)
|
||||
write_javascript_file(gallerydata, dest_dir)
|
||||
copy_static_files(dest_dir)
|
||||
end
|
||||
|
||||
local script_data = {}
|
||||
|
||||
script_data.metadata = {
|
||||
name = _("website gallery (new)"),
|
||||
purpose = _("create a web gallery from exported images"),
|
||||
author = "Tino Mettler <tino+darktable@tikei.de>",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/TODO"
|
||||
}
|
||||
|
||||
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 destroy()
|
||||
dt.preferences.write('web_gallery', 'title', 'string', title_widget.text)
|
||||
dt.destroy_storage("module_webgallery")
|
||||
end
|
||||
script_data.destroy = destroy
|
||||
|
||||
local function show_status(storage, image, format, filename,
|
||||
number, total, high_quality, extra_data)
|
||||
dt.print(string.format(_("export image ").."%i/%i", number, total))
|
||||
aspect = image.aspect_ratio
|
||||
-- calculate the size of the exported image and store it in extra_data
|
||||
-- to make it available in the finalize function
|
||||
if image.final_height == 0 then
|
||||
if aspect < 1 then
|
||||
dimensions = { width = image.height, height = image.width }
|
||||
else
|
||||
dimensions = { width = image.width, height = image.height }
|
||||
end
|
||||
else
|
||||
dimensions = { width = image.final_width, height = image.final_height }
|
||||
end
|
||||
if format.max_height > 0 and dimensions.height > format.max_height then
|
||||
scale = format.max_height / dimensions.height
|
||||
dimensions.height = math.floor(dimensions.height * scale + 0.5)
|
||||
dimensions.width = math.floor(dimensions.width * scale + 0.5)
|
||||
end
|
||||
if format.max_width > 0 and dimensions.width > format.max_width then
|
||||
scale = format.max_width / dimensions.width
|
||||
dimensions.height = math.floor(dimensions.height * scale + 0.5)
|
||||
dimensions.width = math.floor(dimensions.width * scale + 0.5)
|
||||
end
|
||||
extra_data["sizes"][number] = dimensions
|
||||
end
|
||||
|
||||
local function initialize(storage, img_format, images, high_quality, extra_data)
|
||||
dt.preferences.write('web_gallery', 'title', 'string', title_widget.text)
|
||||
extra_data["images"] = images -- needed, to preserve images order
|
||||
extra_data["sizes"] = {};
|
||||
end
|
||||
|
||||
local supported_formats = { "jpg", "tif", "png", "webp" }
|
||||
|
||||
local formats_lut = {}
|
||||
for key,format in pairs(supported_formats) do
|
||||
formats_lut[format] = true
|
||||
end
|
||||
|
||||
function check_supported(storage, format)
|
||||
extension = format.extension
|
||||
if formats_lut[extension] == true then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
dt.register_storage("module_webgallery", "website gallery (new)", show_status, build_gallery, check_supported, initialize, gallery_widget)
|
||||
|
||||
return script_data
|
||||
BIN
data/icons/blank20.png
Normal file
BIN
data/icons/blank20.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
BIN
data/icons/path20.png
Normal file
BIN
data/icons/path20.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.1 KiB |
56
data/website_gallery/css/gallery.css
Normal file
56
data/website_gallery/css/gallery.css
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
copyright (c) 2025 Tino Mettler
|
||||
|
||||
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 this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
body {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.heading h1 {
|
||||
text-align: center;
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.gallery {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.gallery img {
|
||||
cursor: pointer;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.thumb {
|
||||
object-fit: contain;
|
||||
flex-shrink: 0;
|
||||
min-width: 100%;
|
||||
min-height: 100%;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.thumb-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
object-fit: contain;
|
||||
justify-content: center;
|
||||
}
|
||||
99
data/website_gallery/css/modal.css
Normal file
99
data/website_gallery/css/modal.css
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
copyright (c) 2025 Tino Mettler
|
||||
|
||||
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 this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.viewer {
|
||||
position: relative;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
touch-action: none;
|
||||
overflow: hidden;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.navgrid {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.nav {
|
||||
height: var(--navigation-bar-height);
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
z-index: 1001;
|
||||
}
|
||||
|
||||
.slider {
|
||||
height: calc(100vh - var(--navigation-bar-height));
|
||||
position: relative;
|
||||
width: 100vw;
|
||||
touch-action: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.slide-container {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 300%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
transform: translateX(-33.333%);
|
||||
transition: transform 0.3s ease-out;
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.slide {
|
||||
width: 33.333%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background: #000;
|
||||
will-change: contents;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
touch-action: none;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.slide img {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
display: block;
|
||||
transform-origin: 0 0;
|
||||
cursor: zoom-in;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.slide.zoomed img {
|
||||
cursor: zoom-out;
|
||||
max-width: none;
|
||||
max-height: none;
|
||||
}
|
||||
|
||||
.slide img.zooming {
|
||||
transition: transform 0.2s ease-out;
|
||||
}
|
||||
|
||||
66
data/website_gallery/css/style.css
Normal file
66
data/website_gallery/css/style.css
Normal file
@@ -0,0 +1,66 @@
|
||||
body {
|
||||
font-family: system-ui, Arial, Helvetica, sans-serif;
|
||||
background-color: rgb(238, 240, 242);
|
||||
}
|
||||
|
||||
.heading h1 {
|
||||
background-color: #cdd;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.heading h1:after {
|
||||
content: " ";
|
||||
border-bottom: 1px solid #888888;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
.gallery {
|
||||
gap: 3vw;
|
||||
margin: 3vw auto;
|
||||
padding: 1.5vw;
|
||||
}
|
||||
|
||||
.gallery img {
|
||||
background: none;
|
||||
border: 1px outset #737780;
|
||||
|
||||
}
|
||||
|
||||
.gallery img:hover {
|
||||
transform: scale(1.08);
|
||||
}
|
||||
|
||||
.thumb-box {
|
||||
background: none;
|
||||
box-shadow: 0 1vw 4vw 1vw rgba(0,0,0,0.6);
|
||||
}
|
||||
|
||||
.viewer {
|
||||
--navigation-bar-height: 5vh;
|
||||
}
|
||||
|
||||
.nav {
|
||||
background-color: rgba(60,60,60, 0.4);
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.navgrid {
|
||||
grid-template-columns: 4em 1fr 1.5em 1.5em 1fr 1.5em 1.5em;
|
||||
font-size: 3.5vh;
|
||||
grid-column-gap: 1vw;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
.button {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
text-shadow: 0px 0px 10px #ccc;
|
||||
}
|
||||
|
||||
.counter {
|
||||
font-size: 2.5vh;
|
||||
}
|
||||
46
data/website_gallery/index.html
Normal file
46
data/website_gallery/index.html
Normal file
@@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||||
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="css/modal.css">
|
||||
<link rel="stylesheet" href="css/gallery.css">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<title id="page-title">Image Gallery</title>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="heading1" class="heading">
|
||||
<h1 id="gallery-title">Image Gallery</h1>
|
||||
</div>
|
||||
<div id="gallery" class="gallery"></div>
|
||||
<div class="viewer" id="viewer">
|
||||
<div class="navgrid">
|
||||
<div id="counter" class="nav"></div>
|
||||
<div class="spacer"></div>
|
||||
<div class="button nav nav-arrow" id="prevArrow">◀</div>
|
||||
<div class="button nav nav-arrow" id="nextArrow">▶</div>
|
||||
<div class="spacer"></div>
|
||||
<div id="fullscreen" class="button nav">⛶</div>
|
||||
<div id="close" class="nav button">×</div>
|
||||
</div>
|
||||
<div class="slider" id="slider1">
|
||||
<div class="slide-container">
|
||||
<div class="slide" id="prev"></div>
|
||||
<div class="slide" id="current"></div>
|
||||
<div class="slide" id="next"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type='text/javascript' >
|
||||
var currentIndex = 1;
|
||||
</script>
|
||||
<script src="js/images.js"></script>
|
||||
<script src="js/fullscreen.js"></script>
|
||||
<script src="js/modal.js"></script>
|
||||
<script src="js/gallery.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
40
data/website_gallery/js/fullscreen.js
Normal file
40
data/website_gallery/js/fullscreen.js
Normal file
@@ -0,0 +1,40 @@
|
||||
var isFullscreen = false;
|
||||
|
||||
var toggleFullscreen = function (ele) {
|
||||
return isFullscreen ? exitFullscreen(ele) : requestFullscreen(ele);
|
||||
};
|
||||
|
||||
var requestFullscreen = function (ele) {
|
||||
if(isFullscreen == true) return 0 ;
|
||||
|
||||
isFullscreen = true;
|
||||
if (ele.requestFullscreen) {
|
||||
ele.requestFullscreen();
|
||||
} else if (ele.webkitRequestFullscreen) {
|
||||
ele.webkitRequestFullscreen();
|
||||
} else if (ele.mozRequestFullScreen) {
|
||||
ele.mozRequestFullScreen();
|
||||
} else if (ele.msRequestFullscreen) {
|
||||
ele.msRequestFullscreen();
|
||||
} else {
|
||||
console.log('Fullscreen API is not supported.');
|
||||
}
|
||||
};
|
||||
|
||||
var exitFullscreen = function () {
|
||||
if(isFullscreen == false) return 0;
|
||||
|
||||
isFullscreen = false;
|
||||
if (document.exitFullscreen) {
|
||||
document.exitFullscreen();
|
||||
} else if (document.webkitExitFullscreen) {
|
||||
document.webkitExitFullscreen();
|
||||
} else if (document.mozCancelFullScreen) {
|
||||
document.mozCancelFullScreen();
|
||||
} else if (document.msExitFullscreen) {
|
||||
document.msExitFullscreen();
|
||||
} else {
|
||||
console.log('Fullscreen API is not supported.');
|
||||
}
|
||||
};
|
||||
|
||||
112
data/website_gallery/js/gallery.js
Normal file
112
data/website_gallery/js/gallery.js
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
copyright (c) 2025 Tino Mettler
|
||||
|
||||
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 this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var scrollPosX = 0;
|
||||
var scrollPosY = 0;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var imageCount = 0;
|
||||
const gallery = document.getElementById('gallery');
|
||||
const viewer = document.getElementById('viewer');
|
||||
|
||||
function showModal(e) {
|
||||
const thumbbox = e.target.parentElement;
|
||||
const index = [...gallery.children].indexOf(thumbbox);
|
||||
currentIndex = index;
|
||||
scrollPosX = document.documentElement.scrollLeft;
|
||||
scrollPosY = document.documentElement.scrollTop;
|
||||
|
||||
gallery.style.display = 'none';
|
||||
document.getElementById('heading1').style.display = 'none';
|
||||
viewer.style.display = 'grid';
|
||||
loadSlides();
|
||||
updateCounter(currentIndex);
|
||||
updateNavigationState();
|
||||
}
|
||||
|
||||
|
||||
function closeModal() {
|
||||
exitFullscreen(document.documentElement);
|
||||
viewer.style.display = 'none';
|
||||
document.getElementById('heading1').style.display = 'grid';
|
||||
gallery.style.display = 'flex';
|
||||
document.documentElement.scrollTo({
|
||||
left: scrollPosX,
|
||||
top: scrollPosY,
|
||||
behavior: "instant",
|
||||
});
|
||||
};
|
||||
|
||||
function createThumbnailElement(imageObj) {
|
||||
const frame = document.createElement('div');
|
||||
frame.className = 'thumb-box';
|
||||
const framesize = 18;
|
||||
|
||||
const width = parseInt(imageObj.width);
|
||||
const height = parseInt(imageObj.height);
|
||||
const sum = width + height;
|
||||
const scalefactor = sum / (framesize * 2.0);
|
||||
frame.style.width = (width / scalefactor) + 'vw';
|
||||
frame.style.height = (height / scalefactor) + 'vw';
|
||||
|
||||
const img = document.createElement('img');
|
||||
img.className = 'thumb';
|
||||
img.src = imageObj.filename.replace(/images\/(.*)$/i, 'thumbnails/thumb_$1');
|
||||
img.alt = imageObj.filename;
|
||||
img.addEventListener('click', function (e) { e.stopPropagation(); showModal(e); });
|
||||
|
||||
frame.appendChild(img);
|
||||
gallery.appendChild(frame);
|
||||
}
|
||||
|
||||
const images = gallery_data.images;
|
||||
|
||||
const title = document.getElementById('gallery-title');
|
||||
const pageTitle = document.getElementById('page-title');
|
||||
if (gallery_data.name) {
|
||||
title.textContent = gallery_data.name;
|
||||
pageTitle.textContent = gallery_data.name;
|
||||
}
|
||||
|
||||
|
||||
document.getElementById('close').onclick = function (e) {
|
||||
e.stopPropagation();
|
||||
closeModal();
|
||||
};
|
||||
|
||||
// Keyboard navigation using left/right arrow keys
|
||||
document.onkeyup = function (e) {
|
||||
e.stopPropagation();
|
||||
switch(e.key) {
|
||||
case "Escape":
|
||||
closeModal();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
document.getElementById('fullscreen').onclick = function (e) {
|
||||
e.stopPropagation();
|
||||
toggleFullscreen(document.documentElement);
|
||||
};
|
||||
|
||||
// Populate thumbnail gallery
|
||||
images.forEach(function (imageObj) {
|
||||
createThumbnailElement(imageObj);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
355
data/website_gallery/js/modal.js
Normal file
355
data/website_gallery/js/modal.js
Normal file
@@ -0,0 +1,355 @@
|
||||
/*
|
||||
copyright (c) 2025 Tino Mettler
|
||||
|
||||
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 this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const container = document.querySelector('.slide-container');
|
||||
const slides = {
|
||||
prev: document.getElementById('prev'),
|
||||
current: document.getElementById('current'),
|
||||
next: document.getElementById('next')
|
||||
};
|
||||
const prevArrow = document.getElementById('prevArrow');
|
||||
const nextArrow = document.getElementById('nextArrow');
|
||||
|
||||
let startX = 0;
|
||||
let startY = 0;
|
||||
let isDragging = false; // For swipe navigation
|
||||
let isZoomed = false;
|
||||
let isPanning = false; // Panning in zoomed state
|
||||
let hasPanned = false;
|
||||
let translateX = 0;
|
||||
let translateY = 0;
|
||||
let currentScale = 1;
|
||||
let img;
|
||||
|
||||
let baseWidth, baseHeight; // Image dimensions before zoom
|
||||
|
||||
let scaledWidth, scaledHeight;
|
||||
|
||||
const images = gallery_data.images;
|
||||
|
||||
function updateCounter(index) {
|
||||
const counter = document.getElementById('counter');
|
||||
counter.textContent = (index + 1) + ' / ' + images.length;
|
||||
}
|
||||
|
||||
function updateBoundaries() {
|
||||
containerRect = container.getBoundingClientRect();
|
||||
// Calculate the actual scaled dimensions based on the base (pre-zoom) size
|
||||
scaledWidth = baseWidth * currentScale;
|
||||
scaledHeight = baseHeight * currentScale;
|
||||
}
|
||||
|
||||
function limitPanning(proposedX, proposedY) {
|
||||
const maxX = 0;
|
||||
const minX = baseWidth - scaledWidth;
|
||||
|
||||
const maxY = 0;
|
||||
const minY = baseHeight - scaledHeight;
|
||||
|
||||
let constrainedX = proposedX;
|
||||
let constrainedY = proposedY;
|
||||
|
||||
// Apply constraints
|
||||
if (scaledWidth > baseWidth) {
|
||||
// Image wider than original - constrain panning
|
||||
constrainedX = Math.max(minX, Math.min(maxX, proposedX));
|
||||
} else {
|
||||
// Image narrower than original - center it
|
||||
constrainedX = (baseWidth - scaledWidth) / 2;
|
||||
}
|
||||
|
||||
if (scaledHeight > baseHeight) {
|
||||
// Image taller than original - constrain panning
|
||||
constrainedY = Math.max(minY, Math.min(maxY, proposedY));
|
||||
} else {
|
||||
// Image shorter than original - center it
|
||||
constrainedY = (baseHeight - scaledHeight) / 2;
|
||||
}
|
||||
|
||||
return {
|
||||
x: constrainedX,
|
||||
y: constrainedY
|
||||
};
|
||||
}
|
||||
|
||||
function handleZoom(e) {
|
||||
// If we were actually panning, don't zoom
|
||||
if (hasPanned) {
|
||||
isPanning = false;
|
||||
hasPanned = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're zoomed and haven't panned, zoom out
|
||||
if (isZoomed) {
|
||||
img.classList.add('zooming');
|
||||
translateX = 0;
|
||||
translateY = 0;
|
||||
currentScale = 1;
|
||||
img.style.transform = 'none';
|
||||
container.classList.remove('zoomed');
|
||||
isZoomed = false;
|
||||
updateNavigationState();
|
||||
|
||||
setTimeout(() => {
|
||||
img.classList.remove('zooming');
|
||||
}, 200);
|
||||
return;
|
||||
}
|
||||
|
||||
// Zoom in at clicked/tapped point
|
||||
if (!isZoomed) {
|
||||
const rect = img.getBoundingClientRect();
|
||||
const x = e.clientX - rect.left;
|
||||
const y = e.clientY - rect.top;
|
||||
|
||||
// Store the base (pre-zoom) dimensions and offset
|
||||
baseWidth = rect.width;
|
||||
baseHeight = rect.height;
|
||||
|
||||
// Calculate the scale for 1:1 pixel zoom
|
||||
currentScale = img.naturalWidth / rect.width;
|
||||
|
||||
// Calculate the translation needed to keep clicked point under cursor
|
||||
// After scaling, the point at (x, y) will be at (x * currentScale, y * currentScale)
|
||||
// We want it to remain at (e.clientX - rect.left, e.clientY - rect.top)
|
||||
translateX = e.clientX - rect.left - (x * currentScale);
|
||||
translateY = e.clientY - rect.top - (y * currentScale);
|
||||
|
||||
updateBoundaries();
|
||||
const limited = limitPanning(translateX, translateY);
|
||||
translateX = limited.x;
|
||||
translateY = limited.y;
|
||||
|
||||
img.classList.add('zooming');
|
||||
img.style.transform = `translate(${translateX}px, ${translateY}px) scale(${currentScale})`;
|
||||
container.classList.add('zoomed');
|
||||
|
||||
setTimeout(() => {
|
||||
img.classList.remove('zooming');
|
||||
}, 200);
|
||||
}
|
||||
isZoomed = true;
|
||||
updateNavigationState();
|
||||
}
|
||||
|
||||
function createImageElement(imageData) {
|
||||
if (!imageData) return null;
|
||||
const img = new Image();
|
||||
img.src = imageData.filename;
|
||||
img.width = imageData.width;
|
||||
img.height = imageData.height;
|
||||
img.addEventListener('dragstart', (e) => e.preventDefault());
|
||||
return img;
|
||||
}
|
||||
|
||||
function loadSlides() {
|
||||
slides.prev.innerHTML = '';
|
||||
slides.current.innerHTML = '';
|
||||
slides.next.innerHTML = '';
|
||||
|
||||
if (currentIndex > 0) {
|
||||
const prevImg = createImageElement(images[currentIndex - 1]);
|
||||
if (prevImg) slides.prev.appendChild(prevImg);
|
||||
}
|
||||
|
||||
const currentImg = createImageElement(images[currentIndex]);
|
||||
if (currentImg) {
|
||||
img = currentImg;
|
||||
slides.current.appendChild(currentImg);
|
||||
}
|
||||
|
||||
if (currentIndex < images.length - 1) {
|
||||
const nextImg = createImageElement(images[currentIndex + 1]);
|
||||
if (nextImg) slides.next.appendChild(nextImg);
|
||||
}
|
||||
|
||||
updateCounter(currentIndex)
|
||||
updateNavigationState();
|
||||
}
|
||||
|
||||
function updateNavigationState() {
|
||||
prevArrow.style.visibility = (currentIndex === 0 || isZoomed) ? 'hidden' : 'visible';
|
||||
nextArrow.style.visibility = (currentIndex === images.length - 1 || isZoomed) ? 'hidden' : 'visible';
|
||||
}
|
||||
|
||||
async function showPreviousImage() {
|
||||
if (currentIndex > 0 && !isZoomed) {
|
||||
currentIndex--;
|
||||
container.style.transition = 'transform 0.3s ease-out';
|
||||
container.style.transform = 'translateX(0%)';
|
||||
await waitForTransition();
|
||||
container.style.transition = 'none';
|
||||
container.style.transform = 'translateX(-33.333%)';
|
||||
loadSlides();
|
||||
}
|
||||
}
|
||||
|
||||
async function showNextImage() {
|
||||
if (currentIndex < images.length - 1 && !isZoomed) {
|
||||
currentIndex++;
|
||||
container.style.transition = 'transform 0.3s ease-out';
|
||||
container.style.transform = 'translateX(-66.666%)';
|
||||
await waitForTransition();
|
||||
container.style.transition = 'none';
|
||||
container.style.transform = 'translateX(-33.333%)';
|
||||
loadSlides();
|
||||
}
|
||||
}
|
||||
|
||||
function handleTouchStart(e) {
|
||||
if (isZoomed) return;
|
||||
startX = e.touches[0].clientX;
|
||||
isDragging = true;
|
||||
container.style.transition = 'none';
|
||||
}
|
||||
|
||||
function handleTouchMove(e) {
|
||||
if (!isDragging || isZoomed) return;
|
||||
|
||||
const currentX = e.touches[0].clientX;
|
||||
const diff = currentX - startX;
|
||||
const baseOffset = -33.333;
|
||||
const percentMoved = (diff / window.innerWidth) * 33.333;
|
||||
|
||||
container.style.transform = `translateX(${baseOffset + percentMoved}%)`;
|
||||
}
|
||||
|
||||
async function handleTouchEnd(e) {
|
||||
if (!isDragging)
|
||||
if(isZoomed) {
|
||||
handleZoom(e);
|
||||
return;
|
||||
}
|
||||
isDragging = false;
|
||||
|
||||
const endX = e.changedTouches[0].clientX;
|
||||
const diff = endX - startX;
|
||||
const threshold = window.innerWidth * 0.2;
|
||||
|
||||
container.style.transition = 'transform 0.3s ease-out';
|
||||
|
||||
if (diff > threshold && currentIndex > 0) {
|
||||
await showPreviousImage();
|
||||
} else if (diff < -threshold && currentIndex < images.length - 1) {
|
||||
await showNextImage();
|
||||
} else {
|
||||
container.style.transform = 'translateX(-33.333%)';
|
||||
}
|
||||
}
|
||||
|
||||
function handleKeyDown(e) {
|
||||
if (isZoomed) return;
|
||||
|
||||
if (e.code === 'Space' || e.code === 'ArrowRight') {
|
||||
e.preventDefault();
|
||||
showNextImage();
|
||||
} else if (e.code === 'Backspace' || e.code === 'ArrowLeft') {
|
||||
e.preventDefault();
|
||||
showPreviousImage();
|
||||
}
|
||||
}
|
||||
|
||||
function waitForTransition() {
|
||||
return new Promise(resolve => {
|
||||
container.addEventListener('transitionend', resolve, { once: true });
|
||||
});
|
||||
}
|
||||
|
||||
// Initialize
|
||||
loadSlides();
|
||||
|
||||
// Navigation event listeners
|
||||
container.addEventListener('touchstart', handleTouchStart);
|
||||
container.addEventListener('touchmove', handleTouchMove);
|
||||
container.addEventListener('touchend', handleTouchEnd);
|
||||
container.addEventListener('click', handleZoom);
|
||||
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
prevArrow.addEventListener('click', showPreviousImage);
|
||||
nextArrow.addEventListener('click', showNextImage);
|
||||
|
||||
// Mouse panning event listeners
|
||||
container.addEventListener('mousedown', function(e) {
|
||||
if (isZoomed && e.target.tagName === 'IMG') {
|
||||
isPanning = true;
|
||||
hasPanned = false;
|
||||
updateBoundaries();
|
||||
startX = e.clientX - translateX;
|
||||
startY = e.clientY - translateY;
|
||||
e.preventDefault();
|
||||
container.style.cursor = 'grabbing';
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('mousemove', function(e) {
|
||||
if (isPanning && isZoomed) {
|
||||
const proposedX = e.clientX - startX;
|
||||
const proposedY = e.clientY - startY;
|
||||
|
||||
const limited = limitPanning(proposedX, proposedY);
|
||||
translateX = limited.x;
|
||||
translateY = limited.y;
|
||||
|
||||
const img = slides.current.querySelector('img');
|
||||
img.style.transform = `translate(${translateX}px, ${translateY}px) scale(${currentScale})`;
|
||||
hasPanned = true;
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('mouseup', function() {
|
||||
if (isPanning) {
|
||||
isPanning = false;
|
||||
container.style.cursor = isZoomed ? 'zoom-out' : 'zoom-in';
|
||||
}
|
||||
});
|
||||
|
||||
// Touch panning event listeners
|
||||
container.addEventListener('touchstart', function(e) {
|
||||
if (isZoomed) {
|
||||
isPanning = true;
|
||||
hasPanned = false;
|
||||
updateBoundaries();
|
||||
const touch = e.touches[0];
|
||||
startX = touch.clientX - translateX;
|
||||
startY = touch.clientY - translateY;
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
container.addEventListener('touchmove', function(e) {
|
||||
if (isPanning && isZoomed) {
|
||||
const touch = e.touches[0];
|
||||
const proposedX = touch.clientX - startX;
|
||||
const proposedY = touch.clientY - startY;
|
||||
|
||||
const limited = limitPanning(proposedX, proposedY);
|
||||
translateX = limited.x;
|
||||
translateY = limited.y;
|
||||
|
||||
const img = slides.current.querySelector('img');
|
||||
img.style.transform = `translate(${translateX}px, ${translateY}px) scale(${currentScale})`;
|
||||
hasPanned = true;
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
container.addEventListener('touchend', function(e) {
|
||||
if (isPanning) {
|
||||
isPanning = false;
|
||||
}
|
||||
});
|
||||
323
examples/ai_denoise.lua
Normal file
323
examples/ai_denoise.lua
Normal file
@@ -0,0 +1,323 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
copyright (c) 2026 darktable developers.
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
ai_denoise - example script demonstrating the darktable.ai Lua
|
||||
API by denoising the selected images with tile-based inference.
|
||||
|
||||
Adds an "AI denoise" panel to the lighttable right column with a
|
||||
"denoise selected" button. Each selected image is loaded through
|
||||
the develop pipeline (so denoise sees the output of all enabled
|
||||
IOPs, not the original raw), run tile-by-tile through the active
|
||||
denoise model, and saved as a 16-bit TIFF grouped with the source.
|
||||
|
||||
Demonstrates:
|
||||
* model lookup via dt.ai.model_for_task
|
||||
* tensor crop/paste for tile-based inference
|
||||
* linear <-> sRGB conversion (NR models train on gamma input)
|
||||
* edge-replicated padding to suppress border artifacts
|
||||
* background job with progress bar and cancellation
|
||||
|
||||
LIMITATIONS
|
||||
* Image must be at least TILE_SIZE x TILE_SIZE (768 x 768 for
|
||||
denoise-nind / denoise-nafnet); smaller inputs return an error.
|
||||
* If a save fails mid-batch the Lua error propagates and aborts
|
||||
the whole job. Wrap denoise_one in pcall if you need
|
||||
batch-robust behaviour.
|
||||
|
||||
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
|
||||
* a denoise model enabled in preferences -> AI (denoise-nind,
|
||||
denoise-nafnet, ...)
|
||||
|
||||
USAGE
|
||||
* require this script from your luarc
|
||||
* select one or more images in lighttable
|
||||
* click the "denoise selected" button in the AI denoise panel
|
||||
|
||||
BUGS, COMMENTS, SUGGESTIONS
|
||||
* file an issue on https://github.com/darktable-org/darktable
|
||||
|
||||
CHANGES
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- C O N S T A N T S
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
local MODULE_NAME = "ai_denoise"
|
||||
|
||||
-- darktable's NR models use static-shape ONNX: each model has a fixed
|
||||
-- input dimension baked in at training time. The Lua API doesn't
|
||||
-- expose this, so keep TILE_SIZE in sync with the model's
|
||||
-- `attributes.input_sizes` in its config.json.
|
||||
local TILE_SIZE = 768 -- denoise-nind, denoise-nafnet
|
||||
|
||||
-- overlap between adjacent tiles. larger values produce smoother
|
||||
-- seams at the cost of more compute per pixel
|
||||
local OVERLAP = 64
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- F U N C T I O N S
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
-- Surround the input with `pad` pixels on every side, replicating the
|
||||
-- outermost rows/columns ("edge clamp" padding). Boundary tiles then
|
||||
-- see plausible context instead of a literal image edge, so the
|
||||
-- network's internal zero-padding no longer leaks into the visible
|
||||
-- output as colour artifacts along the image rim.
|
||||
local function pad_replicate(input, pad)
|
||||
local C = input:shape()[2]
|
||||
local H = input:shape()[3]
|
||||
local W = input:shape()[4]
|
||||
local padded = dt.ai.create_tensor({1, C, H + 2 * pad, W + 2 * pad})
|
||||
|
||||
-- center: original image
|
||||
padded:paste(input, pad, pad)
|
||||
|
||||
-- left and right strips: replicate first / last column of input
|
||||
local left_col = input:crop(0, 0, H, 1)
|
||||
local right_col = input:crop(0, W - 1, H, 1)
|
||||
for i = 0, pad - 1 do
|
||||
padded:paste(left_col, pad, i)
|
||||
padded:paste(right_col, pad, pad + W + i)
|
||||
end
|
||||
|
||||
-- top and bottom strips: replicate first / last row of the already
|
||||
-- horizontally-padded buffer so the four corners get filled correctly
|
||||
local top_row = padded:crop(pad, 0, 1, W + 2 * pad)
|
||||
local bottom_row = padded:crop(pad + H - 1, 0, 1, W + 2 * pad)
|
||||
for i = 0, pad - 1 do
|
||||
padded:paste(top_row, i, 0)
|
||||
padded:paste(bottom_row, pad + H + i, 0)
|
||||
end
|
||||
|
||||
return padded
|
||||
end
|
||||
|
||||
-- Tile a [1,C,H,W] tensor through the model with overlap-blended seams.
|
||||
-- Each tile is tile_size x tile_size, successive tiles step by
|
||||
-- (tile_size - 2*overlap), and only the central (non-overlap) region
|
||||
-- of each tile is pasted into the output. Image-boundary edges keep
|
||||
-- their full extent; only image-interior seams drop the overlap margin.
|
||||
--
|
||||
-- The trailing tile in each axis is pinned to the image boundary so
|
||||
-- the residual right/bottom strip is never smaller than 2*overlap --
|
||||
-- otherwise it would have to be skipped (the model has a fixed input
|
||||
-- size) and those pixels would never be written.
|
||||
local function run_tiled(ctx, input, tile_size, overlap,
|
||||
job, base_pct, span_pct)
|
||||
local C = input:shape()[2]
|
||||
local H = input:shape()[3]
|
||||
local W = input:shape()[4]
|
||||
if H < tile_size or W < tile_size then
|
||||
return nil, string.format("image too small (%dx%d) for tile %d",
|
||||
W, H, tile_size)
|
||||
end
|
||||
|
||||
local step = tile_size - 2 * overlap
|
||||
|
||||
-- enumerate tile origins along one axis, ending exactly at the boundary
|
||||
local function origins(extent)
|
||||
local out, p = {}, 0
|
||||
while p + tile_size < extent do
|
||||
out[#out + 1] = p
|
||||
p = p + step
|
||||
end
|
||||
out[#out + 1] = math.max(0, extent - tile_size)
|
||||
return out
|
||||
end
|
||||
local ys, xs = origins(H), origins(W)
|
||||
local total = #xs * #ys
|
||||
|
||||
local output = dt.ai.create_tensor({1, C, H, W})
|
||||
local done = 0
|
||||
|
||||
for _, ty in ipairs(ys) do
|
||||
for _, tx in ipairs(xs) do
|
||||
if job and not job.valid then return nil, "cancelled" end
|
||||
|
||||
local tile_in = input:crop(ty, tx, tile_size, tile_size)
|
||||
local tile_out = ctx:run(tile_in)
|
||||
|
||||
-- central region to keep: drop overlap on every inner edge;
|
||||
-- full extent at image-boundary edges
|
||||
local at_top = (ty == 0)
|
||||
local at_left = (tx == 0)
|
||||
local at_bottom = (ty + tile_size >= H)
|
||||
local at_right = (tx + tile_size >= W)
|
||||
|
||||
local cy = at_top and 0 or overlap
|
||||
local cx = at_left and 0 or overlap
|
||||
local ch = tile_size - cy - (at_bottom and 0 or overlap)
|
||||
local cw = tile_size - cx - (at_right and 0 or overlap)
|
||||
|
||||
output:paste(tile_out:crop(cy, cx, ch, cw), ty + cy, tx + cx)
|
||||
|
||||
done = done + 1
|
||||
if job then
|
||||
job.percent = base_pct + span_pct * (done / total)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return output
|
||||
end
|
||||
|
||||
-- Denoise one image: load through the develop pipeline, run tiled
|
||||
-- inference, save as 16-bit TIFF, group with the source.
|
||||
local function denoise_one(ctx, img, tile_size, job, base_pct, span_pct)
|
||||
-- darktable returns the develop-pipeline output as scene-linear RGB;
|
||||
-- the NR models were trained on sRGB-gamma input, so we re-encode
|
||||
-- before inference and decode back to linear before saving
|
||||
local input = dt.ai.load_image(img)
|
||||
if not input then return false, "load_image failed" end
|
||||
input:linear_to_srgb()
|
||||
|
||||
-- pad so the image's outer rim is no longer at a tile boundary;
|
||||
-- the padded strip absorbs the network's edge artifacts and gets
|
||||
-- cropped away after inference
|
||||
local H = input:shape()[3]
|
||||
local W = input:shape()[4]
|
||||
local padded_in = pad_replicate(input, OVERLAP)
|
||||
|
||||
local padded_out, err = run_tiled(ctx, padded_in, tile_size, OVERLAP,
|
||||
job, base_pct, span_pct)
|
||||
if not padded_out then return false, err end
|
||||
|
||||
local output = padded_out:crop(OVERLAP, OVERLAP, H, W)
|
||||
output:srgb_to_linear()
|
||||
|
||||
local base = img.filename:match("(.+)%..+$") or img.filename
|
||||
local out_path = img.path .. "/" .. base .. "_denoised.tif"
|
||||
output:save_tiff(out_path, 16, img)
|
||||
|
||||
-- import the result and group with the source so they live together
|
||||
-- in the lighttable
|
||||
local imported = dt.database.import(out_path)
|
||||
if imported then imported:group_with(img) end
|
||||
return true
|
||||
end
|
||||
|
||||
-- Button handler: looks up the active denoise model, fans out the
|
||||
-- selected images, and reports progress via a cancellable job.
|
||||
local function process_denoise()
|
||||
local model_id = dt.ai.model_for_task("denoise")
|
||||
if not model_id then
|
||||
dt.print("no denoise model enabled -- pick one in preferences -> AI")
|
||||
return
|
||||
end
|
||||
|
||||
local images = dt.gui.selection()
|
||||
if #images == 0 then
|
||||
dt.print("select at least one image")
|
||||
return
|
||||
end
|
||||
|
||||
-- progress + cancel job. the cancel callback flips job.valid; the
|
||||
-- main loop polls it between tiles to stop cleanly
|
||||
local job = dt.gui.create_job(
|
||||
string.format("AI denoise (%d image%s)",
|
||||
#images, #images == 1 and "" or "s"),
|
||||
true,
|
||||
function(j) j.valid = false end)
|
||||
|
||||
dt.print_log(string.format(
|
||||
"[ai_denoise] starting: %d image%s with model %s",
|
||||
#images, #images == 1 and "" or "s", model_id))
|
||||
local t_start = os.time()
|
||||
|
||||
local ctx = dt.ai.load_model(model_id)
|
||||
if not ctx then
|
||||
dt.print("failed to load model: " .. model_id)
|
||||
job.valid = false
|
||||
return
|
||||
end
|
||||
|
||||
local span = 1.0 / #images
|
||||
local done = 0
|
||||
for i, img in ipairs(images) do
|
||||
if not job.valid then break end
|
||||
dt.print_log(string.format("[ai_denoise] [%d/%d] %s",
|
||||
i, #images, img.filename))
|
||||
local ok, err = denoise_one(ctx, img, TILE_SIZE, job,
|
||||
(i - 1) * span, span)
|
||||
if not ok then
|
||||
dt.print(string.format("[%d/%d] %s: %s",
|
||||
i, #images, img.filename, tostring(err)))
|
||||
dt.print_log(string.format("[ai_denoise] [%d/%d] %s FAILED: %s",
|
||||
i, #images, img.filename, tostring(err)))
|
||||
else
|
||||
done = done + 1
|
||||
end
|
||||
end
|
||||
|
||||
ctx:close()
|
||||
job.valid = false
|
||||
local elapsed = os.time() - t_start
|
||||
dt.print(string.format("denoise complete: %d image%s",
|
||||
#images, #images == 1 and "" or "s"))
|
||||
dt.print_log(string.format(
|
||||
"[ai_denoise] finished: %d/%d in %ds",
|
||||
done, #images, elapsed))
|
||||
end
|
||||
|
||||
-- script_manager integration: called when the user disables the script.
|
||||
-- darktable can't remove a registered lib from the UI at runtime, so we
|
||||
-- only stop any in-flight work; the panel itself remains until restart.
|
||||
local function destroy()
|
||||
-- nothing persistent to clean up: each click runs its own job and
|
||||
-- closes its own model context
|
||||
end
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- M A I N
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
dt.register_lib(
|
||||
MODULE_NAME, -- plugin id
|
||||
"AI denoise", -- displayed name
|
||||
true, -- expandable
|
||||
false, -- no reset button
|
||||
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}},
|
||||
dt.new_widget("box") {
|
||||
orientation = "vertical",
|
||||
dt.new_widget("button") {
|
||||
label = "denoise selected",
|
||||
clicked_callback = process_denoise,
|
||||
}
|
||||
},
|
||||
nil, nil
|
||||
)
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- 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 = "AI denoise",
|
||||
purpose = "tile-based AI denoise using the darktable.ai Lua API",
|
||||
author = "Andrii Ryzhkov",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/ai_denoise"
|
||||
}
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
481
examples/ai_raw_denoise.lua
Normal file
481
examples/ai_raw_denoise.lua
Normal file
@@ -0,0 +1,481 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
copyright (c) 2026 darktable developers.
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
ai_raw_denoise - example script demonstrating the darktable.ai Lua
|
||||
API by denoising the selected raw images with tile-based inference
|
||||
on the raw CFA.
|
||||
|
||||
Adds an "AI raw denoise" panel to the lighttable right column with
|
||||
a "denoise selected" button. Each selected image's raw CFA is
|
||||
loaded, Bayer-packed to 4 channels, run tile-by-tile through the
|
||||
currently enabled rawdenoise model (which denoises AND demosaicks
|
||||
in one pass), and saved as a LinearRaw DNG grouped with the
|
||||
source image.
|
||||
|
||||
Demonstrates:
|
||||
* model lookup via dt.ai.model_for_task
|
||||
* loading model variant files via dt.ai.load_model file arg
|
||||
* raw CFA loading via dt.ai.load_raw
|
||||
* tensor bayer_pack for 4-channel CFA tiling
|
||||
* tile loop with non-trivial input->output scale (here 1 -> 2)
|
||||
* edge-replicated padding to suppress border artifacts
|
||||
* LinearRaw DNG output via dt.ai.save_dng_linear
|
||||
* background job with progress bar and cancellation
|
||||
|
||||
LIMITATIONS
|
||||
* Bayer sensors only. The script loads model_bayer.onnx and uses
|
||||
bayer_pack, which assumes a 2x2 Bayer layout. X-Trans and
|
||||
Foveon sensors need model_linear.onnx with a different
|
||||
preprocessing pipeline (no bayer_pack, demosaicked input).
|
||||
* Image must be at least TILE_SIZE x TILE_SIZE in packed pixels
|
||||
(1024 x 1024 of CFA for the default 512 packed tile size).
|
||||
* If a save fails mid-batch the Lua error propagates and aborts
|
||||
the whole job. Wrap denoise_one in pcall if you need
|
||||
batch-robust behaviour.
|
||||
|
||||
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
|
||||
* a rawdenoise model enabled in preferences -> AI
|
||||
(e.g. rawdenoise-nind)
|
||||
|
||||
USAGE
|
||||
* require this script from your luarc
|
||||
* select one or more raw images in lighttable
|
||||
* click the "denoise selected" button in the AI raw denoise panel
|
||||
|
||||
BUGS, COMMENTS, SUGGESTIONS
|
||||
* file an issue on https://github.com/darktable-org/darktable
|
||||
|
||||
CHANGES
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- C O N S T A N T S
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
local MODULE_NAME = "ai_raw_denoise"
|
||||
|
||||
-- The rawdenoise-nind bayer model is a denoise+demosaic combo:
|
||||
-- input : [1, 4, 512, 512] packed CFA (4 phase planes)
|
||||
-- output : [1, 3, 1024, 1024] linear RGB at 2x the input resolution
|
||||
-- So each tile-size pixel of the input covers a 2x2 CFA block, and the
|
||||
-- model emits two output pixels per input pixel in each axis.
|
||||
-- TILE_SIZE is in packed pixels (model input); SCALE turns those into
|
||||
-- output pixels. Keep in sync with `attributes.input_sizes` in the
|
||||
-- model's config.json.
|
||||
local TILE_SIZE = 512 -- rawdenoise-nind
|
||||
local SCALE = 2 -- model output dim / input dim
|
||||
local OUT_CH = 3 -- model emits linear RGB
|
||||
|
||||
-- overlap between adjacent tiles, in packed pixels (input space).
|
||||
-- larger values produce smoother seams at the cost of more compute
|
||||
local OVERLAP = 32
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- F U N C T I O N S
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
-- Bayer-only CFA channel lookup. Returns 0/1/2 (R/G/B) for the cell
|
||||
-- at sensor position (r, c) given the 32-bit `filters` mask from
|
||||
-- load_raw's meta table. Used to find the R-cell origin so bayer_pack's
|
||||
-- plane 0 always holds R. X-Trans (filters == 9) uses meta.xtrans
|
||||
-- instead and is not handled here.
|
||||
local function fc(r, c, filters)
|
||||
local shift = ((r % 2) * 4) + ((c % 2) * 2)
|
||||
return math.floor(filters / (2 ^ shift)) % 4
|
||||
end
|
||||
|
||||
-- daylight WB multipliers (R, G=1, B) derived from the camera's
|
||||
-- XYZ->camRGB color matrix and the D65 white point. mirrors the C
|
||||
-- path's _bayer_wb_daylight in restore_raw_bayer.c — the rawdenoise
|
||||
-- bayer model is trained on daylight-WB'd input, so feeding it
|
||||
-- un-WB'd camRGB produces wrong colors. Falls back to {1, 1, 1} if
|
||||
-- the matrix is missing or degenerate.
|
||||
local function daylight_wb(color_matrix)
|
||||
local d65 = {0.95047, 1.0, 1.08883}
|
||||
if not color_matrix then return 1.0, 1.0, 1.0 end
|
||||
local resp = {0, 0, 0}
|
||||
for c = 1, 3 do
|
||||
resp[c] = color_matrix[c][1] * d65[1]
|
||||
+ color_matrix[c][2] * d65[2]
|
||||
+ color_matrix[c][3] * d65[3]
|
||||
end
|
||||
if resp[1] <= 0 or resp[2] <= 0 or resp[3] <= 0 then
|
||||
return 1.0, 1.0, 1.0
|
||||
end
|
||||
return resp[2] / resp[1], 1.0, resp[2] / resp[3]
|
||||
end
|
||||
|
||||
-- Surround the input with `pad` pixels on every side, replicating the
|
||||
-- outermost rows/columns ("edge clamp" padding). Boundary tiles then
|
||||
-- see plausible context instead of a literal image edge, so the
|
||||
-- network's internal zero-padding no longer leaks into the visible
|
||||
-- output as colour artifacts along the image rim.
|
||||
local function pad_replicate(input, pad)
|
||||
local C = input:shape()[2]
|
||||
local H = input:shape()[3]
|
||||
local W = input:shape()[4]
|
||||
local padded = dt.ai.create_tensor({1, C, H + 2 * pad, W + 2 * pad})
|
||||
|
||||
-- center: original image
|
||||
padded:paste(input, pad, pad)
|
||||
|
||||
-- left and right strips: replicate first / last column of input
|
||||
local left_col = input:crop(0, 0, H, 1)
|
||||
local right_col = input:crop(0, W - 1, H, 1)
|
||||
for i = 0, pad - 1 do
|
||||
padded:paste(left_col, pad, i)
|
||||
padded:paste(right_col, pad, pad + W + i)
|
||||
end
|
||||
|
||||
-- top and bottom strips: replicate first / last row of the already
|
||||
-- horizontally-padded buffer so the four corners get filled correctly
|
||||
local top_row = padded:crop(pad, 0, 1, W + 2 * pad)
|
||||
local bottom_row = padded:crop(pad + H - 1, 0, 1, W + 2 * pad)
|
||||
for i = 0, pad - 1 do
|
||||
padded:paste(top_row, i, 0)
|
||||
padded:paste(bottom_row, pad + H + i, 0)
|
||||
end
|
||||
|
||||
return padded
|
||||
end
|
||||
|
||||
-- Tile a [1,C_in,H,W] tensor through a model that emits [1,C_out,H*scale,
|
||||
-- W*scale]. Each tile is tile_size x tile_size in input space; successive
|
||||
-- tiles step by (tile_size - 2*overlap); only the central (non-overlap)
|
||||
-- region of each tile's output is pasted into the result, with all
|
||||
-- offsets multiplied by `scale`. Image-boundary edges keep their full
|
||||
-- extent; only image-interior seams drop the overlap margin.
|
||||
--
|
||||
-- The trailing tile in each axis is pinned to the image boundary so
|
||||
-- the residual right/bottom strip is never smaller than 2*overlap --
|
||||
-- otherwise it would have to be skipped (the model has a fixed input
|
||||
-- size) and those pixels would never be written.
|
||||
local function run_tiled(ctx, input, tile_size, overlap, scale, c_out,
|
||||
job, base_pct, span_pct)
|
||||
local H = input:shape()[3]
|
||||
local W = input:shape()[4]
|
||||
if H < tile_size or W < tile_size then
|
||||
return nil, string.format("image too small (%dx%d) for tile %d",
|
||||
W, H, tile_size)
|
||||
end
|
||||
|
||||
local step = tile_size - 2 * overlap
|
||||
|
||||
-- enumerate tile origins along one axis, ending exactly at the boundary
|
||||
local function origins(extent)
|
||||
local out, p = {}, 0
|
||||
while p + tile_size < extent do
|
||||
out[#out + 1] = p
|
||||
p = p + step
|
||||
end
|
||||
out[#out + 1] = math.max(0, extent - tile_size)
|
||||
return out
|
||||
end
|
||||
local ys, xs = origins(H), origins(W)
|
||||
local total = #xs * #ys
|
||||
|
||||
-- output is scale-times larger spatially and may have a different
|
||||
-- channel count than the input
|
||||
local output = dt.ai.create_tensor({1, c_out, H * scale, W * scale})
|
||||
local done = 0
|
||||
|
||||
for _, ty in ipairs(ys) do
|
||||
for _, tx in ipairs(xs) do
|
||||
if job and not job.valid then return nil, "cancelled" end
|
||||
|
||||
local tile_in = input:crop(ty, tx, tile_size, tile_size)
|
||||
local tile_out = ctx:run(tile_in)
|
||||
|
||||
-- central region to keep: drop overlap on every inner edge;
|
||||
-- full extent at image-boundary edges. all dimensions in OUTPUT
|
||||
-- (post-scale) space, since that's where we paste
|
||||
local at_top = (ty == 0)
|
||||
local at_left = (tx == 0)
|
||||
local at_bottom = (ty + tile_size >= H)
|
||||
local at_right = (tx + tile_size >= W)
|
||||
|
||||
local ov = overlap * scale
|
||||
local tos = tile_size * scale
|
||||
local cy = at_top and 0 or ov
|
||||
local cx = at_left and 0 or ov
|
||||
local ch = tos - cy - (at_bottom and 0 or ov)
|
||||
local cw = tos - cx - (at_right and 0 or ov)
|
||||
|
||||
output:paste(tile_out:crop(cy, cx, ch, cw),
|
||||
ty * scale + cy, tx * scale + cx)
|
||||
|
||||
done = done + 1
|
||||
if job then
|
||||
job.percent = base_pct + span_pct * (done / total)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return output
|
||||
end
|
||||
|
||||
-- Denoise one raw image. The bayer rawdenoise model denoises AND
|
||||
-- demosaicks in one pass, so its output is linear RGB at the
|
||||
-- original CFA resolution (not a CFA mosaic). Saved as a LinearRaw
|
||||
-- DNG, which darktable can re-import as an already-debayered raw.
|
||||
--
|
||||
-- Pipeline:
|
||||
-- load CFA [1,1,H,W] + image metadata
|
||||
-- -> bayer_pack [1,4,H/2,W/2]
|
||||
-- -> normalize to [0, 1] using black/white levels (the model is
|
||||
-- trained on (val - black) / (white - black), not raw ADC)
|
||||
-- -> pad to [1,4,H/2+2P,W/2+2P]
|
||||
-- -> tile through model (scale=2, c_out=3) -> [1,3,(H+4P),(W+4P)]
|
||||
-- -> crop padding back off -> [1,3,H,W]
|
||||
-- -> save linear DNG -> import + group with source
|
||||
local function denoise_one(ctx, img, tile_size, job, base_pct, span_pct)
|
||||
-- load_raw returns (tensor, meta). tensor is [1,1,H,W] in raw ADC
|
||||
-- units; meta carries black/white/wb/CFA info we need to normalise
|
||||
-- the input into the [0, 1] range the model was trained on
|
||||
local cfa, meta = dt.ai.load_raw(img)
|
||||
if not cfa then return false, "load_raw failed" end
|
||||
|
||||
-- this script is Bayer-only: filters == 9 is X-Trans (handled by a
|
||||
-- different preprocessing pipeline + model_linear.onnx); filters == 0
|
||||
-- means monochrome / non-CFA, which bayer_pack can't handle either
|
||||
if not meta.filters or meta.filters == 0 or meta.filters == 9 then
|
||||
return false, "unsupported CFA pattern (Bayer-only script)"
|
||||
end
|
||||
|
||||
-- Crop to the visible region and shift the origin onto the R cell
|
||||
-- of the CFA pattern. bayer_pack splits by position only, so to make
|
||||
-- plane 0 always hold R (which the model expects) the cropped CFA's
|
||||
-- (0, 0) must sit at an R site. Mirrors the C path's _bayer_origin
|
||||
-- + RGGB shift in restore_raw_bayer.c.
|
||||
local cy = 0
|
||||
local cx = 0
|
||||
local cw = cfa:shape()[4]
|
||||
local ch = cfa:shape()[3]
|
||||
if meta.crop_x and meta.crop_y then
|
||||
cy = meta.crop_y - (meta.crop_y % 2)
|
||||
cx = meta.crop_x - (meta.crop_x % 2)
|
||||
cw = (meta.visible_width or cw) + (meta.crop_x - cx)
|
||||
ch = (meta.visible_height or ch) + (meta.crop_y - cy)
|
||||
end
|
||||
-- find R cell within the 2x2 starting at (cy, cx)
|
||||
local sy, sx = 0, 0
|
||||
for ty = 0, 1 do
|
||||
for tx = 0, 1 do
|
||||
if fc(cy + ty, cx + tx, meta.filters) == 0 then
|
||||
sy, sx = ty, tx
|
||||
end
|
||||
end
|
||||
end
|
||||
cy = cy + sy
|
||||
cx = cx + sx
|
||||
ch = ch - sy
|
||||
cw = cw - sx
|
||||
-- ensure even dims for bayer_pack
|
||||
ch = ch - (ch % 2)
|
||||
cw = cw - (cw % 2)
|
||||
if cy > 0 or cx > 0
|
||||
or cw < cfa:shape()[4] or ch < cfa:shape()[3]
|
||||
then
|
||||
cfa = cfa:crop(cy, cx, ch, cw)
|
||||
end
|
||||
|
||||
-- uniform-black approximation: most sensors report identical black
|
||||
-- levels across the 4 CFA sites, in which case a single scalar
|
||||
-- (val - black) / (white - black) normalisation is exact. cameras
|
||||
-- with non-uniform per-site black levels (e.g. some PDAF sensors)
|
||||
-- would need per-plane scaling via scale_add_planes -- left as an
|
||||
-- exercise
|
||||
local black = meta.black_level
|
||||
local range = meta.white_level - black
|
||||
if range <= 0 then range = 65535 end
|
||||
|
||||
-- pack the 1-channel CFA into 4 phase planes so each channel holds
|
||||
-- one Bayer site type. After the RGGB shift above:
|
||||
-- plane 0 = R, planes 1,2 = G, plane 3 = B
|
||||
local packed = cfa:bayer_pack()
|
||||
packed:scale_add(1.0 / range, -black / range)
|
||||
|
||||
-- apply daylight WB so the four planes sit in the same range the
|
||||
-- model was trained on (R, G, G, B → R*wb_R, G, G, B*wb_B). without
|
||||
-- this, the model sees unbalanced channels and produces wrong colors
|
||||
local wb_R, wb_G, wb_B = daylight_wb(meta.color_matrix)
|
||||
packed:scale_add_planes({wb_R, wb_G, wb_G, wb_B})
|
||||
local pH = packed:shape()[3]
|
||||
local pW = packed:shape()[4]
|
||||
|
||||
-- save the post-normalisation input mean for gain-matching the
|
||||
-- model output: the bayer rawdenoise model emits values on its own
|
||||
-- internal scale, not [0, 1], so we rescale so output mean matches
|
||||
-- input mean (the per-tile equivalent of dt's C reference path)
|
||||
local in_mean = packed:mean()
|
||||
|
||||
-- pad so the image rim is no longer at a tile boundary; the padded
|
||||
-- strip absorbs the network's edge artifacts and is cropped away
|
||||
-- after inference (in output space, where the pad covers 2*OVERLAP
|
||||
-- pixels per side)
|
||||
local padded_in = pad_replicate(packed, OVERLAP)
|
||||
|
||||
local padded_out, err = run_tiled(ctx, padded_in, tile_size, OVERLAP,
|
||||
SCALE, OUT_CH,
|
||||
job, base_pct, span_pct)
|
||||
if not padded_out then return false, err end
|
||||
|
||||
-- crop the padded region (in output coords: pad * scale per side)
|
||||
-- back to the original-CFA resolution
|
||||
local out_rgb = padded_out:crop(OVERLAP * SCALE, OVERLAP * SCALE,
|
||||
pH * SCALE, pW * SCALE)
|
||||
|
||||
-- gain-match: rescale the output so its mean matches the input
|
||||
-- mean, bringing the model's internal-scale output back into the
|
||||
-- [0, 1] range save_dng_linear expects
|
||||
local out_mean = out_rgb:mean()
|
||||
if out_mean > 1e-8 then
|
||||
out_rgb:scale_add(in_mean / out_mean)
|
||||
end
|
||||
|
||||
-- invert the daylight WB so the saved tensor is un-WB'd camRGB
|
||||
-- (save_dng_linear's contract — the consumer applies AsShotNeutral
|
||||
-- on import)
|
||||
out_rgb:scale_add_planes({1.0 / wb_R, 1.0 / wb_G, 1.0 / wb_B})
|
||||
|
||||
local base = img.filename:match("(.+)%..+$") or img.filename
|
||||
local out_path = img.path .. "/" .. base .. "_rawdenoised.dng"
|
||||
-- LinearRaw DNG: tensor values must be normalised to [0, 1] camRGB;
|
||||
-- the model handles black-subtract + scale internally, so we just
|
||||
-- pass the output through
|
||||
dt.ai.save_dng_linear(out_rgb, img, out_path)
|
||||
|
||||
-- import the result and group with the source so they live together
|
||||
-- in the lighttable
|
||||
local imported = dt.database.import(out_path)
|
||||
if imported then imported:group_with(img) end
|
||||
return true
|
||||
end
|
||||
|
||||
-- Button handler: looks up the active rawdenoise model, fans out the
|
||||
-- selected images, and reports progress via a cancellable job.
|
||||
local function process_raw_denoise()
|
||||
local model_id = dt.ai.model_for_task("rawdenoise")
|
||||
if not model_id then
|
||||
dt.print("no rawdenoise model enabled -- pick one in preferences -> AI")
|
||||
return
|
||||
end
|
||||
|
||||
local images = dt.gui.selection()
|
||||
if #images == 0 then
|
||||
dt.print("select at least one image")
|
||||
return
|
||||
end
|
||||
|
||||
-- progress + cancel job. the cancel callback flips job.valid; the
|
||||
-- main loop polls it between tiles to stop cleanly
|
||||
local job = dt.gui.create_job(
|
||||
string.format("AI raw denoise (%d image%s)",
|
||||
#images, #images == 1 and "" or "s"),
|
||||
true,
|
||||
function(j) j.valid = false end)
|
||||
|
||||
dt.print_log(string.format(
|
||||
"[ai_raw_denoise] starting: %d image%s with model %s",
|
||||
#images, #images == 1 and "" or "s", model_id))
|
||||
local t_start = os.time()
|
||||
|
||||
-- rawdenoise packages ship multiple files (one per CFA type); pick
|
||||
-- the Bayer variant. X-Trans / Foveon would use model_linear.onnx
|
||||
-- with a different preprocessing pipeline (no bayer_pack)
|
||||
local ctx = dt.ai.load_model(model_id, nil, "model_bayer.onnx")
|
||||
if not ctx then
|
||||
dt.print("failed to load model: " .. model_id)
|
||||
job.valid = false
|
||||
return
|
||||
end
|
||||
|
||||
local span = 1.0 / #images
|
||||
local done = 0
|
||||
for i, img in ipairs(images) do
|
||||
if not job.valid then break end
|
||||
dt.print_log(string.format("[ai_raw_denoise] [%d/%d] %s",
|
||||
i, #images, img.filename))
|
||||
local ok, err = denoise_one(ctx, img, TILE_SIZE, job,
|
||||
(i - 1) * span, span)
|
||||
if not ok then
|
||||
dt.print(string.format("[%d/%d] %s: %s",
|
||||
i, #images, img.filename, tostring(err)))
|
||||
dt.print_log(string.format("[ai_raw_denoise] [%d/%d] %s FAILED: %s",
|
||||
i, #images, img.filename, tostring(err)))
|
||||
else
|
||||
done = done + 1
|
||||
end
|
||||
end
|
||||
|
||||
ctx:close()
|
||||
job.valid = false
|
||||
local elapsed = os.time() - t_start
|
||||
dt.print(string.format("raw denoise complete: %d image%s",
|
||||
#images, #images == 1 and "" or "s"))
|
||||
dt.print_log(string.format(
|
||||
"[ai_raw_denoise] finished: %d/%d in %ds",
|
||||
done, #images, elapsed))
|
||||
end
|
||||
|
||||
-- script_manager integration: called when the user disables the script.
|
||||
-- darktable can't remove a registered lib from the UI at runtime, so we
|
||||
-- only stop any in-flight work; the panel itself remains until restart.
|
||||
local function destroy()
|
||||
-- nothing persistent to clean up: each click runs its own job and
|
||||
-- closes its own model context
|
||||
end
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- M A I N
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
dt.register_lib(
|
||||
MODULE_NAME, -- plugin id
|
||||
"AI raw denoise", -- displayed name
|
||||
true, -- expandable
|
||||
false, -- no reset button
|
||||
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}},
|
||||
dt.new_widget("box") {
|
||||
orientation = "vertical",
|
||||
dt.new_widget("button") {
|
||||
label = "denoise selected",
|
||||
clicked_callback = process_raw_denoise,
|
||||
}
|
||||
},
|
||||
nil, nil
|
||||
)
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- 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 = "AI raw denoise",
|
||||
purpose = "tile-based AI raw denoise using the darktable.ai Lua API",
|
||||
author = "Andrii Ryzhkov",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/ai_raw_denoise"
|
||||
}
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
@@ -23,5 +23,36 @@ USAGE
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
|
||||
-- translation facilities
|
||||
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
local function _(msg)
|
||||
return gettext(msg)
|
||||
end
|
||||
|
||||
-- script_manager integration to allow a script to be removed
|
||||
-- without restarting darktable
|
||||
local function destroy()
|
||||
-- nothing to destroy
|
||||
end
|
||||
|
||||
local result = dt.configuration.api_version_string
|
||||
dt.print_error("API Version: "..result)
|
||||
dt.print_log("API Version: " .. result)
|
||||
dt.print("API " .. _("version") .. ": " .. result)
|
||||
|
||||
-- set the destroy routine so that script_manager can call it when
|
||||
-- it's time to destroy the script and then return the data to
|
||||
-- script_manager
|
||||
local script_data = {}
|
||||
|
||||
script_data.metadata = {
|
||||
name = _("APIversion"),
|
||||
purpose = _("display api_version example"),
|
||||
author = "Tobias Jakobs",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/api_version"
|
||||
}
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
128
examples/darkroom_demo.lua
Normal file
128
examples/darkroom_demo.lua
Normal file
@@ -0,0 +1,128 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
copyright (c) 2019 Bill Ferguson <wpferguson@gmail.com>
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
darkroom_demo - an example script demonstrating how to control image display in darkroom mode
|
||||
|
||||
darkroom_demo is an example script showing how to control the currently displayed image in
|
||||
darkroom mode using lua.
|
||||
|
||||
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
|
||||
* none
|
||||
|
||||
USAGE
|
||||
* require this script from your main lua file
|
||||
|
||||
BUGS, COMMENTS, SUGGESTIONS
|
||||
* Send to Bill Ferguson, wpferguson@gmail.com
|
||||
|
||||
CHANGES
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- V E R S I O N C H E C K
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
du.check_min_api_version("5.0.2", "darkroom_demo") -- darktable 3.0
|
||||
|
||||
-- script_manager integration to allow a script to be removed
|
||||
-- without restarting darktable
|
||||
local function destroy()
|
||||
-- nothing to destroy
|
||||
end
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- C O N S T A N T S
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
local MODULE_NAME = "darkroom_demo"
|
||||
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- T R A N S L A T I O N S
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
local function _(msgid)
|
||||
return gettext(msgid)
|
||||
end
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- M A I N
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
-- alias dt.control.sleep to sleep
|
||||
local sleep = dt.control.sleep
|
||||
|
||||
-- save the configuration
|
||||
|
||||
local current_view = dt.gui.current_view()
|
||||
|
||||
-- check that there is an image selected, otherwise we can't activate darkroom viewe
|
||||
|
||||
local images = dt.gui.action_images
|
||||
dt.print_log(#images .. " images selected")
|
||||
if not images or #images == 0 then
|
||||
dt.print_log("no images selected, creating selection")
|
||||
dt.print_log("using image " .. dt.collection[1].filename)
|
||||
dt.gui.selection({dt.collection[1]})
|
||||
end
|
||||
|
||||
-- enter darkroom view
|
||||
|
||||
dt.gui.current_view(dt.gui.views.darkroom)
|
||||
|
||||
local max_images = 10
|
||||
|
||||
dt.print(_("showing images, with a pause between each"))
|
||||
sleep(1500)
|
||||
|
||||
-- display first 10 images of collection pausing for a second between each
|
||||
|
||||
for i, img in ipairs(dt.collection) do
|
||||
dt.print(string.format(_("displaying image "), i))
|
||||
dt.gui.views.darkroom.display_image(img)
|
||||
sleep(1500)
|
||||
if i == max_images then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- return to lighttable view
|
||||
|
||||
dt.print(_("restoring view"))
|
||||
sleep(1500)
|
||||
dt.gui.current_view(current_view)
|
||||
|
||||
-- set the destroy routine so that script_manager can call it when
|
||||
-- it's time to destroy the script and then return the data to
|
||||
-- script_manager
|
||||
local script_data = {}
|
||||
|
||||
script_data.metadata = {
|
||||
name = _("darkroom demo"),
|
||||
purpose = _("example demonstrating how to control image display in darkroom mode"),
|
||||
author = "Bill Ferguson <wpferguson@gmail.com>",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/darkroom_demo"
|
||||
}
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
20
examples/de_DE/LC_MESSAGES/gettextExample.po
Normal file
20
examples/de_DE/LC_MESSAGES/gettextExample.po
Normal file
@@ -0,0 +1,20 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Lua gettextTest\n"
|
||||
"POT-Creation-Date: 2016-01-07 20:33+0100\n"
|
||||
"PO-Revision-Date: 2016-01-07 21:32+0100\n"
|
||||
"Last-Translator: Tobias Jakobs <tobias.jakobs@gmail.com>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: de\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.8.4\n"
|
||||
"X-Poedit-Basepath: .\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Poedit-KeywordsList: gettext;dgettext:2;dcgettext:2;ngettext:1,2;dngettext:2,3\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
|
||||
#: gettextExample.lua:36
|
||||
msgid "Hello World!"
|
||||
msgstr "Hallo Welt!"
|
||||
97
examples/gettextExample.lua
Normal file
97
examples/gettextExample.lua
Normal file
@@ -0,0 +1,97 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
Copyright 2016 by Tobias Jakobs.
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
darktable script to show how translations works
|
||||
|
||||
To create the .po file run:
|
||||
xgettext -l lua gettextExample.lua
|
||||
|
||||
xgettext is not a lua tool, it knows (almost) nothing about Lua, and not
|
||||
enough to do a proper parsing. It takes a text file (In our case a Lua
|
||||
file) and recognises a few (language dependant) keyword in there.
|
||||
It matches those keywords with internal description on how functions are
|
||||
called and creates the .po file accordingly. (For example, it knows that
|
||||
the first argument of gettext() is the translated string, but that it's
|
||||
the second argument for dgettext)
|
||||
This is important because it means that if you use some neat Lua tricks
|
||||
(like renaming functions) xgettext won't recognize those calls and won't
|
||||
extract the string to the .po file.
|
||||
So, this is why we create a local variagle gettext = dt.gettext, so
|
||||
xgettext recognises gettext.gettext as a function but not dt.gettext.gettext
|
||||
|
||||
To create a .mo file run:
|
||||
msgfmt -v gettextExample.po -o gettextExample.mo
|
||||
|
||||
USAGE
|
||||
* require this script from your main lua file (Add 'require "gettextExample"' to luarc.)
|
||||
* copy the script to: .config/darktable/lua/
|
||||
* copy the gettextExample.mo to .config/darktable/lua/de_DE/LC_MESSAGES
|
||||
|
||||
You need to start darktable with the Lua debug option: darktable -d lua
|
||||
$LANG must set to: de_DE
|
||||
|
||||
The script run on darktable startup and should output this three lines:
|
||||
|
||||
LUA ERROR Hello World!
|
||||
LUA ERROR Bild
|
||||
LUA ERROR Hallo Welt!
|
||||
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
--check API version
|
||||
du.check_min_api_version("3.0.0", "gettextExample")
|
||||
|
||||
-- script_manager integration to allow a script to be removed
|
||||
-- without restarting darktable
|
||||
local function destroy()
|
||||
-- nothing to destroy
|
||||
end
|
||||
|
||||
-- Not translated Text
|
||||
dt.print_error("Hello World!")
|
||||
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
-- Translate a string using the darktable textdomain
|
||||
dt.print_error(gettext("image"))
|
||||
|
||||
-- Define a local function called _ to make the code more readable and have it call dgettext
|
||||
-- with the proper domain.
|
||||
local function _(msgid)
|
||||
return gettext(msgid)
|
||||
end
|
||||
|
||||
dt.print_error(_("hello world!"))
|
||||
|
||||
-- set the destroy routine so that script_manager can call it when
|
||||
-- it's time to destroy the script and then return the data to
|
||||
-- script_manager
|
||||
local script_data = {}
|
||||
|
||||
script_data.metadata = {
|
||||
name = _("gettext example"),
|
||||
purpose = _("example of how translations works"),
|
||||
author = "Tobias Jakobs",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/gettextExample"
|
||||
}
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
142
examples/gui_action.lua
Normal file
142
examples/gui_action.lua
Normal file
@@ -0,0 +1,142 @@
|
||||
local dt = require "darktable"
|
||||
|
||||
local NaN = 0/0
|
||||
|
||||
local wg = {}
|
||||
|
||||
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 = _("gui action"),
|
||||
purpose = _("example of how to use darktable.gui.action() calls"),
|
||||
author = "Diederik ter Rahe",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/gui_action"
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
wg.action = dt.new_widget("entry"){
|
||||
text = "lib/filter/view",
|
||||
placeholder = _("action path"),
|
||||
tooltip = _("enter the full path of an action, for example 'lib/filter/view'")
|
||||
}
|
||||
|
||||
wg.instance = dt.new_widget("combobox"){
|
||||
label = _("instance"),
|
||||
tooltip = _("the instance of an image processing module to execute action on"),
|
||||
"0", "+1", "-1", "+2", "-2", "+3", "-3", "+4", "-4", "+5", "-5", "+6", "-6", "+7", "-7", "+8", "-8", "+9", "-9"
|
||||
}
|
||||
|
||||
wg.element = dt.new_widget("entry"){
|
||||
text = "",
|
||||
placeholder = _("action element"),
|
||||
tooltip = _("enter the element of an action, for example 'selection', or leave empty for default")
|
||||
}
|
||||
|
||||
wg.effect = dt.new_widget("entry"){
|
||||
text = "next",
|
||||
placeholder = _("action effect"),
|
||||
tooltip = _("enter the effect of an action, for example 'next', or leave empty for default")
|
||||
}
|
||||
|
||||
wg.speed = dt.new_widget("entry"){
|
||||
text = "1",
|
||||
placeholder = _("action speed"),
|
||||
tooltip = _("enter the speed to use in action execution, or leave empty to only read state")
|
||||
}
|
||||
|
||||
wg.check = dt.new_widget("check_button"){
|
||||
label = _('perform action'),
|
||||
tooltip = _('perform action or only read return'),
|
||||
clicked_callback = function()
|
||||
wg.speed.sensitive = wg.check.value
|
||||
end,
|
||||
value = true
|
||||
}
|
||||
|
||||
wg.return_value = dt.new_widget("entry"){
|
||||
text = "",
|
||||
sensitive = false
|
||||
}
|
||||
|
||||
dt.register_lib(
|
||||
"execute_action", -- Module name
|
||||
_("execute gui actions"), -- name
|
||||
true, -- expandable
|
||||
false, -- resetable
|
||||
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER", 100},
|
||||
[dt.gui.views.darkroom] = {"DT_UI_CONTAINER_PANEL_LEFT_CENTER", 100}},
|
||||
dt.new_widget("box")
|
||||
{
|
||||
orientation = "vertical",
|
||||
|
||||
dt.new_widget("box")
|
||||
{
|
||||
orientation = "horizontal",
|
||||
dt.new_widget("label"){label = _("action path"), halign = "start"},
|
||||
wg.action
|
||||
},
|
||||
wg.instance,
|
||||
dt.new_widget("box")
|
||||
{
|
||||
orientation = "horizontal",
|
||||
dt.new_widget("label"){label = _("element"), halign = "start"},
|
||||
wg.element
|
||||
},
|
||||
dt.new_widget("box")
|
||||
{
|
||||
orientation = "horizontal",
|
||||
dt.new_widget("label"){label = _("effect"), halign = "start"},
|
||||
wg.effect
|
||||
},
|
||||
wg.check,
|
||||
dt.new_widget("box")
|
||||
{
|
||||
orientation = "horizontal",
|
||||
dt.new_widget("label"){label = _("speed"), halign = "start"},
|
||||
wg.speed
|
||||
},
|
||||
dt.new_widget("button")
|
||||
{
|
||||
label = _("execute action"),
|
||||
tooltip = _("execute the action specified in the fields above"),
|
||||
clicked_callback = function(_)
|
||||
local sp = NaN
|
||||
if wg.check.value then sp = wg.speed.text end
|
||||
wg.return_value.text = dt.gui.action(wg.action.text, tonumber(wg.instance.value), wg.element.text, wg.effect.text, tonumber(sp))
|
||||
end
|
||||
},
|
||||
dt.new_widget("box")
|
||||
{
|
||||
orientation = "horizontal",
|
||||
dt.new_widget("label"){label = "return value:", halign = "start"},
|
||||
wg.return_value
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
local function restart()
|
||||
dt.gui.libs["execute_action"].visible = true
|
||||
end
|
||||
|
||||
local function destroy()
|
||||
dt.gui.libs["execute_action"].visible = false
|
||||
end
|
||||
|
||||
script_data.destroy = destroy
|
||||
script_data.destroy_method = "hide"
|
||||
script_data.restart = restart
|
||||
script_data.show = restart
|
||||
|
||||
return script_data
|
||||
@@ -27,9 +27,40 @@ USAGE
|
||||
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
dt.configuration.check_version(...,{2,0,0})
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
dt.print("hello, world")
|
||||
-- translation facilities
|
||||
|
||||
du.check_min_api_version("2.0.0", "hello_world")
|
||||
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
local function _(msg)
|
||||
return gettext(msg)
|
||||
end
|
||||
|
||||
-- script_manager integration to allow a script to be removed
|
||||
-- without restarting darktable
|
||||
local function destroy()
|
||||
-- nothing to destroy
|
||||
end
|
||||
|
||||
dt.print(_("hello, world"))
|
||||
|
||||
-- set the destroy routine so that script_manager can call it when
|
||||
-- it's time to destroy the script and then return the data to
|
||||
-- script_manager
|
||||
local script_data = {}
|
||||
|
||||
script_data.metadata = {
|
||||
name = _("hello world"),
|
||||
purpose = _("example of how to print a message to the screen"),
|
||||
author = "Tobias Ellinghaus",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/hello_world"
|
||||
}
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
--
|
||||
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
|
||||
229
examples/lighttable_demo.lua
Normal file
229
examples/lighttable_demo.lua
Normal file
@@ -0,0 +1,229 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
copyright (c) 2019 Bill Ferguson <wpferguson@gmail.com>
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
lighttable_demo - an example script demonstrating how to control lighttable display modes
|
||||
|
||||
lighttable_demo is an example script showing how to control lighttable layout, sorting, and
|
||||
filtering from a lua script. If the selected directory has different ratings, color labels, etc,
|
||||
then the sorting and filtering display is a little clearer.
|
||||
|
||||
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
|
||||
* none
|
||||
|
||||
USAGE
|
||||
* require this script from your main lua file
|
||||
|
||||
BUGS, COMMENTS, SUGGESTIONS
|
||||
* Send to Bill Ferguson, wpferguson@gmail.com
|
||||
|
||||
CHANGES
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- V E R S I O N C H E C K
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
du.check_min_api_version("5.0.2", "lighttable_demo") -- darktable 3.0
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- C O N S T A N T S
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
local MODULE_NAME = "lighttable"
|
||||
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
|
||||
|
||||
-- script_manager integration to allow a script to be removed
|
||||
-- without restarting darktable
|
||||
local function destroy()
|
||||
-- nothing to destroy
|
||||
end
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- T R A N S L A T I O N S
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
dt.gettext.bindtextdomain("lighttable_demo", dt.configuration.config_dir .."/lua/locale/")
|
||||
|
||||
local function _(msgid)
|
||||
return gettext(msgid)
|
||||
end
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- F U N C T I O N S
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- M A I N
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
-- alias dt.control.sleep to sleep
|
||||
local sleep = dt.control.sleep
|
||||
|
||||
local layouts = {
|
||||
"DT_LIGHTTABLE_LAYOUT_ZOOMABLE",
|
||||
"DT_LIGHTTABLE_LAYOUT_FILEMANAGER",
|
||||
"DT_LIGHTTABLE_LAYOUT_CULLING",
|
||||
"DT_LIGHTTABLE_LAYOUT_CULLING_DYNAMIC",
|
||||
}
|
||||
|
||||
local sorts = {
|
||||
"DT_COLLECTION_SORT_NONE",
|
||||
"DT_COLLECTION_SORT_FILENAME",
|
||||
"DT_COLLECTION_SORT_DATETIME",
|
||||
"DT_COLLECTION_SORT_RATING",
|
||||
"DT_COLLECTION_SORT_ID",
|
||||
"DT_COLLECTION_SORT_COLOR",
|
||||
"DT_COLLECTION_SORT_GROUP",
|
||||
"DT_COLLECTION_SORT_PATH",
|
||||
"DT_COLLECTION_SORT_CUSTOM_ORDER",
|
||||
"DT_COLLECTION_SORT_TITLE",
|
||||
"DT_COLLECTION_SORT_DESCRIPTION",
|
||||
"DT_COLLECTION_SORT_ASPECT_RATIO",
|
||||
"DT_COLLECTION_SORT_SHUFFLE"
|
||||
}
|
||||
|
||||
local sort_orders = {
|
||||
"DT_COLLECTION_SORT_ORDER_ASCENDING",
|
||||
"DT_COLLECTION_SORT_ORDER_DESCENDING"
|
||||
}
|
||||
|
||||
local ratings = {
|
||||
"DT_COLLECTION_FILTER_ALL",
|
||||
"DT_COLLECTION_FILTER_STAR_NO",
|
||||
"DT_COLLECTION_FILTER_STAR_1",
|
||||
"DT_COLLECTION_FILTER_STAR_2",
|
||||
"DT_COLLECTION_FILTER_STAR_3",
|
||||
"DT_COLLECTION_FILTER_STAR_4",
|
||||
"DT_COLLECTION_FILTER_STAR_5",
|
||||
"DT_COLLECTION_FILTER_REJECT",
|
||||
"DT_COLLECTION_FILTER_NOT_REJECT"
|
||||
}
|
||||
|
||||
local rating_comparators = {
|
||||
"DT_COLLECTION_RATING_COMP_LT",
|
||||
"DT_COLLECTION_RATING_COMP_LEQ",
|
||||
"DT_COLLECTION_RATING_COMP_EQ",
|
||||
"DT_COLLECTION_RATING_COMP_GEQ",
|
||||
"DT_COLLECTION_RATING_COMP_GT",
|
||||
"DT_COLLECTION_RATING_COMP_NE"
|
||||
}
|
||||
|
||||
local zoom_levels = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
|
||||
|
||||
|
||||
-- save filter, view, and collection parameters
|
||||
|
||||
local current_layout = dt.gui.libs.lighttable_mode.layout()
|
||||
local current_zoom_level = dt.gui.libs.lighttable_mode.zoom_level()
|
||||
local current_rating = dt.gui.libs.filter.rating()
|
||||
local current_rating_comparator = dt.gui.libs.filter.rating_comparator()
|
||||
local current_sort = dt.gui.libs.filter.sort()
|
||||
local current_sort_order = dt.gui.libs.filter.sort_order()
|
||||
|
||||
-- cycle through layouts and zooms
|
||||
|
||||
dt.print(_("lighttable layout and zoom level demonstration"))
|
||||
sleep(2000)
|
||||
|
||||
for n, layout in ipairs(layouts) do
|
||||
dt.gui.libs.lighttable_mode.layout(layout)
|
||||
dt.print(string.format(_("set lighttable layout to %s"), layout))
|
||||
dt.print_log("set lighttable layout to " .. layout)
|
||||
sleep(1500)
|
||||
for i = 1, 10 do
|
||||
dt.gui.libs.lighttable_mode.zoom_level(i)
|
||||
dt.print(string.format(_("set zoom level to %d"), i))
|
||||
sleep(1500)
|
||||
end
|
||||
for i = 9, 1, -1 do
|
||||
dt.gui.libs.lighttable_mode.zoom_level(i)
|
||||
dt.print(string.format(_("set zoom level to %d"), i))
|
||||
sleep(1500)
|
||||
end
|
||||
end
|
||||
|
||||
dt.print_log("finished layout and zoom level testing")
|
||||
dt.print_log("starting sort demonstration")
|
||||
-- cycle through sorts
|
||||
|
||||
dt.print(_("lighttable sorting demonstration"))
|
||||
dt.print_log("setting lighttable to filemanager mode")
|
||||
dt.gui.libs.lighttable_mode.layout("DT_LIGHTTABLE_LAYOUT_FILEMANAGER")
|
||||
sleep(500)
|
||||
dt.print_log("setting lighttable to zoom level 5")
|
||||
dt.gui.libs.lighttable_mode.zoom_level(5)
|
||||
dt.print_log("starting sorts")
|
||||
|
||||
for n, sort in ipairs(sorts) do
|
||||
dt.gui.libs.filter.sort(sort)
|
||||
dt.print(string.format(_("set lighttable sort to %s"), sort))
|
||||
sleep(1500)
|
||||
|
||||
for m, sort_order in ipairs(sort_orders) do
|
||||
dt.gui.libs.filter.sort_order(sort_order)
|
||||
dt.print(string.format(_("sort order set to %s"), sort_order))
|
||||
sleep(1500)
|
||||
end
|
||||
end
|
||||
|
||||
-- cycle through filters
|
||||
|
||||
dt.print(_("lighttable filtering demonstration"))
|
||||
|
||||
for n, rating in ipairs(ratings) do
|
||||
dt.gui.libs.filter.rating(rating)
|
||||
dt.print(string.format(_("set filter to %s"), rating))
|
||||
sleep(1500)
|
||||
|
||||
for m, rating_comparator in ipairs(rating_comparators) do
|
||||
dt.gui.libs.filter.rating_comparator(rating_comparator)
|
||||
dt.print(string.format(_("set rating comparator to %s"), rating_comparator))
|
||||
sleep(1500)
|
||||
end
|
||||
end
|
||||
|
||||
-- restore settings
|
||||
|
||||
dt.print(_("restoring settings"))
|
||||
|
||||
current_layout = dt.gui.libs.lighttable_mode.layout(current_layout)
|
||||
current_zoom_level = dt.gui.libs.lighttable_mode.zoom_level(current_zoom_level)
|
||||
current_rating = dt.gui.libs.filter.rating(current_rating)
|
||||
current_rating_comparator = dt.gui.libs.filter.rating_comparator(current_rating_comparator)
|
||||
current_sort =dt.gui.libs.filter.sort(current_sort)
|
||||
current_sort_order = dt.gui.libs.filter.sort_order(current_sort_order)
|
||||
|
||||
-- set the destroy routine so that script_manager can call it when
|
||||
-- it's time to destroy the script and then return the data to
|
||||
-- script_manager
|
||||
local script_data = {}
|
||||
|
||||
script_data.metadata = {
|
||||
name = _("lighttable demo"),
|
||||
purpose = _("example demonstrating how to control lighttable display modes"),
|
||||
author = "Bill Ferguson <wpferguson@gmail.com>",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/lighttable_demo"
|
||||
}
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
195
examples/moduleExample.lua
Normal file
195
examples/moduleExample.lua
Normal file
@@ -0,0 +1,195 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
copyright (c) 2016 Tobias Jakobs
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
|
||||
USAGE
|
||||
* require this script from your luarc file
|
||||
To do this add this line to the file .config/darktable/luarc:
|
||||
require "examples/moduleExample"
|
||||
|
||||
* it creates a new example lighttable module
|
||||
|
||||
More informations about building user interface elements:
|
||||
https://www.darktable.org/usermanual/ch09.html.php#lua_gui_example
|
||||
And about new_widget here:
|
||||
https://www.darktable.org/lua-api/index.html.php#darktable_new_widget
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
du.check_min_api_version("7.0.0", "moduleExample")
|
||||
|
||||
-- https://www.darktable.org/lua-api/index.html#darktable_gettext
|
||||
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 = ("module example"),
|
||||
purpose = _("example of how to create a lighttable module"),
|
||||
author = "Tobias Jakobs",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/moduleExample"
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
-- translation
|
||||
|
||||
-- declare a local namespace and a couple of variables we'll need to install the module
|
||||
local mE = {}
|
||||
mE.widgets = {}
|
||||
mE.event_registered = false -- keep track of whether we've added an event callback or not
|
||||
mE.module_installed = false -- keep track of whether the module is module_installed
|
||||
|
||||
--[[ We have to create the module in one of two ways depending on which view darktable starts
|
||||
in. In orker to not repeat code, we wrap the darktable.register_lib in a local function.
|
||||
]]
|
||||
|
||||
local function install_module()
|
||||
if not mE.module_installed then
|
||||
-- https://www.darktable.org/lua-api/index.html#darktable_register_lib
|
||||
dt.register_lib(
|
||||
"exampleModule", -- Module name
|
||||
_("example module"), -- name
|
||||
true, -- expandable
|
||||
false, -- resetable
|
||||
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 100}}, -- containers
|
||||
-- https://www.darktable.org/lua-api/types_lua_box.html
|
||||
dt.new_widget("box") -- widget
|
||||
{
|
||||
orientation = "vertical",
|
||||
dt.new_widget("button")
|
||||
{
|
||||
label = _("my ") .. "button",
|
||||
clicked_callback = function (_)
|
||||
dt.print(_("button clicked"))
|
||||
end
|
||||
},
|
||||
table.unpack(mE.widgets),
|
||||
},
|
||||
nil,-- view_enter
|
||||
nil -- view_leave
|
||||
)
|
||||
mE.module_installed = true
|
||||
end
|
||||
end
|
||||
|
||||
-- script_manager integration to allow a script to be removed
|
||||
-- without restarting darktable
|
||||
local function destroy()
|
||||
dt.gui.libs["exampleModule"].visible = false -- we haven't figured out how to destroy it yet, so we hide it for now
|
||||
end
|
||||
|
||||
local function restart()
|
||||
dt.gui.libs["exampleModule"].visible = true -- the user wants to use it again, so we just make it visible and it shows up in the UI
|
||||
end
|
||||
|
||||
-- https://www.darktable.org/lua-api/types_lua_check_button.html
|
||||
local check_button = dt.new_widget("check_button"){label = _("my ") .. "check_button", value = true}
|
||||
|
||||
-- https://www.darktable.org/lua-api/types_lua_combobox.html
|
||||
local combobox = dt.new_widget("combobox"){label = _("my ") .. "combobox", value = 2, "8", "16", "32"}
|
||||
|
||||
-- https://www.darktable.org/lua-api/types_lua_entry.html
|
||||
local entry = dt.new_widget("entry")
|
||||
{
|
||||
text = "test",
|
||||
placeholder = _("placeholder"),
|
||||
is_password = false,
|
||||
editable = true,
|
||||
tooltip = _("tooltip text"),
|
||||
reset_callback = function(self) self.text = "text" end
|
||||
}
|
||||
|
||||
-- https://www.darktable.org/lua-api/types_lua_file_chooser_button.html
|
||||
local file_chooser_button = dt.new_widget("file_chooser_button")
|
||||
{
|
||||
title = _("my ") .. "file_chooser_button", -- The title of the window when choosing a file
|
||||
value = "", -- The currently selected file
|
||||
is_directory = false -- True if the file chooser button only allows directories to be selecte
|
||||
}
|
||||
|
||||
-- https://www.darktable.org/lua-api/types_lua_label.html
|
||||
local label = dt.new_widget("label")
|
||||
label.label = _("my ") .. "label" -- This is an alternative way to the "{}" syntax to set a property
|
||||
|
||||
-- https://www.darktable.org/lua-api/types_lua_separator.html
|
||||
local separator = dt.new_widget("separator"){}
|
||||
|
||||
-- https://www.darktable.org/lua-api/types_lua_slider.html
|
||||
local slider = dt.new_widget("slider")
|
||||
{
|
||||
label = _("my ") .. "slider",
|
||||
soft_min = 10, -- The soft minimum value for the slider, the slider can't go beyond this point
|
||||
soft_max = 100, -- The soft maximum value for the slider, the slider can't go beyond this point
|
||||
hard_min = 0, -- The hard minimum value for the slider, the user can't manually enter a value beyond this point
|
||||
hard_max = 1000, -- The hard maximum value for the slider, the user can't manually enter a value beyond this point
|
||||
value = 52 -- The current value of the slider
|
||||
}
|
||||
|
||||
-- pack the widgets in a table for loading in the module
|
||||
|
||||
table.insert(mE.widgets, check_button)
|
||||
table.insert(mE.widgets, combobox)
|
||||
table.insert(mE.widgets, entry)
|
||||
table.insert(mE.widgets, file_chooser_button)
|
||||
table.insert(mE.widgets, label)
|
||||
table.insert(mE.widgets, separator)
|
||||
table.insert(mE.widgets, slider)
|
||||
|
||||
-- ... and tell dt about it all
|
||||
|
||||
|
||||
if dt.gui.current_view().id == "lighttable" then -- make sure we are in lighttable view
|
||||
install_module() -- register the lib
|
||||
else
|
||||
if not mE.event_registered then -- if we are not in lighttable view then register an event to signal when we might be
|
||||
-- https://www.darktable.org/lua-api/index.html#darktable_register_event
|
||||
dt.register_event(
|
||||
"mdouleExample", "view-changed", -- we want to be informed when the view changes
|
||||
function(event, old_view, new_view)
|
||||
if new_view.name == "lighttable" and old_view.name == "darkroom" then -- if the view changes from darkroom to lighttable
|
||||
install_module() -- register the lib
|
||||
end
|
||||
end
|
||||
)
|
||||
mE.event_registered = true -- keep track of whether we have an event handler installed
|
||||
end
|
||||
end
|
||||
|
||||
-- set the destroy routine so that script_manager can call it when
|
||||
-- it's time to destroy the script and then return the data to
|
||||
-- script_manager
|
||||
script_data.destroy = destroy
|
||||
script_data.restart = restart -- only required for lib modules until we figure out how to destroy them
|
||||
script_data.destroy_method = "hide" -- tell script_manager that we are hiding the lib so it knows to use the restart function
|
||||
script_data.show = restart -- if the script was "off" when darktable exited, the module is hidden, so force it to show on start
|
||||
|
||||
return script_data
|
||||
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
|
||||
-- kate: hl Lua;
|
||||
306
examples/multi_os.lua
Normal file
306
examples/multi_os.lua
Normal file
@@ -0,0 +1,306 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
copyright (c) 2017,2018 Bill Ferguson <wpferguson@gmail.com>
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
multi_os - an example script that runs on linux, MacOS, and Windows.
|
||||
|
||||
multi_os is an example of how to write a script that will run on different
|
||||
operating systems. It uses the lua-scripts libraries to lessen the amount
|
||||
of code that needs to be written, as well as gaining access to tested
|
||||
cross-platform routines. This script also performs a function that some
|
||||
may find useful. It creates a button in the lighttable selected images module
|
||||
that extracts the embedded jpeg image from a raw file, then imports it and groups
|
||||
it with the raw file. A keyboard shortcut is also created. A key combination can
|
||||
be assigned to the shortcut in the lua preferences and then the action can be invoked
|
||||
by hovering over the image and pressing the key combination.
|
||||
|
||||
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
|
||||
* exiftool - https://exiftool.org
|
||||
|
||||
USAGE
|
||||
* require this script from your main lua file
|
||||
* start darktable, open prefreences, go to lua options
|
||||
and update the executable location if you are running
|
||||
Windows or MacOS, then restart darktable.
|
||||
* select an image or images
|
||||
* click the button to extract the jpeg
|
||||
|
||||
BUGS, COMMENTS, SUGGESTIONS
|
||||
* Send to Bill Ferguson, wpferguson@gmail.com
|
||||
|
||||
CHANGES
|
||||
20251205 - replaced ufraw-batch with exiftool
|
||||
]]
|
||||
|
||||
--[[
|
||||
require "darktable" provides the interface to the darktable lua functions used to
|
||||
interact with darktable
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
|
||||
--[[
|
||||
require "lib/..." provides access to functions that have been pulled from various
|
||||
scripts and consolidated into libraries. Using the libraries eliminates having to
|
||||
recode common functions in every script.
|
||||
]]
|
||||
|
||||
local du = require "lib/dtutils" -- utilities
|
||||
local df = require "lib/dtutils.file" -- file utilities
|
||||
local dtsys = require "lib/dtutils.system" -- system utilities
|
||||
|
||||
--[[
|
||||
darktable is an international program, and it's user interface has been translated into
|
||||
many languages. The lua API provides gettext which is a function that looks for and replaces
|
||||
strings with the translated equivalents based on locale. Even if you don't provide the
|
||||
translations, inserting this lays the groundwork for anyone who wants to translate the strings.
|
||||
]]
|
||||
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
local function _(msgid)
|
||||
return gettext(msgid)
|
||||
end
|
||||
|
||||
--[[
|
||||
Check that the current api version is greater than or equal to the specified minimum. If it's not
|
||||
then du.check_min_api_version will print an error to the log and return false. If the minimum api is
|
||||
not met, then just refuse to load and return. Optionally, you could print an error message to the
|
||||
screen stating that you couldn't load because the minimum api version wasn't met.
|
||||
]]
|
||||
|
||||
du.check_min_api_version("7.0.0", "multi_os")
|
||||
|
||||
--[[
|
||||
copy_image_attributes is a local subroutine to copy image attributes in the database from the raw image
|
||||
to the extracted jpeg image. Even though the subroutine could act on the variables in the main program
|
||||
directly, passing them as arguments and using them in the subroutine is much safer.
|
||||
]]
|
||||
|
||||
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 check_file_size(img_name)
|
||||
local result = 0
|
||||
|
||||
if dt.configuration.running_os == "windows" then
|
||||
local path = df.get_path(img_name)
|
||||
local fname = df.get_filename(img_name)
|
||||
|
||||
local p = io.open("forfiles /P " .. path .. " /M " .. fname .. " /C \"cmd /c echo $fsize\"")
|
||||
|
||||
if p then
|
||||
for line in p:lines() do
|
||||
if line:length() > 5 then
|
||||
result = tonumber(line)
|
||||
end
|
||||
end
|
||||
p:close()
|
||||
end
|
||||
else
|
||||
local p = io.popen("ls -s " .. img_name)
|
||||
|
||||
if p then
|
||||
local line = p:read("*a")
|
||||
result = tonumber(du.split(line, " ")[1])
|
||||
p:close()
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
--[[
|
||||
The main function called from the button or the shortcut. It takes one or more raw files, passed
|
||||
in a table and extracts the embedded jpeg images
|
||||
]]
|
||||
|
||||
local function extract_embedded_jpeg(images)
|
||||
|
||||
--[[
|
||||
check if the executable exists, since we can't do anything without it. check_if_bin_exists()
|
||||
checks to see if there is a saved executable location. If not, it checks for the executable
|
||||
in the user's path. When it finds the executable, it returns the command to run it.
|
||||
]]
|
||||
|
||||
local exiftool_executable = df.check_if_bin_exists("exiftool")
|
||||
if exiftool_executable then
|
||||
for _, image in ipairs(images) do
|
||||
if image.is_raw then
|
||||
local img_file = tostring(image)
|
||||
local jpg_img_file = string.gsub(img_file, "%....$", ".jpg")
|
||||
|
||||
--[[
|
||||
dtsys.external_command() is operating system aware and formats the command as necessary.
|
||||
df.sanitize_filename() is used to quote the image filepath to protect from spaces. It is also
|
||||
operating system aware and uses the corresponding quotes.
|
||||
]]
|
||||
|
||||
if dtsys.external_command(exiftool_executable .. " -b -JpgFromRaw " .. df.sanitize_filename(img_file) .. " > " .. df.sanitize_filename(jpg_img_file)) then
|
||||
dt.print_log("created jpg from raw")
|
||||
if check_file_size(df.sanitize_filename(jpg_img_file)) == 0 then
|
||||
dt.print_log("using preview")
|
||||
dtsys.external_command(exiftool_executable .. " -b -PreviewImage " .. df.sanitize_filename(img_file) .. " > " .. df.sanitize_filename(jpg_img_file))
|
||||
end
|
||||
dt.print_log("jpg_img_file set to ", jpg_img_file) -- print a debugging message
|
||||
local myimage = dt.database.import(jpg_img_file)
|
||||
myimage:group_with(image.group_leader)
|
||||
copy_image_attributes(image, myimage, "all")
|
||||
|
||||
--[[
|
||||
copy all of the tags except the darktable tags
|
||||
]]
|
||||
|
||||
for _,tag in pairs(dt.tags.get_tags(image)) do
|
||||
if not (string.sub(tag.name,1,9) == "darktable") then
|
||||
dt.print_log("attaching tag")
|
||||
dt.tags.attach(tag,myimage)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
dt.print_error(image.filename .. " is not a raw file. No image can be extracted") -- print debugging error message
|
||||
dt.print(string.format(_("%s is not a raw file, no image can be extracted"), image.filename)) -- print the error to the screen
|
||||
end
|
||||
end
|
||||
else
|
||||
dt.print_error("exiftool not found. Exiting...") -- print debugging error message
|
||||
dt.print("exiftool not found, exiting...") -- print the error to the screen
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
script_manager integration to allow a script to be removed
|
||||
without restarting darktable
|
||||
]]
|
||||
|
||||
local function destroy()
|
||||
dt.destroy_event("multi_os", "shortcut") -- destroy the event since the callback will no longer be present
|
||||
dt.gui.libs.image.destroy_action("multi_os") -- remove the button from the selected images module
|
||||
end
|
||||
--[[
|
||||
Windows and MacOS don't place executables in the user's path so their location needs to be specified
|
||||
so that the script can find them. An exception to this is packages installed on MacOS with homebrew. Those
|
||||
executables are put in /usr/local/bin. These are saved as executable path preferences. check_if_bin_exists()
|
||||
looks for the executable path preference for the executable. If it doesn't find one, then the path is checked
|
||||
to see if the executable is there.
|
||||
]]
|
||||
|
||||
if dt.configuration.running_os ~= "linux" then
|
||||
local executable = "ufraw-batch"
|
||||
local ufraw_batch_path_widget = dt.new_widget("file_chooser_button"){
|
||||
title = string.format(_("select %s executable"), "ufraw-batch[.exe]"),
|
||||
value = df.get_executable_path_preference(executable),
|
||||
is_directory = false,
|
||||
changed_callback = function(self)
|
||||
if df.check_if_bin_exists(self.value) then
|
||||
df.set_executable_path_preference(executable, self.value)
|
||||
end
|
||||
end
|
||||
}
|
||||
dt.preferences.register("executable_paths", "ufraw-batch", -- name
|
||||
"file", -- type
|
||||
'multi_os: ufraw-batch ' .. _('location'), -- label
|
||||
_('installed location of ufraw-batch, requires restart to take effect.'), -- tooltip
|
||||
"ufraw-batch", -- default
|
||||
ufraw_batch_path_widget
|
||||
)
|
||||
end
|
||||
|
||||
--[[
|
||||
Add a button to the selected images module in lighttable
|
||||
]]
|
||||
|
||||
dt.gui.libs.image.register_action(
|
||||
"multi_os", _("extract embedded jpeg"),
|
||||
function(event, images) extract_embedded_jpeg(images) end,
|
||||
_("extract embedded jpeg")
|
||||
)
|
||||
|
||||
--[[
|
||||
Add a shortcut
|
||||
]]
|
||||
|
||||
dt.register_event(
|
||||
"multi_os", "shortcut",
|
||||
function(event, shortcut) extract_embedded_jpeg(dt.gui.action_images) end,
|
||||
_("extract embedded jpeg")
|
||||
)
|
||||
|
||||
--[[
|
||||
set the destroy routine so that script_manager can call it when
|
||||
it's time to destroy the script and then return the data to
|
||||
script_manager
|
||||
]]
|
||||
|
||||
local script_data = {}
|
||||
|
||||
script_data.metadata = {
|
||||
name = _("multi OS"),
|
||||
purpose = _("example module thet runs on different operating systems"),
|
||||
author = "Bill Ferguson <wpferguson@gmail.com>",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/multi_os"
|
||||
}
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
157
examples/panels_demo.lua
Normal file
157
examples/panels_demo.lua
Normal file
@@ -0,0 +1,157 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
copyright (c) 2019 Bill Ferguson <wpferguson@gmail.com>
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
panels_demo - an example script demonstrating how to contol panel visibility
|
||||
|
||||
panels_demo is an example script showing how to control panel visibility. It cycles
|
||||
through the panels hiding them one by one, then showing them one by one, then
|
||||
hiding all, then showing all. Finally, the original panel visibility is restored.
|
||||
|
||||
ADDITIONAL SOFTWARE NEEDED FOR THIS SCRIPT
|
||||
* none
|
||||
|
||||
USAGE
|
||||
* require this script from your main lua file
|
||||
|
||||
BUGS, COMMENTS, SUGGESTIONS
|
||||
* Send to Bill Ferguson, wpferguson@gmail.com
|
||||
|
||||
CHANGES
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- V E R S I O N C H E C K
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
du.check_min_api_version("7.0.0", "panels_demo")
|
||||
|
||||
-- script_manager integration to allow a script to be removed
|
||||
-- without restarting darktable
|
||||
local function destroy()
|
||||
-- nothing to destroy
|
||||
end
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- C O N S T A N T S
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
local MODULE_NAME = "panels_demo"
|
||||
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- T R A N S L A T I O N S
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
local function _(msgid)
|
||||
return gettext(msgid)
|
||||
end
|
||||
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
-- M A I N
|
||||
-- - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
-- alias dt.control.sleep to sleep
|
||||
local sleep = dt.control.sleep
|
||||
|
||||
local panels = {"DT_UI_PANEL_CENTER_TOP", -- center top panel
|
||||
"DT_UI_PANEL_CENTER_BOTTOM", -- center bottom panel
|
||||
"DT_UI_PANEL_TOP", -- complete top panel
|
||||
"DT_UI_PANEL_LEFT", -- left panel
|
||||
"DT_UI_PANEL_RIGHT", -- right panel
|
||||
"DT_UI_PANEL_BOTTOM"} -- complete bottom panel
|
||||
|
||||
local panel_status = {}
|
||||
|
||||
-- save panel visibility
|
||||
|
||||
for i = 1,#panels do
|
||||
panel_status[i] = dt.gui.panel_visible(panels[i])
|
||||
end
|
||||
|
||||
-- show all just in case
|
||||
|
||||
dt.gui.panel_show_all()
|
||||
|
||||
-- hide center_top, center_bottom, left, top, right, bottom in order
|
||||
|
||||
dt.print(_("hiding all panels, one at a time"))
|
||||
sleep(1500)
|
||||
|
||||
for i = 1, #panels do
|
||||
dt.print(string.format(_("hiding %s"), panels[i]))
|
||||
dt.gui.panel_hide(panels[i])
|
||||
sleep(1500)
|
||||
end
|
||||
|
||||
-- display left, then top, then right, then bottom
|
||||
|
||||
dt.print(_("make panels visible, one at a time"))
|
||||
sleep(1500)
|
||||
|
||||
for i = #panels, 1, -1 do
|
||||
dt.print(string.format(_("showing %s"), panels[i]))
|
||||
dt.gui.panel_show(panels[i])
|
||||
sleep(1500)
|
||||
end
|
||||
|
||||
-- hide all
|
||||
|
||||
dt.print(_("hiding all panels"))
|
||||
sleep(1500)
|
||||
|
||||
dt.gui.panel_hide_all()
|
||||
sleep(1500)
|
||||
|
||||
-- show all
|
||||
|
||||
dt.print(_("showing all panels"))
|
||||
sleep(1500)
|
||||
|
||||
dt.gui.panel_show_all()
|
||||
sleep(1500)
|
||||
|
||||
-- restore
|
||||
|
||||
dt.print(_("restoring panels to starting configuration"))
|
||||
for i = 1, #panels do
|
||||
if panel_status[i] then
|
||||
dt.gui.panel_show(panels[i])
|
||||
else
|
||||
dt.gui.panel_hide(panels[i])
|
||||
end
|
||||
end
|
||||
|
||||
-- set the destroy routine so that script_manager can call it when
|
||||
-- it's time to destroy the script and then return the data to
|
||||
-- script_manager
|
||||
local script_data = {}
|
||||
|
||||
script_data.metadata = {
|
||||
name = _("panels demo"),
|
||||
purpose = _("example demonstrating how to contol panel visibility"),
|
||||
author = "Bill Ferguson <wpferguson@gmail.com>",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/panels_demo"
|
||||
}
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
@@ -16,66 +16,94 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
]]
|
||||
--[[
|
||||
darktable script to show the different prefference types that are possible with the Lua
|
||||
darktable script to show the different preference types that are possible with Lua
|
||||
|
||||
USAGE
|
||||
* require this script from your main lua file
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
dt.configuration.check_version(...,{2,0,1})
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
-- translation facilities
|
||||
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
local function _(msg)
|
||||
return gettext(msg)
|
||||
end
|
||||
|
||||
local script_data = {}
|
||||
|
||||
script_data.metadata = {
|
||||
name = _("preference examples"),
|
||||
purpose = _("example to show the different preference types that are possible"),
|
||||
author = "Tobias Jakobs",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/preferenceExamples"
|
||||
}
|
||||
|
||||
du.check_min_api_version("2.0.1", "preferenceExamples")
|
||||
|
||||
|
||||
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
|
||||
"preferenceExamplesString", -- name
|
||||
"string", -- type
|
||||
"Example String", -- label
|
||||
"Example String Tooltip", -- tooltip
|
||||
_("example") .. " string", -- label
|
||||
_("example") .. " string " .. _("tooltip"), -- tooltip
|
||||
"String") -- default
|
||||
|
||||
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
|
||||
"preferenceExamplesString", -- name
|
||||
"preferenceExamplesBool", -- name
|
||||
"bool", -- type
|
||||
"Example Boolean", -- label
|
||||
"Example Boolean Tooltip", -- tooltip
|
||||
_("example") .. " boolean", -- label
|
||||
_("example") .. " boolean " .. _("tooltip"), -- tooltip
|
||||
true) -- default
|
||||
|
||||
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
|
||||
"preferenceExamplesString", -- name
|
||||
"preferenceExamplesInteger", -- name
|
||||
"integer", -- type
|
||||
"Example Integer", -- label
|
||||
"Example Integer Tooltip", -- tooltip
|
||||
_("example") .. " integer", -- label
|
||||
_("example") .. " integer " .. _("tooltip"), -- tooltip
|
||||
2, -- default
|
||||
1, -- min
|
||||
99) -- max
|
||||
|
||||
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
|
||||
"preferenceExamplesString", -- name
|
||||
"preferenceExamplesFloat", -- name
|
||||
"float", -- type
|
||||
"Example Float", -- label
|
||||
"Example Float Tooltip", -- tooltip
|
||||
_("example") .. " float", -- label
|
||||
_("example") .. " float " .. _("tooltip"), -- tooltip
|
||||
1.3, -- default
|
||||
1, -- min
|
||||
99, -- max
|
||||
0.5) -- step
|
||||
|
||||
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
|
||||
"preferenceExamplesString", -- name
|
||||
"preferenceExamplesFile", -- name
|
||||
"file", -- type
|
||||
"Example File", -- label
|
||||
"Example File Tooltip", -- tooltip
|
||||
_("example") .. " file", -- label
|
||||
_("example") .. " file " .. _("tooltip"), -- tooltip
|
||||
"") -- default
|
||||
|
||||
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
|
||||
"preferenceExamplesString", -- name
|
||||
"preferenceExamplesDirectory", -- name
|
||||
"directory", -- type
|
||||
"Example Directory", -- label
|
||||
"Example Directory Tooltip", -- tooltip
|
||||
_("example") .. " directory", -- label
|
||||
_("example") .. " directory " .. _("tooltip"), -- tooltip
|
||||
"") -- default
|
||||
|
||||
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
|
||||
"preferenceExamplesString", -- name
|
||||
"preferenceExamplesEnum", -- name
|
||||
"enum", -- type
|
||||
"Example Enum", -- label
|
||||
"Example Enum Tooltip", -- tooltip
|
||||
_("example") .. " enum", -- label
|
||||
_("example") .. " enum " .. _("tooltip"), -- tooltip
|
||||
"Enum 1", -- default
|
||||
"Enum 1", "Enum 2") -- values
|
||||
|
||||
|
||||
local function destroy()
|
||||
-- nothing to destroy
|
||||
end
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
71
examples/printExamples.lua
Normal file
71
examples/printExamples.lua
Normal file
@@ -0,0 +1,71 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
copyright (c) 2017 Tobias Jakobs
|
||||
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/>.
|
||||
]]
|
||||
|
||||
--[[
|
||||
Print Examples
|
||||
prints "hello world when DT starts
|
||||
USAGE
|
||||
* require this file from your main lua config file:
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
du.check_min_api_version("5.0.0", "printExamples")
|
||||
|
||||
-- translation facilities
|
||||
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
local function _(msg)
|
||||
return gettext(msg)
|
||||
end
|
||||
|
||||
-- script_manager integration to allow a script to be removed
|
||||
-- without restarting darktable
|
||||
local function destroy()
|
||||
-- nothing to destroy
|
||||
end
|
||||
|
||||
-- Will print a string to the darktable control log (the long
|
||||
-- overlayed window that appears over the main panel).
|
||||
dt.print(_("print"))
|
||||
|
||||
-- This function will print its parameter if the Lua logdomain is
|
||||
-- activated. Start darktable with the "-d lua" command line option
|
||||
-- to enable the Lua logdomain.
|
||||
dt.print_error("print error")
|
||||
|
||||
-- This function will print its parameter if the Lua logdomain is
|
||||
-- activated. Start darktable with the "-d lua" command line option
|
||||
-- to enable the Lua logdomain.
|
||||
dt.print_log("print log")
|
||||
|
||||
-- set the destroy routine so that script_manager can call it when
|
||||
-- it's time to destroy the script and then return the data to
|
||||
-- script_manager
|
||||
local script_data = {}
|
||||
|
||||
script_data.metadata = {
|
||||
name = _("print examples"),
|
||||
purpose = _("example showing the different types of printing messages"),
|
||||
author = "Tobias Jakobs",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/printExamples"
|
||||
}
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
--
|
||||
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
|
||||
66
examples/running_os.lua
Normal file
66
examples/running_os.lua
Normal file
@@ -0,0 +1,66 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
copyright (c) 2017 Tobias Jakobs
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
|
||||
USAGE
|
||||
* require this script from your main lua file
|
||||
To do this add this line to the file .config/darktable/luarc:
|
||||
require "running_os"
|
||||
|
||||
prints the operating system
|
||||
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
du.check_min_api_version("5.0.0", "running_os")
|
||||
|
||||
-- translation facilities
|
||||
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
local function _(msg)
|
||||
return gettext(msg)
|
||||
end
|
||||
|
||||
-- script_manager integration to allow a script to be removed
|
||||
-- without restarting darktable
|
||||
local function destroy()
|
||||
-- nothing to destroy
|
||||
end
|
||||
|
||||
dt.print(string.format(_("you are running: %s"), dt.configuration.running_os))
|
||||
|
||||
-- set the destroy routine so that script_manager can call it when
|
||||
-- it's time to destroy the script and then return the data to
|
||||
-- script_manager
|
||||
local script_data = {}
|
||||
|
||||
script_data.metadata = {
|
||||
name = _("running OS"),
|
||||
purpose = _("example of how to determine the operating system being used"),
|
||||
author = "Tobias Jakobs",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/running_os"
|
||||
}
|
||||
|
||||
script_data.destroy = destroy
|
||||
|
||||
return script_data
|
||||
|
||||
--
|
||||
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
|
||||
345
examples/x-touch.lua
Normal file
345
examples/x-touch.lua
Normal file
@@ -0,0 +1,345 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
copyright (c) 2023 Diederik ter Rahe
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
X-Touch Mini flexible encoder shortcuts
|
||||
|
||||
This script will create virtual sliders that are mapped dynamically to
|
||||
the most relevant sliders for the currently focused processing module.
|
||||
Tailored modules are color zones, tone equalizer, color calibration and
|
||||
mask manager properties. The script can easily be amended for other
|
||||
devices or personal preferences. Virtual "toggle" buttons can be created
|
||||
as well, that dynamically change meaning depending on current status.
|
||||
|
||||
USAGE
|
||||
* require this script from your main lua file
|
||||
* restart darktable
|
||||
* create shortcuts for each of the encoders on the x-touch mini
|
||||
to a virtual slider under lua/x-touch
|
||||
or import the following shortcutsrc file in the shortcuts dialog/preferences tab:
|
||||
|
||||
None;midi:CC1=lua/x-touch/knob 1
|
||||
None;midi:CC2=lua/x-touch/knob 2
|
||||
None;midi:CC3=lua/x-touch/knob 3
|
||||
None;midi:CC4=lua/x-touch/knob 4
|
||||
None;midi:CC5=lua/x-touch/knob 5
|
||||
None;midi:CC6=lua/x-touch/knob 6
|
||||
None;midi:CC7=lua/x-touch/knob 7
|
||||
None;midi:CC8=lua/x-touch/knob 8
|
||||
midi:E0=global/modifiers
|
||||
midi:F0=global/modifiers;ctrl
|
||||
midi:F#0=global/modifiers;alt
|
||||
midi:G#-1=iop/blend/tools/show and edit mask elements
|
||||
midi:A-1=iop/colorzones;focus
|
||||
midi:A#-1=iop/toneequal;focus
|
||||
midi:B-1=iop/colorbalancergb;focus
|
||||
midi:C0=iop/channelmixerrgb;focus
|
||||
midi:C#0=iop/colorequal;focus
|
||||
midi:D0=iop/colorequal/page;previous
|
||||
midi:D#0=iop/colorequal/page;next
|
||||
|
||||
USAGE:
|
||||
To add a new module, simply add an entry to MODULE_PROFILES below.
|
||||
Get action paths from darktable's shortcut interface.
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
du.check_min_api_version("9.2.0", "x-touch")
|
||||
|
||||
local gettext = dt.gettext.gettext
|
||||
local function _(msgid)
|
||||
return gettext(msgid)
|
||||
end
|
||||
|
||||
-- Constants
|
||||
local NUM_KNOBS = 8
|
||||
local NAN = 0/0
|
||||
local darkroom_view = dt.gui.views.darkroom
|
||||
|
||||
-- ============================================================================
|
||||
-- USER CONFIGURATION
|
||||
-- ============================================================================
|
||||
|
||||
-- Module Profiles: Define behavior when each module has focus
|
||||
-- Structure: [module_name] = { knob1_action, knob2_action, ... }
|
||||
local MODULE_PROFILES = {
|
||||
|
||||
-- Color Zones: Control individual color channels
|
||||
colorzones = {
|
||||
{"iop/colorzones/graph", "red"},
|
||||
{"iop/colorzones/graph", "orange"},
|
||||
{"iop/colorzones/graph", "yellow"},
|
||||
{"iop/colorzones/graph", "green"},
|
||||
{"iop/colorzones/graph", "aqua"},
|
||||
{"iop/colorzones/graph", "blue"},
|
||||
{"iop/colorzones/graph", "purple"},
|
||||
{"iop/colorzones/graph", "magenta"}
|
||||
},
|
||||
|
||||
-- Color Equalizer: Control color channels
|
||||
colorequal = {
|
||||
{"iop/colorequal/graph", "red"},
|
||||
{"iop/colorequal/graph", "orange"},
|
||||
{"iop/colorequal/graph", "yellow"},
|
||||
{"iop/colorequal/graph", "green"},
|
||||
{"iop/colorequal/graph", "cyan"},
|
||||
{"iop/colorequal/graph", "blue"},
|
||||
{"iop/colorequal/graph", "lavender"},
|
||||
{"iop/colorequal/graph", "magenta"}
|
||||
},
|
||||
|
||||
-- Sigmoid: Control primary color adjustments
|
||||
sigmoid = {
|
||||
{"iop/sigmoid/primaries/red attenuation"},
|
||||
{"iop/sigmoid/primaries/red rotation"},
|
||||
{"iop/sigmoid/primaries/green attenuation"},
|
||||
{"iop/sigmoid/primaries/green rotation"},
|
||||
{"iop/sigmoid/primaries/blue attenuation"},
|
||||
{"iop/sigmoid/primaries/blue rotation"},
|
||||
{"iop/sigmoid/primaries/recover purity"}
|
||||
},
|
||||
|
||||
-- Color Calibration (Primaries)
|
||||
primaries = {
|
||||
{"iop/primaries/red hue"},
|
||||
{"iop/primaries/red purity"},
|
||||
{"iop/primaries/green hue"},
|
||||
{"iop/primaries/green purity"},
|
||||
{"iop/primaries/blue hue"},
|
||||
{"iop/primaries/blue purity"},
|
||||
{"iop/primaries/tint hue"},
|
||||
{"iop/primaries/tint purity"}
|
||||
},
|
||||
|
||||
-- AgX
|
||||
agx = {
|
||||
{"iop/agx/white relative exposure"},
|
||||
{"iop/agx/black relative exposure"},
|
||||
{"iop/agx/curve/pivot relative exposure"},
|
||||
{"iop/agx/curve/pivot target output"},
|
||||
{"iop/agx/curve/contrast"},
|
||||
{"iop/agx/curve/shoulder power"},
|
||||
{"iop/agx/curve/toe power"},
|
||||
{"iop/agx/curve/curve y gamma"}
|
||||
},
|
||||
|
||||
-- Tone Equalizer: Control EV bands
|
||||
-- For 8 knobs, using offsets -8 to get bands
|
||||
toneequal = {
|
||||
{"iop/toneequal/simple/-8 EV"},
|
||||
{"iop/toneequal/simple/-7 EV"},
|
||||
{"iop/toneequal/simple/-6 EV"},
|
||||
{"iop/toneequal/simple/-5 EV"},
|
||||
{"iop/toneequal/simple/-4 EV"},
|
||||
{"iop/toneequal/simple/-3 EV"},
|
||||
{"iop/toneequal/simple/-2 EV"},
|
||||
{"iop/toneequal/simple/-1 EV"}
|
||||
},
|
||||
|
||||
-- Color Balance RGB: Selected controls
|
||||
colorbalancergb = {
|
||||
nil, -- Knob 1: unused --> default
|
||||
{"iop/colorbalancergb/global vibrance"},
|
||||
{"iop/colorbalancergb/contrast"},
|
||||
{"iop/colorbalancergb/global chroma"},
|
||||
{"iop/colorbalancergb/global saturation"},
|
||||
{"iop/colorbalancergb/global brilliance"},
|
||||
nil, -- Knob 7: --> default
|
||||
nil -- Knob 8: --> default
|
||||
},
|
||||
|
||||
-- Channel Mixer RGB (Color Calibration): Tab control and sliders
|
||||
channelmixerrgb = {
|
||||
nil, -- Knob 1-4: --> default
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
{"iop/channelmixerrgb/page", "CAT", "tab"}, -- Knob 5: Tab selector
|
||||
{"iop/focus/sliders", "1st"}, -- Knob 6: First slider
|
||||
{"iop/focus/sliders", "2nd"}, -- Knob 7: Second slider
|
||||
{"iop/focus/sliders", "3rd"} -- Knob 8: Third slider
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
local DEFAULT_MAPPINGS = {
|
||||
{"iop/exposure/exposure"},
|
||||
{"iop/filmicrgb/white relative exposure"},
|
||||
{"iop/filmicrgb/black relative exposure"},
|
||||
{"iop/filmicrgb/contrast"},
|
||||
{"iop/crop/left"},
|
||||
{"iop/crop/right"},
|
||||
{"iop/crop/top"},
|
||||
{"iop/crop/bottom"}
|
||||
}
|
||||
-- Mask properties: Always checked first, regardless of module focus
|
||||
local MASK_PROPERTIES = {
|
||||
{"lib/masks/properties/opacity"},
|
||||
{"lib/masks/properties/size"},
|
||||
{"lib/masks/properties/feather"},
|
||||
{"lib/masks/properties/hardness"},
|
||||
{"lib/masks/properties/rotation"},
|
||||
{"lib/masks/properties/curvature"},
|
||||
{"lib/masks/properties/compression"}
|
||||
}
|
||||
|
||||
-- Priority order for checking module focus (most commonly used first)
|
||||
local MODULE_CHECK_ORDER = {
|
||||
"toneequal",
|
||||
"colorequal",
|
||||
"colorbalancergb",
|
||||
"agx",
|
||||
"sigmoid",
|
||||
"primaries",
|
||||
"channelmixerrgb",
|
||||
"colorzones"
|
||||
}
|
||||
|
||||
-- ============================================================================
|
||||
-- CORE LOGIC - No need to edit below unless changing architecture
|
||||
-- ============================================================================
|
||||
|
||||
-- Helper functions
|
||||
local function is_in_darkroom()
|
||||
return dt.gui.current_view() == darkroom_view
|
||||
end
|
||||
|
||||
local function is_valid(value)
|
||||
return value == value -- NaN check
|
||||
end
|
||||
|
||||
local function translate_tab_effect(effect)
|
||||
if effect == "up" then
|
||||
return "next"
|
||||
elseif effect == "down" then
|
||||
return "previous"
|
||||
else
|
||||
return "activate"
|
||||
end
|
||||
end
|
||||
|
||||
-- Execute an action configuration
|
||||
local function execute_action(action_config, element, effect, size)
|
||||
if not action_config then
|
||||
return nil
|
||||
end
|
||||
|
||||
local path = action_config[1]
|
||||
local elem = action_config[2] or element
|
||||
local action_type = action_config[3]
|
||||
|
||||
-- Handle special action types
|
||||
if action_type == "tab" then
|
||||
effect = translate_tab_effect(effect)
|
||||
end
|
||||
|
||||
return dt.gui.action(path, elem, effect, size)
|
||||
end
|
||||
|
||||
-- Try mask properties first
|
||||
local function try_mask_properties(knob_idx, element, effect, size)
|
||||
if knob_idx >= NUM_KNOBS then
|
||||
return NAN
|
||||
end
|
||||
|
||||
local mask_action = MASK_PROPERTIES[knob_idx]
|
||||
if not mask_action then
|
||||
return NAN
|
||||
end
|
||||
|
||||
local value = execute_action(mask_action, element, effect, size)
|
||||
return value
|
||||
end
|
||||
|
||||
-- Main knob handler
|
||||
local function handle_knob_action(knob_idx, element, effect, size)
|
||||
-- Early exit for non-darkroom view
|
||||
if not is_in_darkroom() then
|
||||
return NAN
|
||||
end
|
||||
|
||||
-- Try mask properties first (no focus check needed)
|
||||
local mask_value = try_mask_properties(knob_idx, element, effect, size)
|
||||
if is_valid(mask_value) then
|
||||
return mask_value
|
||||
end
|
||||
|
||||
-- Check focused modules in priority order
|
||||
for _, module_name in ipairs(MODULE_CHECK_ORDER) do
|
||||
local focus_status = dt.gui.action("iop/" .. module_name, "focus")
|
||||
|
||||
if focus_status ~= 0 then
|
||||
-- Module has focus, get its profile
|
||||
local profile = MODULE_PROFILES[module_name]
|
||||
|
||||
if profile then
|
||||
local action_config = profile[knob_idx]
|
||||
|
||||
-- If profile has explicit mapping for this knob, use it
|
||||
if action_config then
|
||||
local result = execute_action(action_config, element, effect, size)
|
||||
if result then
|
||||
return result
|
||||
end
|
||||
else
|
||||
-- Profile exists but this knob is nil -> use default
|
||||
-- This avoids checking other modules when we know the focused one
|
||||
local default_action = DEFAULT_MAPPINGS[knob_idx]
|
||||
return execute_action(default_action, element, effect, size) or NAN
|
||||
end
|
||||
end
|
||||
|
||||
-- If no profile exists for this module, continue checking others
|
||||
end
|
||||
end
|
||||
|
||||
-- No module has focus or no profile matched, fall back to default
|
||||
local default_action = DEFAULT_MAPPINGS[knob_idx]
|
||||
return execute_action(default_action, element, effect, size) or NAN
|
||||
end
|
||||
|
||||
-- Setup mimic sliders
|
||||
local function setup_knobs()
|
||||
for k = 1, NUM_KNOBS do
|
||||
dt.gui.mimic("slider", "knob " .. k,
|
||||
function(action, element, effect, size)
|
||||
local knob_idx = tonumber(action:sub(-1))
|
||||
return handle_knob_action(knob_idx, element, effect, size)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
-- Script metadata
|
||||
local script_data = {
|
||||
metadata = {
|
||||
name = _("x-touch"),
|
||||
purpose = _("data-driven x-touch midi controller configuration"),
|
||||
author = "Martin Straeten",
|
||||
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/examples/x-touch"
|
||||
},
|
||||
destroy = function() end,
|
||||
destroy_method = nil,
|
||||
restart = nil,
|
||||
show = nil
|
||||
}
|
||||
|
||||
-- Initialize
|
||||
setup_knobs()
|
||||
|
||||
return script_data
|
||||
@@ -1,54 +0,0 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
copyright (c) 2014 Jérémy Rosen
|
||||
|
||||
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/>.
|
||||
]]
|
||||
--[[
|
||||
INCLUDE ALL
|
||||
Automatically include all scripts in the script repository
|
||||
|
||||
This is intended for debugging purpose
|
||||
|
||||
|
||||
USAGE
|
||||
* require this file from your main lua config file:
|
||||
* go to configuration => preferences
|
||||
* Enable the scripts you want to use
|
||||
* restart darktable
|
||||
|
||||
Note that you need to restart DT for your changes to enabled scripts to take effect
|
||||
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
local io = require "io"
|
||||
dt.configuration.check_version(...,{2,0,0})
|
||||
|
||||
local output = io.popen("cd "..dt.configuration.config_dir.."/lua ;find . -name \\*.lua -print")
|
||||
local my_name={...}
|
||||
my_name = my_name[1]
|
||||
for line in output:lines() do
|
||||
local req_name = line:sub(3,-5)
|
||||
if req_name ~= my_name then
|
||||
dt.preferences.register(my_name,req_name,"bool","enable "..req_name,
|
||||
"Should the script "..req_name.." be enabled at next startup",false)
|
||||
|
||||
if dt.preferences.read(my_name,req_name,"bool") then
|
||||
require(req_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
|
||||
467
lib/dtutils.lua
Normal file
467
lib/dtutils.lua
Normal file
@@ -0,0 +1,467 @@
|
||||
local dtutils = {}
|
||||
|
||||
dtutils.libdoc = {
|
||||
Name = [[dtutils]],
|
||||
Synopsis = [[A Darktable lua utilities library]],
|
||||
Usage = [[local du = require "lib/dtutils"]],
|
||||
Description = [[dtutils provides a common library of functions used to build
|
||||
lua scripts. There are also sublibraries that provide more functions.]],
|
||||
Return_Value = [[du - library - the library of functions]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[dtutils.debug(3), dtutils.file(3), dtutils.log(3), dtutils.string(3)]],
|
||||
Reference = [[]],
|
||||
License = [[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/>.]],
|
||||
Copyright = [[Copyright (C) 2016 Bill Ferguson <wpferguson@gmail.com>.
|
||||
Copyright (C) 2016 Tobias Jakobs]],
|
||||
functions = {}
|
||||
}
|
||||
|
||||
local dt = require "darktable"
|
||||
|
||||
local log = require "lib/dtutils.log"
|
||||
|
||||
dtutils.libdoc.functions["check_min_api_version"] = {
|
||||
Name = [[check_min_api_version]],
|
||||
Synopsis = [[check the minimum required api version against the current api version]],
|
||||
Usage = [[local du = require "lib/dtutils"
|
||||
|
||||
local result = du.check_min_api_version(min_api, script_name)
|
||||
min_api - string - the api version that the application was written for (example: "5.0.0")
|
||||
script_name - string - the name of the script]],
|
||||
Description = [[check_min_api_version compares the minimum api required for the appllication to
|
||||
run against the current api version. The minimum api version is typically the api version that
|
||||
was current when the application was created. If the minimum api version is not met, then an
|
||||
error message is printed saying the script_name failed to load, then an error is thrown causing the
|
||||
program to stop executing.
|
||||
|
||||
This function is intended to replace darktable.configuration.check_version(). The application code
|
||||
won't have to be updated each time the api changes because this only checks the minimum version required.]],
|
||||
Return_Value = [[result - true if the minimum api version is available, false if not.]],
|
||||
Limitations = [[When using the default handler on a script being executed from the luarc file, the error thrown
|
||||
will stop the luarc file from executing any remaining statements. This limitation does not apply to script_manger.]],
|
||||
Example = [[check_min_api_version("5.0.0") does nothing if the api is greater or equal to 5.0.0 otherwise an
|
||||
error message is printed and an error is thrown stopping execution of the script.]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils.check_min_api_version(min_api, script_name)
|
||||
local current_api = dt.configuration.api_version_string
|
||||
if dtutils.compare_api_versions(min_api, current_api) > 0 then
|
||||
dt.print_error("This application is written for lua api version " .. min_api .. " or later.")
|
||||
dt.print_error("The current lua api version is " .. current_api)
|
||||
dt.print("ERROR: " .. script_name .. " failed to load. Lua API version " .. min_api .. " or later required.")
|
||||
dt.control.sleep(2000) -- allow time for the error to display before script_manager writes it's error message
|
||||
error("Minimum API " .. min_api .. " not met for " .. script_name .. ".", 0)
|
||||
end
|
||||
end
|
||||
|
||||
dtutils.libdoc.functions["check_max_api_version"] = {
|
||||
Name = [[check_max_api_version]],
|
||||
Synopsis = [[check the maximum required api version against the current api version]],
|
||||
Usage = [[local du = require "lib/dtutils"
|
||||
|
||||
local result = du.check_max_api_version(max_api, script_name)
|
||||
max_api - string - the api version that the application was written for (example: "5.0.0")
|
||||
script_name - string - the name of the script]],
|
||||
Description = [[check_max_api_version compares the maximum api required for the appllication to
|
||||
run against the current api version. This function is used when a part of the Lua API that
|
||||
the script relies on is removed. If the maximum api version is not met, then an
|
||||
error message is printed saying the script_name failed to load, then an error is thrown causing the
|
||||
program to stop executing.]],
|
||||
Return_Value = [[result - true if the maximum api version is available, false if not.]],
|
||||
Limitations = [[When using the default handler on a script being executed from the luarc file, the error thrown
|
||||
will stop the luarc file from executing any remaining statements. This limitation does not apply to script_manger.]],
|
||||
Example = [[check_max_api_version("9.0.0") does nothing if the api is less than or equal to 9.0.0 otherwise an
|
||||
error message is printed and an error is thrown stopping execution of the script.]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils.check_max_api_version(max_api, script_name)
|
||||
local current_api = dt.configuration.api_version_string
|
||||
if dtutils.compare_api_versions(current_api, max_api) > 0 then
|
||||
dt.print_error("This application is written for lua api version " .. max_api .. " or earlier.")
|
||||
dt.print_error("The current lua api version is " .. current_api)
|
||||
dt.print("ERROR: " .. script_name .. " failed to load. Lua API version " .. max_api .. " or earlier required.")
|
||||
dt.control.sleep(2000) -- allow time for the error to display before script_manager writes it's error message
|
||||
error("Maximum API " .. max_api .. " not met for " .. script_name .. ".", 0)
|
||||
end
|
||||
end
|
||||
|
||||
dtutils.libdoc.functions["split"] = {
|
||||
Name = [[split]],
|
||||
Synopsis = [[split a string on a specified separator]],
|
||||
Usage = [[local du = require "lib/dtutils"
|
||||
|
||||
local result = du.split(str, pat)
|
||||
str - string - the string to split
|
||||
pat - string - the pattern to split on]],
|
||||
Description = [[split separates a string into a table of strings. The strings are separated at each
|
||||
occurrence of the supplied pattern. The pattern may be any pattern as described in the lua docs.
|
||||
Each match of the pattern is consumed and not returned.]],
|
||||
Return_Value = [[result - a table of strings on success, or an empty table on error]],
|
||||
Limitations = [[]],
|
||||
Example = [[split("/a/long/path/name/to/a/file.txt", "/") would return a table like
|
||||
{a, "long", "path", "name", "to", a, "file.txt"}]],
|
||||
See_Also = [[]],
|
||||
Reference = [[http://lua-users.org/wiki/SplitJoin]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils.split(str, pat)
|
||||
local t = {}
|
||||
local fpat = "(.-)" .. pat
|
||||
local last_end = 1
|
||||
local s, e, cap = str:find(fpat, 1)
|
||||
while s do
|
||||
if s ~= 1 or cap ~= "" then
|
||||
table.insert(t,cap)
|
||||
end
|
||||
last_end = e+1
|
||||
s, e, cap = str:find(fpat, last_end)
|
||||
end
|
||||
if last_end <= #str then
|
||||
cap = str:sub(last_end)
|
||||
table.insert(t, cap)
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
dtutils.libdoc.functions["join"] = {
|
||||
Name = [[join]],
|
||||
Synopsis = [[join a table of strings with a specified separator]],
|
||||
Usage = [[local du = require "lib/dtutils"
|
||||
|
||||
local result = du.join(tabl, pat)
|
||||
tabl - a table of strings
|
||||
pat - a separator]],
|
||||
Description = [[join assembles a table of strings into a string with the specified pattern
|
||||
in between each string]],
|
||||
Return_Value = [[result - string - the joined string on success, or an empty string on failure]],
|
||||
Limitations = [[]],
|
||||
Example = [[join({a, "long", "path", "name", "to", a, "file.txt"}, " ") would return the string
|
||||
"a long path name to a file.txt"]],
|
||||
See_Also = [[]],
|
||||
Reference = [[http://lua-users.org/wiki/SplitJoin]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils.join(tabl, pat)
|
||||
returnstr = ""
|
||||
for i,str in pairs(tabl) do
|
||||
returnstr = returnstr .. str .. pat
|
||||
end
|
||||
return string.sub(returnstr, 1, -(pat:len() + 1))
|
||||
end
|
||||
|
||||
--[[
|
||||
NAME
|
||||
prequire - a protected lua require
|
||||
|
||||
SYNOPSIS
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
local result = du.prequire(req_name)
|
||||
req_name - the filename of the lua code to load without the ".lua" filetype
|
||||
|
||||
DESCRIPTION
|
||||
prequire is a protected require that can survive an error in the code being loaded without
|
||||
bringing down the calling routine.
|
||||
|
||||
RETURN VALUE
|
||||
result - the code or true on success, otherwise an error message
|
||||
|
||||
EXAMPLE
|
||||
prequire("lib/dtutils.file") which would load lib/dtutils/file.lua
|
||||
|
||||
]]
|
||||
|
||||
dtutils.libdoc.functions["prequire"] = {
|
||||
Name = [[prequire]],
|
||||
Synopsis = [[a protected lua require]],
|
||||
Usage = [[local du = require "lib/dtutils"
|
||||
|
||||
local status, lib = du.prequire(req_name)
|
||||
req_name - the filename of the lua code to load without the ".lua" filetype]],
|
||||
Description = [[prequire is a protected require that can survive an error in the code being loaded without
|
||||
bringing down the calling routine.]],
|
||||
Return_Value = [[status - boolean - true on success
|
||||
lib - if status is true, then the code, otherwise an error message]],
|
||||
Limitations = [[]],
|
||||
Example = [[local status, lib = prequire("lib/dtutils.file") which would load lib/dtutils/file.lua which
|
||||
would return a status of true and the reference to the library in lib.]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils.prequire(req_name)
|
||||
local status, lib = pcall(require, req_name)
|
||||
if status then
|
||||
log.msg(log.info, "Loaded " .. req_name)
|
||||
else
|
||||
log.msg(log.error, "Error loading " .. req_name)
|
||||
log.msg(log.error, "Error returned is " .. lib)
|
||||
end
|
||||
return status, lib
|
||||
end
|
||||
|
||||
dtutils.libdoc.functions["spairs"] = {
|
||||
Name = [[spairs]],
|
||||
Synopsis = [[an iterator that provides sorted pairs from a table]],
|
||||
Usage = [[local du = require "lib/dtutils"
|
||||
|
||||
for key, value in du.spairs(t, order) do
|
||||
t - table - table of key, value pairs
|
||||
order - function - an optional function to sort the pairs
|
||||
if none is supplied, table.sort() is used]],
|
||||
Description = [[spairs is an iterator that returns key, value pairs from a table in sorted
|
||||
order. The sorting order is the result of table.sort() if no function is
|
||||
supplied, otherwise sorting is done as specified in the function.]],
|
||||
Return_Value = [[]],
|
||||
Limitations = [[]],
|
||||
Example = [[HighScore = { Robin = 8, Jon = 10, Max = 11 }
|
||||
|
||||
-- basic usage, just sort by the keys
|
||||
for k,v in spairs(HighScore) do
|
||||
print(k,v)
|
||||
end
|
||||
--> Jon 10
|
||||
--> Max 11
|
||||
--> Robin 8
|
||||
|
||||
-- this uses an custom sorting function ordering by score descending
|
||||
for k,v in spairs(HighScore, function(t,a,b) return t[b] < t[a] end) do
|
||||
print(k,v)
|
||||
end
|
||||
--> Max 11
|
||||
--> Jon 10
|
||||
--> Robin 8]],
|
||||
See_Also = [[]],
|
||||
Reference = [[Code copied from http://stackoverflow.com/questions/15706270/sort-a-table-in-lua]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
-- Sort a table
|
||||
function dtutils.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
|
||||
|
||||
-- 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
|
||||
|
||||
-- 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
|
||||
|
||||
dtutils.libdoc.functions["check_os"] = {
|
||||
Name = [[check_os]],
|
||||
Synopsis = [[check that the operating system is supported]],
|
||||
Usage = [[local du = require "lib/dtutils"
|
||||
|
||||
local result = du.check_os(operating_systems)
|
||||
operating_systems - a table of operating system names such as {"windows","linux","macos","unix"}]],
|
||||
Description = [[check_os checks a supplied table of operating systems against the operating system the
|
||||
script is running on and returns true if the OS is in the list, otherwise false]],
|
||||
Return_Value = [[result - boolean - true if the operating system is supported, false if not.]],
|
||||
Limitations = [[]],
|
||||
Example = [[local du = require "lib/dtutils"
|
||||
if du.check_os({"windows"}) then
|
||||
-- run the script
|
||||
else
|
||||
dt.print("Script <script name> only runs on windows")
|
||||
return
|
||||
end]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils.check_os(operating_systems)
|
||||
for _,os in pairs(operating_systems) do
|
||||
if dt.configuration.running_os == os then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
dtutils.libdoc.functions["find_image_by_id"] = {
|
||||
Name = [[find_image_by_id]],
|
||||
Synopsis = [[look up an image by ID in the database]],
|
||||
Usage = [[local du = require "lib/dtutils"
|
||||
local img = du.find_image_by_id(imgid)
|
||||
id - int - the ID to look up
|
||||
]],
|
||||
Description = [[find_image_by_id looks up an image by ID in the database.]],
|
||||
Return_Value = [[result - dt_lua_image_t - image with the given ID if found, nil if not]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils.find_image_by_id(imgid)
|
||||
if #dt.database == 0 or imgid > dt.database[#dt.database].id then
|
||||
return nil
|
||||
end
|
||||
if dt.configuration.api_version_string >= "6.2.0" then
|
||||
return dt.database.get_image(imgid)
|
||||
else
|
||||
local min = 1
|
||||
local max = #dt.database
|
||||
while (max-min)//2 > 0 do
|
||||
local mid = min + (max-min)//2
|
||||
local midID = dt.database[mid].id
|
||||
if imgid == midID then
|
||||
return dt.database[mid]
|
||||
elseif imgid < midID then
|
||||
max = mid-1
|
||||
else
|
||||
min = mid+1
|
||||
end
|
||||
end
|
||||
if dt.database[min].id == imgid then
|
||||
return dt.database[min]
|
||||
elseif dt.database[max].id == imgid then
|
||||
return dt.database[max]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
dtutils.libdoc.functions["deprecated"] = {
|
||||
Name = [[deprecated]],
|
||||
Synopsis = [[print deprecation warning]],
|
||||
Usage = [[local du = require "lib/dtutils"
|
||||
|
||||
du.deprecated(script_name, removal_string)
|
||||
script_name - name of the script being deprecated
|
||||
removal_string - a string explaining when the script will be removed]],
|
||||
Description = [[deprecated prints an error message saying the script is deprecated and when it will be removed]],
|
||||
Return_Value = [[]],
|
||||
Limitations = [[]],
|
||||
Example = [[local du = require "lib/dtutils"
|
||||
du.deprecated("contrib/rename-tags.lua", "darktable release 4.0")]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils.deprecated(script_name, removal_string)
|
||||
dt.print_toast("WARNING: " .. script_name .. " is deprecated and will be removed in " .. removal_string)
|
||||
dt.print_error("WARNING: " .. script_name .. " is deprecated and will be removed in " .. removal_string)
|
||||
end
|
||||
|
||||
dtutils.libdoc.functions["gen_uuid"] = {
|
||||
Name = [[gen_uuid]],
|
||||
Synopsis = [[generate a UUID string]],
|
||||
Usage = [[local du = require "lib/dtutils"
|
||||
|
||||
uuid = du.gen_uuid(case)
|
||||
case - "upper" or "lower" to specify the case of the UUID string]],
|
||||
Description = [[gen_uuid prints an error message saying the script is gen_uuid and when it will be removed]],
|
||||
Return_Value = [[uuid - string - a hexidecimal string representing the UUID in the requested case]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[https://gist.github.com/jrus/3197011]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils.gen_uuid(case)
|
||||
local template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
|
||||
|
||||
-- seed with os.time in seconds and add an extra degree of random for multiple calls in the same second
|
||||
math.randomseed(os.time(), math.random(0, 65536))
|
||||
|
||||
local uuid = string.gsub(template, '[xy]', function (c)
|
||||
local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb)
|
||||
return string.format('%x', v)
|
||||
end
|
||||
)
|
||||
|
||||
if case and case == "upper" then
|
||||
uuid = string.upper(uuid)
|
||||
end
|
||||
|
||||
return uuid
|
||||
end
|
||||
|
||||
dtutils.libdoc.functions["compare_api_versions"] = {
|
||||
Name = [[compare_api_versions]],
|
||||
Synopsis = [[compare two API version strings]],
|
||||
Usage = [[local du = require "lib/dtutils"
|
||||
|
||||
local result = du.compare_api_versions(version1, version2)
|
||||
version1 - string - the first version string to compare (example: "5.0.0")
|
||||
version2 - string - the second version string to compare (example: "5.1.0")]],
|
||||
Description = [[compare_api_versions compares two version strings and returns 1 if version1 is greater,
|
||||
-1 if version2 is greater, and 0 if they are equal.]],
|
||||
Return_Value = [[result - 1 if version1 is greater, -1 if version2 is greater, 0 if they are equal.]],
|
||||
Limitations = [[]],
|
||||
Example = [[compare_api_versions("5.0.0", "5.1.0") returns -1]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils.compare_api_versions(version1, version2)
|
||||
local v1 = {}
|
||||
for num in version1:gmatch("%d+") do table.insert(v1, tonumber(num)) end
|
||||
local v2 = {}
|
||||
for num in version2:gmatch("%d+") do table.insert(v2, tonumber(num)) end
|
||||
|
||||
for i = 1, math.max(#v1, #v2) do
|
||||
local num1 = v1[i] or 0
|
||||
local num2 = v2[i] or 0
|
||||
if num1 > num2 then
|
||||
return 1
|
||||
elseif num1 < num2 then
|
||||
return -1
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
return dtutils
|
||||
161
lib/dtutils/debug.lua
Normal file
161
lib/dtutils/debug.lua
Normal file
@@ -0,0 +1,161 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
Copyright (c) 2014 Jérémy Rosen
|
||||
Copyright (c) 2016 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/>.
|
||||
]]
|
||||
--[[
|
||||
DEBUG HELPERS
|
||||
A collection of helper functions to help debugging lua scripts.
|
||||
|
||||
require it as
|
||||
|
||||
dhelpers = require "lib/dtutils.debug"
|
||||
|
||||
Each function is documented in its own header
|
||||
|
||||
|
||||
]]
|
||||
|
||||
|
||||
local dt = require "darktable"
|
||||
local io = require "io"
|
||||
local table = require "table"
|
||||
require "darktable.debug"
|
||||
local log = require "lib/dtutils.log"
|
||||
local M = {} -- The actual content of the module
|
||||
|
||||
M.libdoc = {
|
||||
Name = [[dtutils.debug]],
|
||||
Synopsis = [[debugging helpers used in developing darktable lua scripts]],
|
||||
Usage = [[local dd = require "lib/dtutils.debug"]],
|
||||
Description = [[dtutils.debug provides an interface to the darktable debugging routines.]],
|
||||
Return_Value = [[dd - library - the darktable lua debugging helpers]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = log.libdoc.License,
|
||||
Copyright = [[Copyright (c) 2014 Jérémy Rosen
|
||||
Copyright (c) 2016 Bill Ferguson
|
||||
]],
|
||||
functions = {}
|
||||
}
|
||||
|
||||
M.libdoc.functions["tracepoint"] = {
|
||||
Name = [[tracepoint]],
|
||||
Synopsis = [[print out a tracepoint and dump the arguments]],
|
||||
Usage = [[local dd = require "lib/dtutils.debug"
|
||||
|
||||
local result = tracepoint(name, ...)
|
||||
name - string - the name of the tracepoint to print out
|
||||
... - arguments - variables to dump the contents of]],
|
||||
Description = [[tracepoint prints its name and dumps its parameters using
|
||||
dt.debug]],
|
||||
Return_Value = [[result - ... - the supplied argument list]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function M.tracepoint(name,...)
|
||||
log.msg(log.always, 4, "***** "..name.." ****")
|
||||
params = {...}
|
||||
log.msg(log.always, 0, dt.debug.dump(params,"parameters"))
|
||||
return ...;
|
||||
end
|
||||
|
||||
M.libdoc.functions["new_tracepoint"] = {
|
||||
Name = [[new_tracepoint]],
|
||||
Synopsis = [[create a function returning a tracepoint]],
|
||||
Usage = [[local dd = require "lib/dtutils.debug"
|
||||
|
||||
local result = new_tracepoint(name, ...)
|
||||
name - string - the name of the tracepoint to print out
|
||||
... - arguments - variables to dump the contents of]],
|
||||
Description = [[A function that returns a tracepoint function with the given name
|
||||
This is mainly used to debug callbacks.]],
|
||||
Return_Value = [[result - function - a function that returns the result of a tracepoint]],
|
||||
Limitations = [[]],
|
||||
Example = [[register_event(event, dd.new_tracepoint("hit callback"))
|
||||
|
||||
will print the following each time the callback is called
|
||||
|
||||
**** hit callback ****
|
||||
<all the callback's parameters dumped>]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function M.new_tracepoint(name)
|
||||
return function(...) return M.tracepoint(name,...) end
|
||||
end
|
||||
|
||||
|
||||
M.libdoc.functions["dprint"] = {
|
||||
Name = [[dprint]],
|
||||
Synopsis = [[pass a variable to dt.debug.dump and print the results to stdout]],
|
||||
Usage = [[local dd = require "lib/dtutils.debug"
|
||||
|
||||
dd.dprint(var)
|
||||
var - variable - any variable that you want to see the contents of]],
|
||||
Description = [[Wrapper around debug.dump, will directly print to stdout,
|
||||
same calling convention]],
|
||||
Return_Value = [[]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function M.dprint(...)
|
||||
log.msg(log.always, 4, dt.debug.dump(...))
|
||||
end
|
||||
|
||||
M.libdoc.functions["terse_dump"] = {
|
||||
Name = [[terse_dump]],
|
||||
Synopsis = [[set dt.debug.known to shorten all image dumps to a single line]],
|
||||
Usage = [[local dd = require "lib/dtutils.debug"
|
||||
|
||||
dd.terse_dump()]],
|
||||
Description = [[terse_dump sets dt.debug.known to shorten all images to a single line.
|
||||
If you don't need to debug the content of images, this will avoid them flooding your logs]],
|
||||
Return_Value = [[]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function M.terse_dump()
|
||||
for _,v in ipairs(dt.database) do
|
||||
dt.debug.known[v] = tostring(v)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
return M
|
||||
-- vim: shiftwidth=2 expandtab tabstop=2 cindent
|
||||
-- kate: tab-indents: off; indent-width 2; replace-tabs on; remove-trailing-space on;
|
||||
890
lib/dtutils/file.lua
Normal file
890
lib/dtutils/file.lua
Normal file
@@ -0,0 +1,890 @@
|
||||
local dtutils_file = {}
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
local ds = require "lib/dtutils.string"
|
||||
local dsys = require "lib/dtutils.system"
|
||||
|
||||
local log = require "lib/dtutils.log"
|
||||
|
||||
dtutils_file.libdoc = {
|
||||
Name = [[dtutils.file]],
|
||||
Synopsis = [[common darktable lua file functions]],
|
||||
Usage = [[local df = require "lib/dtutils.file"]],
|
||||
Description = [[[dtutils.file provides common file manipulation functions used in
|
||||
constructing Darktable lua scripts]],
|
||||
Return_Value = [[df - library - the file functions]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = log.libdoc.License,
|
||||
Copyright = [[Copyright (C) 2016 Bill Ferguson <wpferguson@gmail.com>.]],
|
||||
Copyright = [[Copyright (C) 2016 Bill Ferguson <wpferguson@gmail.com>.
|
||||
Copyright (C) 2016 Tobias Jakobs]],
|
||||
functions = {}
|
||||
}
|
||||
|
||||
local gettext = dt.gettext.gettext
|
||||
|
||||
du.check_min_api_version("5.0.0", "dtutils.file")
|
||||
|
||||
local function _(msgid)
|
||||
return gettext(msgid)
|
||||
end
|
||||
|
||||
--[[
|
||||
local function to run a test command on windows and return a true if it succeeds
|
||||
instead of returning true if it runs
|
||||
]]
|
||||
|
||||
local function _win_os_execute(cmd)
|
||||
local result = nil
|
||||
local p = io.popen(cmd)
|
||||
local output = p:read("*a")
|
||||
p:close()
|
||||
if string.match(output, "true") then
|
||||
result = true
|
||||
else
|
||||
result = false
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
--[[
|
||||
local function to determine if a path name is a windows executable
|
||||
]]
|
||||
|
||||
local function _is_windows_executable(path)
|
||||
local result = false
|
||||
if dtutils_file.test_file(path, "f") then
|
||||
if string.match(path, ".exe$") or string.match(path, ".EXE$") or
|
||||
string.match(path, ".com$") or string.match(path, ".COM$") or
|
||||
string.match(path, ".bat$") or string.match(path, ".BAT$") or
|
||||
string.match(path, ".cmd$") or string.match(path, ".CMD$") then
|
||||
result = true
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
dtutils_file.libdoc.functions["test_file"] = {
|
||||
Name = [[test_file]],
|
||||
Synopsis = [[test a file to see what it is]],
|
||||
Usage = [[local df = require "lib/dtutils.file"
|
||||
|
||||
local result = df.test_file(path, test)
|
||||
path - string - the path to check
|
||||
test - one of d, e, f, x where
|
||||
d - directory
|
||||
e - exists
|
||||
f - file
|
||||
x - executable]],
|
||||
Description = [[test_file checks a path to see if it is a directory]],
|
||||
Return_Value = [[result - boolean - true if path is a directory, nil if not]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_file.test_file(path, test)
|
||||
local cmd = "test -"
|
||||
local engine = os.execute
|
||||
local cmdstring = ""
|
||||
|
||||
if dt.configuration.running_os == "windows" then
|
||||
cmd = "if exist "
|
||||
engine = _win_os_execute
|
||||
end
|
||||
|
||||
if test == "d" then
|
||||
-- test if directory
|
||||
if dt.configuration.running_os == "windows" then
|
||||
cmdstring = cmd .. dtutils_file.sanitize_filename(path .. "\\*") .. " echo true"
|
||||
else
|
||||
cmdstring = cmd .. test .. " " .. dtutils_file.sanitize_filename(path)
|
||||
end
|
||||
elseif test == "e" then
|
||||
-- test exists
|
||||
if dt.configuration.running_os == "windows" then
|
||||
cmdstring = cmd .. dtutils_file.sanitize_filename(path) .. " echo true"
|
||||
else
|
||||
cmdstring = cmd .. test .. " " .. dtutils_file.sanitize_filename(path)
|
||||
end
|
||||
elseif test == "f" then
|
||||
-- test if file
|
||||
if dt.configuration.running_os == "windows" then
|
||||
if not dtutils_file.test_file(path, "d") then -- make sure it's not a directory
|
||||
cmdstring = cmd .. dtutils_file.sanitize_filename(path) .. " echo true"
|
||||
else
|
||||
return false
|
||||
end
|
||||
else
|
||||
cmdstring = cmd .. test .. " " .. dtutils_file.sanitize_filename(path)
|
||||
end
|
||||
elseif test == "x" then
|
||||
-- test executable
|
||||
if dt.configuration.running_os == "windows" then
|
||||
return _is_windows_executable(path)
|
||||
else
|
||||
cmdstring = cmd .. test .. " " .. dtutils_file.sanitize_filename(path)
|
||||
end
|
||||
else
|
||||
dt.print_error("[test_file] unknown test " .. test)
|
||||
return false
|
||||
end
|
||||
|
||||
return engine(cmdstring)
|
||||
end
|
||||
|
||||
--[[
|
||||
local function to return a case insensitive pattern for matching
|
||||
i.e. gimp becomes [Gg][Ii][Mm][Pp] which should match any capitalization
|
||||
of gimp.
|
||||
]]
|
||||
|
||||
local function _case_insensitive_pattern(pattern)
|
||||
return pattern:gsub("(.)", function(letter)
|
||||
return string.format("[%s$s]", letter:lower(), letter:upper())
|
||||
end)
|
||||
end
|
||||
|
||||
--[[
|
||||
local function to search windows for an executable
|
||||
]]
|
||||
|
||||
local function _search_for_bin_windows(bin)
|
||||
local result = false
|
||||
-- use where on path
|
||||
-- use where on program files
|
||||
-- use where on program files (x86)
|
||||
local args = {"", '/R "C:\\Program Files"', '/R "C:\\Program Files (x86)"'}
|
||||
|
||||
for _,arg in ipairs(args) do
|
||||
local cmd = "where " .. arg .. " " .. ds.sanitize(bin)
|
||||
local p = io.popen(cmd)
|
||||
local output = p:read("*a")
|
||||
p:close()
|
||||
local lines = du.split(output, "\n")
|
||||
local cibin = _case_insensitive_pattern(bin)
|
||||
for _,line in ipairs(lines) do
|
||||
if string.match(line, cibin) then
|
||||
dt.print_log("found win search match " .. line)
|
||||
if dtutils_file.test_file(line, "f") and dtutils_file.test_file(line, "x") then
|
||||
dtutils_file.set_executable_path_preference(bin, line) -- save it so we don't have to search again
|
||||
return line
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
--[[
|
||||
local function to search *nix systems for an executable
|
||||
]]
|
||||
|
||||
local function _search_for_bin_nix(bin)
|
||||
local result = false
|
||||
local p = io.popen("command -v " .. bin)
|
||||
local output = p:read("*a")
|
||||
p:close()
|
||||
if string.len(output) > 0 then
|
||||
local spath = dtutils_file.sanitize_filename(output:sub(1, -2))
|
||||
if dtutils_file.test_file(spath, "f") and dtutils_file.test_file(spath, "x") then
|
||||
dtutils_file.set_executable_path_preference(bin, spath)
|
||||
result = spath
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
--[[
|
||||
local function to search macos systems for an executable
|
||||
]]
|
||||
|
||||
local function _search_for_bin_macos(bin)
|
||||
local result = false
|
||||
|
||||
result = _search_for_bin_nix(bin) -- see if it's in the path
|
||||
|
||||
if not result then
|
||||
local search_start = "/Applications"
|
||||
|
||||
if dtutils_file.check_if_file_exists("/Applications/" .. bin .. ".app") then
|
||||
search_start = "/Applications/" .. bin .. ".app"
|
||||
end
|
||||
|
||||
local p = io.popen("find " .. search_start .. " -type f -name " .. bin .. " -print")
|
||||
local output = p:read("*a")
|
||||
p:close()
|
||||
local lines = du.split(output, "\n")
|
||||
|
||||
for _,line in ipairs(lines) do
|
||||
local spath = dtutils_file.sanitize_filename(line:sub(1, -1))
|
||||
if dtutils_file.test_file(spath, "x") then
|
||||
dtutils_file.set_executable_path_preference(bin, spath) -- save it so we don't have to search again
|
||||
result = spath
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
--[[
|
||||
local function to provide a generic search call that can be
|
||||
split into operating system specific calls
|
||||
]]
|
||||
|
||||
local function _search_for_bin(bin)
|
||||
local result = false
|
||||
|
||||
if dt.configuration.running_os == "windows" then
|
||||
result = _search_for_bin_windows(bin)
|
||||
if result then
|
||||
result = dtutils_file.sanitize_filename(result)
|
||||
end
|
||||
elseif dt.configuration.running_os == "macos" then
|
||||
result = _search_for_bin_macos(bin)
|
||||
else
|
||||
result = _search_for_bin_nix(bin)
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
--[[
|
||||
local function to check if an executable path is
|
||||
a windows executable on linux or macos, thus requiring wine to run
|
||||
]]
|
||||
|
||||
local function _check_path_for_wine_bin(path)
|
||||
local result = false
|
||||
|
||||
if string.len(path) > 0 then
|
||||
-- check for windows executable to run under wine
|
||||
if _is_windows_executable(path) then
|
||||
if dtutils_file.check_if_file_exists(path) then
|
||||
result = "wine " .. dtutils_file.sanitize_filename(path)
|
||||
end
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
--[[
|
||||
local function to check if an executable path is
|
||||
a valid executable. Some generic checks are done before
|
||||
system specific checks are done.
|
||||
]]
|
||||
|
||||
local function _check_path_for_bin(bin)
|
||||
local result = false
|
||||
local path = nil
|
||||
|
||||
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
|
||||
|
||||
if string.match(bin, PS) then
|
||||
path = bin
|
||||
else
|
||||
path = dtutils_file.get_executable_path_preference(bin)
|
||||
-- reset path preference is the returned preference is a directory
|
||||
if dtutils_file.test_file(path, "d") then
|
||||
dtutils_file.set_executable_path_preference(bin, "")
|
||||
path = nil
|
||||
end
|
||||
end
|
||||
|
||||
if path and dtutils_file.test_file(path, "d") then
|
||||
path = nil
|
||||
end
|
||||
|
||||
if path and dt.configuration.running_os ~= "windows" then
|
||||
result = _check_path_for_wine_bin(path)
|
||||
end
|
||||
|
||||
if path and not result then
|
||||
if dtutils_file.test_file(path, "x") then
|
||||
result = dtutils_file.sanitize_filename(path)
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
--[[
|
||||
local function to the old check_if_bin_exists functionality
|
||||
on windows in order to decrease the amount of windows being
|
||||
created and destroyed by system calls.
|
||||
]]
|
||||
|
||||
local function _old_check_if_bin_exists(bin) -- only run on windows if preference checked
|
||||
local result = false
|
||||
local path = nil
|
||||
|
||||
if string.match(bin, "\\") then
|
||||
|
||||
path = bin
|
||||
else
|
||||
path = dtutils_file.get_executable_path_preference(bin)
|
||||
end
|
||||
|
||||
if string.len(path) > 0 then
|
||||
if dtutils_file.check_if_file_exists(path) then
|
||||
if (string.match(path, ".exe$") or string.match(path, ".EXE$")) then
|
||||
result = dtutils_file.sanitize_filename(path)
|
||||
end
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
dtutils_file.libdoc.functions["check_if_bin_exists"] = {
|
||||
Name = [[check_if_bin_exists]],
|
||||
Synopsis = [[check if an executable exists]],
|
||||
Usage = [[local df = require "lib/dtutils.file"
|
||||
|
||||
local result = df.check_if_bin_exists(bin)
|
||||
bin - string - the binary to check for]],
|
||||
Description = [[check_if_bin_exists checks to see if the specified binary exists.
|
||||
check_if_bin_exists first checks to see if a preference for the binary has been
|
||||
registered and uses that if found, after it's verified to be an executable and
|
||||
exist. If no preference exissts, the user's path is checked for the executable.
|
||||
If the executable is not found in the users path, then a search of the operating
|
||||
system is conducted to see if the executable can be found.
|
||||
|
||||
If an executalble is found, it's verified to exist and be an executable. Once
|
||||
the executable is verified, the path is saved as a preference to speed up
|
||||
subsequent checks. The executable path is sanitized and returned.
|
||||
|
||||
If no executable is found, false is returned.]],
|
||||
Return_Value = [[result - string - the sanitized path of the binary, false if not found]],
|
||||
Limitations = [[If more than one executable that satisfies the search results is found, the
|
||||
wrong one may be returned. If the wrong value is returned, the user can still specify the
|
||||
correct execuable using tools/executable_manager. Most packages are well behaved with the
|
||||
notiable exception being GIMP on windows. Depending on the packager there are multiple
|
||||
gimp executables, often with version numbers. In this case, the user needs to specify
|
||||
the location of the correct executable using executable_manager.]],
|
||||
Example = [[]],
|
||||
See_Also = [[executable_manager]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_file.check_if_bin_exists(bin)
|
||||
local result = false
|
||||
|
||||
if dt.configuration.running_os == "windows" and dt.preferences.read("dtutils.file", "use_old_check_if_bin_exists", "bool") then
|
||||
result = _old_check_if_bin_exists(bin)
|
||||
else
|
||||
|
||||
result = _check_path_for_bin(bin)
|
||||
|
||||
if not result then
|
||||
result = _search_for_bin(bin)
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
-- the following path, filename, etc functions have
|
||||
-- moved to the string library since they are string
|
||||
-- manipulation functions, and to prevent circular
|
||||
-- library inclusiion.
|
||||
|
||||
-- these functions are left here for compatibility
|
||||
-- with older scripts
|
||||
|
||||
function dtutils_file.split_filepath(str)
|
||||
return ds.split_filepath(str)
|
||||
end
|
||||
|
||||
function dtutils_file.get_path(str)
|
||||
return ds.get_path(str)
|
||||
end
|
||||
|
||||
function dtutils_file.get_filename(str)
|
||||
return ds.get_filename(str)
|
||||
end
|
||||
|
||||
function dtutils_file.get_basename(str)
|
||||
return ds.get_basename(str)
|
||||
end
|
||||
|
||||
function dtutils_file.get_filetype(str)
|
||||
return ds.get_filetype(str)
|
||||
end
|
||||
|
||||
|
||||
-- Thanks Tobias Jakobs for the idea
|
||||
dtutils_file.libdoc.functions["check_if_file_exists"] = {
|
||||
Name = [[check_if_file_exists]],
|
||||
Synopsis = [[check if a file or path exist]],
|
||||
Usage = [[local df = require "lib/dtutils.file"
|
||||
|
||||
local result = df.check_if_file_exists(filepath)
|
||||
filepath - string - a file or path to check]],
|
||||
Description = [[check_if_file_exists checks to see if a file or path exists]],
|
||||
Return_Value = [[result - boolean - true if the file or path exists, false if it doesn't]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_file.check_if_file_exists(filepath)
|
||||
local result = false
|
||||
if (dt.configuration.running_os == 'windows') then
|
||||
filepath = string.gsub(filepath, '[\\/]+', '\\')
|
||||
local p = io.popen("if exist " .. dtutils_file.sanitize_filename(filepath) .. " (echo 'yes') else (echo 'no')")
|
||||
local ans = p:read("*all")
|
||||
p:close()
|
||||
if string.match(ans, "yes") then
|
||||
result = true
|
||||
end
|
||||
-- result = os.execute('if exist "'..filepath..'" (cmd /c exit 0) else (cmd /c exit 1)')
|
||||
-- if not result then
|
||||
-- result = false
|
||||
-- end
|
||||
elseif (dt.configuration.running_os == "linux") then
|
||||
result = os.execute('test -e ' .. dtutils_file.sanitize_filename(filepath))
|
||||
if not result then
|
||||
result = false
|
||||
end
|
||||
else
|
||||
local file = io.open(filepath, "r")
|
||||
if file then
|
||||
result = true
|
||||
file:close()
|
||||
else
|
||||
result = false
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
dtutils_file.libdoc.functions["chop_filetype"] = {
|
||||
Name = [[chop_filetype]],
|
||||
Synopsis = [[remove a filetype from a filename]],
|
||||
Usage = [[local df = require "lib/dtutils.file"
|
||||
|
||||
local result = df.chop_filetype(path)
|
||||
path - string - a filename with or without a path]],
|
||||
Description = [[chop_filetype removes the filetype from the filename]],
|
||||
Return_Value = [[result - string - the path and filename without the filetype]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_file.chop_filetype(path)
|
||||
local length = dtutils_file.get_filetype(path):len() + 2
|
||||
if length > 2 then
|
||||
return string.sub(path, 1, -length)
|
||||
else
|
||||
return path
|
||||
end
|
||||
end
|
||||
|
||||
dtutils_file.libdoc.functions["file_copy"] = {
|
||||
Name = [[file_copy]],
|
||||
Synopsis = [[copy a file to another name/location]],
|
||||
Usage = [[local df = require "lib/dtutils.file"
|
||||
|
||||
local result = df.file_copy(fromFile, toFile)
|
||||
fromFile - string - name of file to copy from
|
||||
toFile - string - name of file to copy to]],
|
||||
Description = [[copy a file using a succession of methods from operating system
|
||||
to a pure lua solution]],
|
||||
Return_Value = [[result - boolean - nil on error, true on success]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_file.file_copy(fromFile, toFile)
|
||||
local result = nil
|
||||
-- if cp exists, use it
|
||||
if dt.configuration.running_os == "windows" then
|
||||
result = os.execute('copy ' .. dtutils_file.sanitize_filename(fromFile) .. ' ' .. dtutils_file.sanitize_filename(toFile))
|
||||
elseif dtutils_file.check_if_bin_exists("cp") then
|
||||
result = os.execute("cp " .. dtutils_file.sanitize_filename(fromFile) .. ' ' .. dtutils_file.sanitize_filename(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
|
||||
log.msg(log.error, errr)
|
||||
end
|
||||
else
|
||||
log.msg(log.error, err)
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
dtutils_file.libdoc.functions["file_move"] = {
|
||||
Name = [[file_move]],
|
||||
Synopsis = [[move a file from one directory to another]],
|
||||
Usage = [[local df = require "lib/dtutils.file"
|
||||
|
||||
local result = df.file_move(fromFile, toFile)
|
||||
fromFile - string - name of the original file
|
||||
toFile - string - the new file location and name]],
|
||||
Description = [[Move a file from one place to another. Try a succession of methods from
|
||||
builtin to operating system to a pure lua solution.]],
|
||||
Return_Value = [[result - boolean - nil on error, some value on success]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_file.file_move(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 dtutils_file.check_if_bin_exists("mv") then
|
||||
success = os.execute("mv " .. dtutils_file.sanitize_filename(fromFile) .. ' ' .. dtutils_file.sanitize_filename(toFile))
|
||||
end
|
||||
-- if the mv didn't exist or succeed, then...
|
||||
if not success then
|
||||
-- pure lua solution
|
||||
success = dtutils_file.file_copy(fromFile, toFile)
|
||||
if success then
|
||||
os.remove(fromFile)
|
||||
else
|
||||
log.msg(log.error, "Unable to move " .. fromFile .. " to " .. toFile .. ". Leaving " .. fromFile .. " in place.")
|
||||
end
|
||||
end
|
||||
end
|
||||
return success -- nil on error, some value if success
|
||||
end
|
||||
|
||||
dtutils_file.libdoc.functions["filename_increment"] = {
|
||||
Name = [[filename_increment]],
|
||||
Synopsis = [[add a two digit increment to a filename]],
|
||||
Usage = [[local df = require "lib/dtutils.file"
|
||||
|
||||
local result = df.filename_increment(filepath)
|
||||
filepath - string - filename to increment]],
|
||||
Description = [[filename_increment solves the problem of filename confllict by adding an
|
||||
increment to the filename. If the supplied filename has no increment then
|
||||
"01" is added to the basename. If the filename already has an increment, then
|
||||
1 is added to it and the filename returned.]],
|
||||
Return_Value = [[result - string - the incremented filename]],
|
||||
Limitations = [[The filename will be incremented to 99]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_file.filename_increment(filepath)
|
||||
|
||||
-- break up the filepath into parts
|
||||
local path = dtutils_file.get_path(filepath)
|
||||
local basename = dtutils_file.get_basename(filepath)
|
||||
local filetype = dtutils_file.get_filetype(filepath)
|
||||
|
||||
-- check to see if we've incremented before
|
||||
local increment = string.match(basename, "_(%d-)$")
|
||||
|
||||
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"
|
||||
elseif increment == "99" then
|
||||
dt.print_error("not incrementing, filename has already been incremented 99 times.")
|
||||
return filepath
|
||||
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
|
||||
|
||||
return incremented_filepath
|
||||
end
|
||||
|
||||
|
||||
dtutils_file.libdoc.functions["create_unique_filename"] = {
|
||||
Name = [[create_unique_filename]],
|
||||
Synopsis = [[create a unique filename from the supplied argment]],
|
||||
Usage = [[local df = require "lib/dtutils.file"
|
||||
|
||||
local result = df.create_unique_filename(filepath)
|
||||
filepath - string - the path and filename requested]],
|
||||
Description = [[create_unique_filename takes a requested filepath and checks to see if
|
||||
it exists. If if doesn't then it's returned intact. If it already exists, then a two
|
||||
digit increment is added to the filename and it is tested again. The increment keeps
|
||||
increasing until either a unique filename is found or there have been 100 attempts.]],
|
||||
Return_Value = [[result - string - the incremented filename]],
|
||||
Limitations = [[create_unique_filename will only attempt 100 increments.]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_file.create_unique_filename(filepath)
|
||||
while dtutils_file.check_if_file_exists(filepath) do
|
||||
filepath = dtutils_file.filename_increment(filepath)
|
||||
-- limit to 99 more exports of the original export
|
||||
local increment = string.match(dtutils_file.get_basename(filepath), "_(%d-)$")
|
||||
if increment == "99" then
|
||||
break
|
||||
end
|
||||
end
|
||||
return filepath
|
||||
end
|
||||
|
||||
|
||||
dtutils_file.libdoc.functions["set_executable_path_preference"] = {
|
||||
Name = [[set_executable_path_preference]],
|
||||
Synopsis = [[set a preference for the path to an executable]],
|
||||
Usage = [[local df = require "lib/dtutils.file"
|
||||
|
||||
df.set_executable_path_preference(executable, path)
|
||||
executable - string - the name of the executable to set the path for
|
||||
path - string - the path to the binary]],
|
||||
Description = [[set_executable_path_preference takes an executable name and path to the
|
||||
executable and registers the preference for later use.]],
|
||||
Return_Value = [[]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_file.set_executable_path_preference(executable, path)
|
||||
dt.preferences.write("executable_paths", executable, "string", path)
|
||||
end
|
||||
|
||||
|
||||
dtutils_file.libdoc.functions["get_executable_path_preference"] = {
|
||||
Name = [[get_executable_path_preference]],
|
||||
Synopsis = [[return the path to an executable from a preference]],
|
||||
Usage = [[local df = require "lib/dtutils.file"
|
||||
|
||||
local result = df.get_executable_path_preference(executable)
|
||||
executable - string - the name of the executable to get the path for]],
|
||||
Description = [[get_executable_path_preference returns the path preference to
|
||||
the requested executable.]],
|
||||
Return_Value = [[result - string - path to the executable]],
|
||||
Limitations = [[executable should be the basename of the executable without extensions]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_file.get_executable_path_preference(executable)
|
||||
return dt.preferences.read("executable_paths", executable, "string")
|
||||
end
|
||||
|
||||
|
||||
dtutils_file.libdoc.functions["executable_path_widget"] = {
|
||||
Name = [[executable_path_widget]],
|
||||
Synopsis = [[create a widget to get executable path preferences]],
|
||||
Usage = [[local df = require "lib/dtutils.file"
|
||||
|
||||
local widget = df.executable_path_widget(executables)
|
||||
executables - table - a table of strings that are executable names]],
|
||||
Description = [[executable_path_widget takes a table of executable names
|
||||
and builds a set of file selector widgets to get the path to the executable.
|
||||
The resulting widgets are wrapped in a box widget and returned.]],
|
||||
Return_Value = [[widget - widget - a widget containing a file selector widget for
|
||||
each executable.]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_file.executable_path_widget(executables)
|
||||
local box_widgets = {}
|
||||
table.insert(box_widgets, dt.new_widget("section_label"){label = "select executable(s)"})
|
||||
for _, executable in pairs(executables) do
|
||||
table.insert(box_widgets, dt.new_widget("label"){label = "select " .. executable .. " executable"})
|
||||
local path = dtutils_file.get_executable_path_preference(executable)
|
||||
if not path then
|
||||
path = ""
|
||||
end
|
||||
table.insert(box_widgets, dt.new_widget("file_chooser_button"){
|
||||
title = "select " .. executable .. " executable",
|
||||
value = path,
|
||||
is_directory = false,
|
||||
changed_callback = function(self)
|
||||
if dtutils_file.check_if_bin_exists(self.value) then
|
||||
dtutils_file.set_executable_path_preference(executable, self.value)
|
||||
end
|
||||
end
|
||||
}
|
||||
)
|
||||
end
|
||||
local box = dt.new_widget("box"){
|
||||
orientation = "vertical",
|
||||
table.unpack(box_widgets)
|
||||
}
|
||||
return box
|
||||
end
|
||||
|
||||
dtutils_file.libdoc.functions["sanitize_filename"] = {
|
||||
Name = [[sanitize_filename]],
|
||||
Synopsis = [[make a filename safe to pass as an argument]],
|
||||
Usage = [[local df = require "lib/dtutils.file"
|
||||
|
||||
local sanitized_filename = df.sanitize_filename(filename)
|
||||
filename - string - a filepath and filename]],
|
||||
Description = [[sanitize_file places quotes around the filename in an
|
||||
operating system specific manner. The result is safe to pass as
|
||||
an argument to the operating system.]],
|
||||
Return_Value = [[sanitized_filename - string - quoted filename]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_file.sanitize_filename(filename)
|
||||
return ds.sanitize(filename)
|
||||
end
|
||||
|
||||
dtutils_file.libdoc.functions["mkdir"] = {
|
||||
Name = [[mkdir]],
|
||||
Synopsis = [[create the directory(ies) if they do not already exists]],
|
||||
Usage = [[local df = require "lib/dtutils.file"
|
||||
|
||||
df.mkdir(path)
|
||||
path - string - a directory path]],
|
||||
Description = [[mkdir creates directories if not already exists. It
|
||||
create whole parents subtree if needed
|
||||
]],
|
||||
Return_Value = [[path - string - a directory path]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_file.mkdir(path)
|
||||
if not dtutils_file.check_if_file_exists(path) then
|
||||
local mkdir_cmd = dt.configuration.running_os == "windows" and "mkdir" or "mkdir -p"
|
||||
return dsys.external_command(mkdir_cmd.." "..dtutils_file.sanitize_filename(path))
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
dtutils_file.libdoc.functions["rmdir"] = {
|
||||
Name = [[rmdir]],
|
||||
Synopsis = [[recursively remove a directory]],
|
||||
Usage = [[local df = require "lib/dtutils.file"
|
||||
|
||||
df.rmdir(path)
|
||||
path - string - a directory path]],
|
||||
Description = [[rm allow to recursively remove directories]],
|
||||
Return_Value = [[path - string - a directory path]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_file.rmdir(path)
|
||||
local rm_cmd = dt.configuration.running_os == "windows" and "rmdir /S /Q" or "rm -r"
|
||||
return dsys.external_command(rm_cmd.." "..dtutils_file.sanitize_filename(path))
|
||||
end
|
||||
|
||||
dtutils_file.libdoc.functions["create_tmp_file"] = {
|
||||
Name = [[create_tmp_file]],
|
||||
Synopsis = [[creates a temporary file]],
|
||||
Usage = [[local df = require "lib/dtutils.file
|
||||
|
||||
local result = df.create_tmp_file()]],
|
||||
Description = [[create_tmp_file can be used to create temporary files]],
|
||||
Return_Value = [[result - string - path to the created temporary file.]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_file.create_tmp_file()
|
||||
local tmp_file = os.tmpname()
|
||||
|
||||
local f = io.open(tmp_file, "w")
|
||||
if not f then
|
||||
log.msg(log.error, string.format("Error writing to `%s`", tmp_file))
|
||||
os.remove(tmp_file)
|
||||
return nil
|
||||
end
|
||||
|
||||
return tmp_file
|
||||
end
|
||||
|
||||
--[[
|
||||
The new check_if_bin_exists() does multiple calls to the operating system to check
|
||||
if the file exists and is an executable. On windows, each call to the operating system
|
||||
causes a window to open in order to run the command, then the window closes when the
|
||||
command exits. If the user gets annoyed by the "flickering windows", then they can
|
||||
enable this preference to use the old check_if_bin_exists() that relys on the
|
||||
executable path preferences and doesn't do as many checks.
|
||||
]]
|
||||
|
||||
if dt.configuration.running_os == "windows" then
|
||||
dt.preferences.register("dtutils.file", "use_old_check_if_bin_exists", "bool",
|
||||
"lua scripts use old check_if_bin_exists()",
|
||||
"lessen flickering windows effect when scripts run",
|
||||
false)
|
||||
end
|
||||
|
||||
|
||||
return dtutils_file
|
||||
|
||||
309
lib/dtutils/log.lua
Normal file
309
lib/dtutils/log.lua
Normal file
@@ -0,0 +1,309 @@
|
||||
|
||||
local dtutils_log = {}
|
||||
|
||||
dtutils_log.libdoc = {
|
||||
Name = [[dtutils.log]],
|
||||
Synopsis = [[darktable lua logging library]],
|
||||
Usage = [[local log = require "lib/dtutils.log"]],
|
||||
Description = [[log provides a multi-level logging solution for use with
|
||||
the darktable lua scripts. With this library you can leave log messages
|
||||
scattered through out your code and only turn them on as necessary.]],
|
||||
Return_Value = [[log - library - the darktable lua logging functions]],
|
||||
Limitations = [[]],
|
||||
Example = [[local log = require "lib/dtutils.log"
|
||||
|
||||
local cur_level = log.log_level()
|
||||
log.log_level(log.warn)
|
||||
|
||||
print out warning, error and success messages as code is running
|
||||
|
||||
log.log_level(log.debug)
|
||||
|
||||
print out debugging messages too because this isnt working
|
||||
|
||||
log.log_level(log.info)
|
||||
|
||||
I want to make sure this is working ok
|
||||
|
||||
log.log_level(cur_level)
|
||||
|
||||
reset the logging level back to normal]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[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/>.]],
|
||||
Copyright = [[Copyright (C) 2016 Bill Ferguson <wpferguson@gmail.com>.]],
|
||||
functions = {}
|
||||
}
|
||||
|
||||
local dt = require "darktable"
|
||||
local dt_print_error = dt.print_error
|
||||
local dt_print_log = dt.print_log
|
||||
local dt_print = dt.print
|
||||
|
||||
|
||||
-- set the default log levels
|
||||
|
||||
dtutils_log.debug = {
|
||||
label = "DEBUG: ",
|
||||
enabled = false,
|
||||
engine = dt_print_log,
|
||||
caller_info = 3,
|
||||
level = 1,
|
||||
}
|
||||
dtutils_log.info = {
|
||||
label = "INFO: ",
|
||||
enable = false,
|
||||
engine = dt_print_log,
|
||||
caller_info = 1,
|
||||
level = 2,
|
||||
}
|
||||
dtutils_log.warn = {
|
||||
label = "WARN: ",
|
||||
enabled = false,
|
||||
engine = dt_print_log,
|
||||
caller_info = 2,
|
||||
level = 3,
|
||||
}
|
||||
dtutils_log.error = {
|
||||
label = "ERROR: ",
|
||||
enabled = true,
|
||||
engine = dt_print_log,
|
||||
caller_info = 3,
|
||||
level = 4,
|
||||
}
|
||||
dtutils_log.success = {
|
||||
label = "SUCCESS: ",
|
||||
enabled = true,
|
||||
engine = dt_print_log,
|
||||
caller_info = 2,
|
||||
level = 5,
|
||||
}
|
||||
dtutils_log.screen = {
|
||||
label = "",
|
||||
enabled = true,
|
||||
engine = dt_print,
|
||||
caller_info = 0,
|
||||
level = 9,
|
||||
}
|
||||
dtutils_log.always = {
|
||||
label = "",
|
||||
enabled = true,
|
||||
engine = dt_print_log,
|
||||
caller_info = 3,
|
||||
level = 9,
|
||||
}
|
||||
dtutils_log.critical = {
|
||||
label = "CRITICAL: ",
|
||||
enabled = true,
|
||||
engine = print,
|
||||
caller_info = 3,
|
||||
level = 9,
|
||||
}
|
||||
|
||||
dtutils_log.libdoc.functions["caller"] = {
|
||||
Name = [[caller]],
|
||||
Synopsis = [[get the name and line number of the calling routine]],
|
||||
Usage = [[local log = require "lib/dtutils.log"
|
||||
|
||||
result = log.caller(level)
|
||||
level - number - the number of stack levels to go down to retrieve the caller routine information]],
|
||||
Description = [[caller gets the name and line number of the calling routine and returns it]],
|
||||
Return_Value = [[result - string - the name and line number of the calling function or 'callback: ' if the attempt to get the
|
||||
caller returns nil]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_log.caller(level, info)
|
||||
local name = debug.getinfo(level).name
|
||||
local lineno = nil
|
||||
local source = nil
|
||||
if name then
|
||||
lineno = debug.getinfo(level).currentline
|
||||
-- returns the path to the file prefixed with @
|
||||
source = debug.getinfo(level).source
|
||||
-- we just need the filename, so grab it from the string
|
||||
-- Thanks, Tobias Jakobs :-)
|
||||
source = string.match(source, "@.-([^\\/]-%.?[^%.\\/]*)$")
|
||||
|
||||
if info == 0 then
|
||||
return ""
|
||||
elseif info == 1 then
|
||||
return source .. ": "
|
||||
elseif info == 2 then
|
||||
return source .. ": " .. name .. ": "
|
||||
else
|
||||
return source .. ": " .. name .. ": " .. lineno .. ":"
|
||||
end
|
||||
else
|
||||
return "callback:"
|
||||
end
|
||||
end
|
||||
|
||||
dtutils_log.libdoc.functions["msg"] = {
|
||||
Name = [[msg]],
|
||||
Synopsis = [[print a log message]],
|
||||
Usage = [[local log = require "lib/log"
|
||||
|
||||
log.msg(level, ...)
|
||||
level - table - the type of message, one of:
|
||||
log.debug - debugging messages
|
||||
log.info - informational messages
|
||||
log.warn - warning messages
|
||||
log.error - error messages
|
||||
log.success - success messages
|
||||
log.always - an internal message for debugging
|
||||
log.screen - output 1 line of text to the screen
|
||||
log.critical - print a critical message to the console
|
||||
|
||||
... - string(s) - the message to print, which could be a comma separated set of strings]],
|
||||
Description = [[msg checks the level to see if it is enabled, then prints the level type and message if it is.
|
||||
Messages are output using the engine configured in each log level.]],
|
||||
Return_Value = [[]],
|
||||
Limitations = [[If you use log.msg in a callback, the name of the calling routine can't be determined. A solution
|
||||
is to include some means of reference such as the name of the callback as an argument, i.e.
|
||||
|
||||
log.msg(log.debug, "libPlugin.format_combobox:", "value is " .. self.value)
|
||||
|
||||
which would result in
|
||||
|
||||
DEBUG: callback: libPlugin.format_combobox: value is JPEG]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_log.msg(level, ...)
|
||||
if level.enabled then
|
||||
local args = {...}
|
||||
local call_level = 3
|
||||
if level == dtutils_log.always then
|
||||
call_level = args[1]
|
||||
table.remove(args, 1)
|
||||
end
|
||||
local log_msg = level.label
|
||||
if level.engine ~= dt_print and call_level ~= 0 then
|
||||
log_msg = log_msg .. dtutils_log.caller(call_level, level.caller_info) .. " "
|
||||
elseif log_msg:len() > 2 then
|
||||
log_msg = log_msg .. " "
|
||||
end
|
||||
for i = 1,#args do
|
||||
log_msg = log_msg .. tostring(args[i]) .. " "
|
||||
end
|
||||
level.engine(log_msg)
|
||||
end
|
||||
end
|
||||
|
||||
dtutils_log.libdoc.functions["log_level"] = {
|
||||
Name = [[log_level]],
|
||||
Synopsis = [[get or set the log level]],
|
||||
Usage = [[local log = require "lib/log"
|
||||
|
||||
local result = log.log_level(...)
|
||||
... - arguments - if none is supplied, then the current log level is returned as one of:
|
||||
log.debug, log.info, log.warn, log.error, log.success. If one of log.debug, log.info, log.warn,
|
||||
log.error, or log.success is supplied as the argument then the log level is set to that value. All
|
||||
log levels greater than or equal in value will be enabled. Any levels of lesser value will be disabled.]],
|
||||
Description = [[log_level gets and sets the logging level. When called with no arguments the current log level
|
||||
is returned as one of log.debug, log.info, log.warn, log.error, or log.success. When called with one of log.debug,
|
||||
log.info, log.warn, log.error or log.success then the log level is set. When setting the log level all levels
|
||||
equal or greater are enabled and any of lesser value are disabled. See the example.]],
|
||||
Return_Value = [[result - the log level, one of log.debug, log.info, log.warn, log.error or log.success]],
|
||||
Limitations = [[]],
|
||||
Example = [[Assume that the current log level is log.error. Calling log.log_level() will return log.error.
|
||||
Calling log.log_level(log.info) will leave log.debug disabled, and enable log.info, log.warn, log.error and
|
||||
log.success. log.info will be returned as the log_level.]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_log.log_level(...)
|
||||
local levels = {"debug", "info", "warn", "error", "success"}
|
||||
local args = {...}
|
||||
local log_level = nil
|
||||
if #args > 0 then
|
||||
log_level = args[1]
|
||||
if log_level == dtutils_log.critical or
|
||||
log_level == dtutils_log.screen or
|
||||
log_level == dtutils_log.always then
|
||||
-- these aren't valid for setting levels
|
||||
return nil
|
||||
else
|
||||
for _,v in ipairs(levels) do
|
||||
if dtutils_log[v].level >= log_level.level then
|
||||
dtutils_log[v].enabled = true
|
||||
else
|
||||
dtutils_log[v].enabled = false
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
for _,v in ipairs(levels) do
|
||||
if dtutils_log[v].enabled == true then
|
||||
log_level = dtutils_log[v]
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return log_level
|
||||
end
|
||||
|
||||
dtutils_log.libdoc.functions["engine"] = {
|
||||
Name = [[engine]],
|
||||
Synopsis = [[get and set the output engine]],
|
||||
Usage = [[local log = require "lib/dtutils.log"
|
||||
|
||||
result = log.engine(level, ...)
|
||||
level - table - the log level to get or set the engine for, one of log.debug, log.info, log.warn, log.error
|
||||
log.success, log.always, log.screen, log.critical
|
||||
... - function - the output function, one of dt.print, dt.print_error, dt.print_log, print
|
||||
if not function is included, the current engine is returned for the specified log level]],
|
||||
Description = [[engine returns the output engine for the specified log level if a second argument is not
|
||||
supplied. If a function is supplied as the second argment, then the output engine for the specified log level
|
||||
is set to that.]],
|
||||
Return_Value = [[result - function - the current output engine]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_log.print_engine(level, ...)
|
||||
local engines = {"dt_print", "dt_print_error", "dt_print_log", "print"}
|
||||
local args = {...}
|
||||
local cur_engine = ""
|
||||
if #args == 0 then
|
||||
cur_engine = level.engine
|
||||
else
|
||||
for _,v in ipairs(engines) do
|
||||
if args[1] == v then
|
||||
level.engine = args[1]
|
||||
cur_engine = level.engine
|
||||
end
|
||||
end
|
||||
end
|
||||
return cur_engine
|
||||
end
|
||||
|
||||
return dtutils_log
|
||||
1348
lib/dtutils/string.lua
Normal file
1348
lib/dtutils/string.lua
Normal file
File diff suppressed because it is too large
Load Diff
140
lib/dtutils/system.lua
Normal file
140
lib/dtutils/system.lua
Normal file
@@ -0,0 +1,140 @@
|
||||
local dtutils_system = {}
|
||||
|
||||
local dt = require "darktable"
|
||||
local ds = require "lib/dtutils.string"
|
||||
|
||||
dtutils_system.libdoc = {
|
||||
Name = [[dtutils.system]],
|
||||
Synopsis = [[a library of system utilities for use in darktable lua scripts]],
|
||||
Usage = [[local ds = require "lib/dtutils.system"]],
|
||||
Description = [[This library contains routines for interfacing to the operating system from
|
||||
darktable lua scripts.]],
|
||||
Return_Value = [[du - library - the darktable lua system library]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[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/>.]],
|
||||
Copyright = [[Copyright (c) 2018 Bill Ferguson <wpferguson@gmail.com>]],
|
||||
functions = {}
|
||||
}
|
||||
|
||||
dtutils_system.libdoc.functions["external_command"] = {
|
||||
Name = [[external_command]],
|
||||
Synopsis = [[pass a command to the operating system for execution and return the result]],
|
||||
Usage = [[local dsys = require "lib/dtutils.system"
|
||||
|
||||
local result = dsys.external_command(command)
|
||||
command - string - a string containing the command and arguments to be passed to the operating system for execution.]],
|
||||
Description = [[external_command passes a command to the operating system for execution and returns the results.]],
|
||||
Return_Value = [[result - the return value signalling success or failure.]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_system.external_command(command)
|
||||
local result = nil
|
||||
|
||||
if dt.configuration.running_os == "windows" then
|
||||
result = dtutils_system.windows_command(command)
|
||||
else
|
||||
result = dt.control.execute(command)
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
dtutils_system.libdoc.functions["windows_command"] = {
|
||||
Name = [[windows_command]],
|
||||
Synopsis = [[pass a command to the windows operating system for execution and return the result]],
|
||||
Usage = [[local dsys = require "lib/dtutils.system"
|
||||
|
||||
local result = dsys.windows_command(command)
|
||||
command - string - a string containing the command and arguments to be passed to the operating system for execution.]],
|
||||
Description = [[The normal method of executing an operating system command is using dt.control.execute(), but that doesn't
|
||||
work with Windows when more than one item in the command is quoted. In order to ensure command execution on Windows we
|
||||
create a batch file in the temporary directory, put the command in it, execute the batch file, then return the result.]],
|
||||
Return_Value = [[result - the return value signalling success or failure.]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_system.windows_command(command)
|
||||
local result = 1
|
||||
|
||||
local fname = dt.configuration.tmp_dir .. "/run_command.bat"
|
||||
|
||||
local file = io.open(fname, "w")
|
||||
if file then
|
||||
dt.print_log("opened file")
|
||||
file:write("@echo off\n")
|
||||
file:write('for /f "tokens=2 delims=:." %%x in (\'chcp\') do set cp=%%x\n')
|
||||
file:write("chcp 65001>nul\n") -- change the encoding of the terminal to handle non-english characters in path
|
||||
file:write("\n")
|
||||
file:write(command .. "\n")
|
||||
file:write("set COMMAND_RC=%ERRORLEVEL%")
|
||||
file:write("\n")
|
||||
file:write("chcp %cp%>nul\n")
|
||||
file:write("exit /b %COMMAND_RC%") -- otherwise, when the real command fails, script will still return "good" error code of chcp
|
||||
file:close()
|
||||
|
||||
result = dt.control.execute(fname)
|
||||
dt.print_log("result from windows command was " .. result)
|
||||
|
||||
os.remove(fname)
|
||||
else
|
||||
dt.print_error("Windows command failed: unable to create batch file")
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
dtutils_system.libdoc.functions["launch_default_app"] = {
|
||||
Name = [[launch_default_app]],
|
||||
Synopsis = [[open file in default application]],
|
||||
Usage = [[local dsys = require "lib/dtutils.file"
|
||||
|
||||
result = dsys.launch_default_app(path)
|
||||
path - string - a file path]],
|
||||
Description = [[launch_default_app allows opening a file in the application that is assigned as default
|
||||
for that filetype in the users's system]],
|
||||
Return_Value = [[result - the return value signalling success or failure.]],
|
||||
Limitations = [[]],
|
||||
Example = [[]],
|
||||
See_Also = [[]],
|
||||
Reference = [[]],
|
||||
License = [[]],
|
||||
Copyright = [[]],
|
||||
}
|
||||
|
||||
function dtutils_system.launch_default_app(path)
|
||||
local open_cmd = "xdg-open "
|
||||
if (dt.configuration.running_os == "windows") then
|
||||
open_cmd = "" -- On Windows we don't need any command. (start e.g. 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
|
||||
elseif (dt.configuration.running_os == "macos") then
|
||||
open_cmd = "open "
|
||||
end
|
||||
return dtutils_system.external_command(open_cmd .. path)
|
||||
end
|
||||
|
||||
return dtutils_system
|
||||
78
locale/de_DE/LC_MESSAGES/OpenInExplorer.po
Normal file
78
locale/de_DE/LC_MESSAGES/OpenInExplorer.po
Normal file
@@ -0,0 +1,78 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# Volker Lenhardt <volker.lenhardt@unitybox.de>, 2020.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-06-11 19:07+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: de_DE\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: OpenInExplorer.lua:71
|
||||
msgid ""
|
||||
"OpenInExplorer plug-in only supports Linux and macOS, and Windows at this time"
|
||||
msgstr "OpenInExplorer-Plug-in unterstützt zur Zeit nur Linux, macOS oder Windows"
|
||||
|
||||
#: OpenInExplorer.lua:87
|
||||
msgid ""
|
||||
"No links directory selected.\n"
|
||||
"Please check the dt preferences (lua options)"
|
||||
msgstr "Kein Verknüpfungs-Verzeichnis ausgewählt.\nBitte die dt-Voreinstellungen überprüfen (Lua-Optionen)"
|
||||
|
||||
#: OpenInExplorer.lua:91
|
||||
#, lua-format
|
||||
msgid ""
|
||||
"Links directory '%s' not found.\n"
|
||||
"Please check the dt preferences (lua options)"
|
||||
msgstr "Das Verknüpfungs-Verzeichnis '%s' konnte nicht gefunden werden.\nBitte die dt-Voreinstellungen überprüfen (Lua-Optionen)"
|
||||
|
||||
#: OpenInExplorer.lua:148
|
||||
msgid "Failed to create links. Missing rights?"
|
||||
msgstr "Die Verknüpfungen konnten nicht erstellt werden. Fehlende Rechte?"
|
||||
|
||||
#: OpenInExplorer.lua:164
|
||||
msgid "Please select an image"
|
||||
msgstr "Es wurde kein Bild ausgewählt"
|
||||
|
||||
#: OpenInExplorer.lua:170
|
||||
msgid "Please select fewer images (max. 15)"
|
||||
msgstr "Bitte nicht mehr als 15 Bilder auswählen"
|
||||
|
||||
#: OpenInExplorer.lua:186
|
||||
msgid "show in file explorer"
|
||||
msgstr "im Dateimanager anzeigen"
|
||||
|
||||
#: OpenInExplorer.lua:188
|
||||
msgid "Open the file manager at the selected image's location"
|
||||
msgstr "Öffnet den Dateimanager an der Position des ausgewählten Bildes"
|
||||
|
||||
#: OpenInExplorer.lua:193
|
||||
msgid "OpenInExplorer: linked files directory"
|
||||
msgstr "OpenInExplorer: Verknüpfungs-Verzeichnis"
|
||||
|
||||
#: OpenInExplorer.lua:194
|
||||
msgid ""
|
||||
"Directory to store the links to the file names. Requires restart to take "
|
||||
"effect"
|
||||
msgstr "Verzeichnis für die Verknüpfungen zu den Dateinamen. Erfordert dt-Neustart"
|
||||
|
||||
#: OpenInExplorer.lua:197
|
||||
msgid "Select directory"
|
||||
msgstr "Verzeichnis auswählen"
|
||||
|
||||
#: OpenInExplorer.lua:203
|
||||
msgid "OpenInExplorer: use links"
|
||||
msgstr "OpenInExplorer: Verknüpfungen nutzen"
|
||||
|
||||
#: OpenInExplorer.lua:204
|
||||
msgid "Use links instead of multiple windows. Requires restart to take effect"
|
||||
msgstr "Verknüpfungen statt einzelner Fenster nutzen. Erfordert dt-Neustart"
|
||||
22
locale/de_DE/LC_MESSAGES/calcDistance.po
Normal file
22
locale/de_DE/LC_MESSAGES/calcDistance.po
Normal file
@@ -0,0 +1,22 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-01-31 22:57+0100\n"
|
||||
"PO-Revision-Date: 2016-01-31 23:02+0100\n"
|
||||
"Language: de_DE\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Last-Translator: Tobias Jakobs <tobias.jakobs@gmail.com>\n"
|
||||
"Language-Team: \n"
|
||||
"X-Generator: Poedit 1.8.4\n"
|
||||
|
||||
#: calcDistance.lua:93
|
||||
msgid "Calculate the distance from latitude and longitude in km"
|
||||
msgstr "Errechne die Entfernung mit Hilfe des Längen- und Breitengrads in km"
|
||||
28
locale/de_DE/LC_MESSAGES/clear_GPS.po
Normal file
28
locale/de_DE/LC_MESSAGES/clear_GPS.po
Normal file
@@ -0,0 +1,28 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-09-07 22:25-0400\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: Bill Ferguson <wpferguson@gmail.com>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.5.4\n"
|
||||
"Language: de_DE\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"X-Poedit-KeywordsList: gettext;dgettext:2;dcgettext:2ngettext:1,2;"
|
||||
"dngettext:2,3\n"
|
||||
"X-Poedit-Basepath: .\n"
|
||||
|
||||
#: clear_GPS.lua:62
|
||||
msgid "clear GPS data"
|
||||
msgstr "GPS-Daten löschen"
|
||||
75
locale/de_DE/LC_MESSAGES/copy_attach_detach_tags.po
Normal file
75
locale/de_DE/LC_MESSAGES/copy_attach_detach_tags.po
Normal file
@@ -0,0 +1,75 @@
|
||||
# Holger Klemm, 2016.
|
||||
# Christian Kanzian <christian.kanzian@gmx.at>, 2016.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Lua image path\n"
|
||||
"POT-Creation-Date: 2016-01-07 20:33+0100\n"
|
||||
"PO-Revision-Date: 2016-10-18 15:34+0200\n"
|
||||
"Last-Translator: Christian Kanzian <christian.kanzian@gmx.at>\n"
|
||||
"Language-Team: German <kde-i18n-de@kde.org>\n"
|
||||
"Language: de\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Lokalize 1.5\n"
|
||||
"X-Poedit-Basepath: .\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Poedit-KeywordsList: \n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
|
||||
#: copy_attach_detach_tags.lua:10
|
||||
msgid "Image tags copied ..."
|
||||
msgstr "Bild Tags kopiert ..."
|
||||
|
||||
#: copy_attach_detach_tags.lua:10
|
||||
msgid "No tags to attached, please copy tags first."
|
||||
msgstr "Es wurden keine Tags eingefügt. Bitte zuerst die Tags kopieren."
|
||||
|
||||
#: copy_attach_detach_tags.lua:10
|
||||
msgid "Tags attached ..."
|
||||
msgstr "Tags anhängen ..."
|
||||
|
||||
#: copy_attach_detach_tags.lua:10
|
||||
msgid "Tags removed from image(s)."
|
||||
msgstr "Tags von Bildern wurden gelöscht."
|
||||
|
||||
#: copy_attach_detach_tags.lua:10
|
||||
msgid "Tags replaced"
|
||||
msgstr "Tag ersetzen"
|
||||
|
||||
#: copy_attach_detach_tags.lua:10
|
||||
msgid "multi copy tags"
|
||||
msgstr "Tags kopieren"
|
||||
|
||||
#: copy_attach_detach_tags.lua:10
|
||||
msgid "paste tags"
|
||||
msgstr "Tags anhängen"
|
||||
|
||||
#: copy_attach_detach_tags.lua:10
|
||||
msgid "replace tags"
|
||||
msgstr "Tags ersetzen"
|
||||
|
||||
#: copy_attach_detach_tags.lua:10
|
||||
msgid "remove all tags"
|
||||
msgstr "Tags löschen"
|
||||
|
||||
#: copy_attach_detach_tags.lua:10
|
||||
msgid "tag clipboard"
|
||||
msgstr "Zwischenablage"
|
||||
|
||||
#: copy_attach_detach_tags.lua:10
|
||||
msgid "copy tags from selected image(s)"
|
||||
msgstr "Tags von ausgewählten Bildern kopieren"
|
||||
|
||||
#: copy_attach_detach_tags.lua:10
|
||||
msgid "paste tags to selected image(s)"
|
||||
msgstr "Tags an ausgewählte Bilder anhängen"
|
||||
|
||||
#: copy_attach_detach_tags.lua:10
|
||||
msgid "remove tags from selected image(s)"
|
||||
msgstr "Tags von ausgewählten Bildern löschen"
|
||||
|
||||
#: copy_attach_detach_tags.lua:10
|
||||
msgid "replace tags from selected image(s)"
|
||||
msgstr "Tags von ausgewählten Bildern ersetzen"
|
||||
|
||||
30
locale/de_DE/LC_MESSAGES/geo_uri.po
Normal file
30
locale/de_DE/LC_MESSAGES/geo_uri.po
Normal file
@@ -0,0 +1,30 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-01-31 22:58+0100\n"
|
||||
"PO-Revision-Date: 2016-01-31 23:13+0100\n"
|
||||
"Language: de_DE\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Last-Translator: Tobias Jakobs <tobias.jakobs@gmail.com>\n"
|
||||
"Language-Team: \n"
|
||||
"X-Generator: Poedit 1.8.4\n"
|
||||
|
||||
#: geo_uri.lua:55
|
||||
msgid "gnome-maps not found"
|
||||
msgstr "gnome-maps wurde nicht gefunden"
|
||||
|
||||
#: geo_uri.lua:81
|
||||
msgid "Command failed ..."
|
||||
msgstr "Aufruf fehlgeschlagen ..."
|
||||
|
||||
#: geo_uri.lua:88
|
||||
msgid "Open Location in Gnome Maps"
|
||||
msgstr "Öffnet den Ort in Gnome Maps"
|
||||
43
locale/de_DE/LC_MESSAGES/gimp.po
Normal file
43
locale/de_DE/LC_MESSAGES/gimp.po
Normal file
@@ -0,0 +1,43 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: gimp\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-04-13 23:50-0400\n"
|
||||
"PO-Revision-Date: 2016-04-14 00:11-0500\n"
|
||||
"Last-Translator: Bill Ferguson <wpferguson@gmail.com>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.5.4\n"
|
||||
"Language: de_DE\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"X-Poedit-KeywordsList: gettext;dgettext:2;dcgettext:2ngettext:1,2;"
|
||||
"dngettext:2,3\n"
|
||||
"X-Poedit-Basepath: .\n"
|
||||
|
||||
#: gimp.lua:194
|
||||
#, lua-format
|
||||
msgid "Export Image %i/%i"
|
||||
msgstr "Exportiere Bild %i/%i"
|
||||
|
||||
#: gimp.lua:242
|
||||
msgid "Unable to move edited file into collection. Leaving it as %s"
|
||||
msgstr "Die bearbeitete Datei kann nicht in die Sammlung aufgenommen werden. Bearbeitete Datei ist %s"
|
||||
|
||||
#: gimp.lua:251
|
||||
msgid "GIMP not found"
|
||||
msgstr "GIMP nicht gefunden"
|
||||
|
||||
#: gimp.lua:266
|
||||
msgid "Launching GIMP..."
|
||||
msgstr "Starten von GIMP"
|
||||
|
||||
#: gimp.lua:313
|
||||
msgid "Edit with GIMP"
|
||||
msgstr "Bearbeiten mit GIMP"
|
||||
26
locale/de_DE/LC_MESSAGES/gps_select.po
Normal file
26
locale/de_DE/LC_MESSAGES/gps_select.po
Normal file
@@ -0,0 +1,26 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-01-31 22:58+0100\n"
|
||||
"PO-Revision-Date: 2016-01-31 23:05+0100\n"
|
||||
"Language: de_DE\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Last-Translator: Tobias Jakobs <tobias.jakobs@gmail.com>\n"
|
||||
"Language-Team: \n"
|
||||
"X-Generator: Poedit 1.8.4\n"
|
||||
|
||||
#: gps_select.lua:59
|
||||
msgid "Select all images with GPS information"
|
||||
msgstr "Markiert alle Bilder mit GPS-Informationen"
|
||||
|
||||
#: gps_select.lua:60
|
||||
msgid "Select all images without GPS information"
|
||||
msgstr "Markiert alle Bilder ohne GPS-Informationen"
|
||||
42
locale/de_DE/LC_MESSAGES/hugin.po
Normal file
42
locale/de_DE/LC_MESSAGES/hugin.po
Normal file
@@ -0,0 +1,42 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-01-31 22:59+0100\n"
|
||||
"PO-Revision-Date: 2018-09-18 10:22+0200\n"
|
||||
"Language: de_DE\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Last-Translator: Simon Legner <Simon.Legner@gmail.com>\n"
|
||||
"Language-Team: \n"
|
||||
"X-Generator: Poedit 2.1.1\n"
|
||||
|
||||
#: hugin.lua:73
|
||||
msgid "hugin not found"
|
||||
msgstr "Hugin wurde nicht gefunden"
|
||||
|
||||
#: hugin.lua:97
|
||||
msgid "Will try to stitch now"
|
||||
msgstr "Versuche Bilder zusammenzufügen"
|
||||
|
||||
#: hugin.lua:102
|
||||
msgid "Creating pto file"
|
||||
msgstr "Erzeuge pto-Datei"
|
||||
|
||||
#: hugin.lua:105
|
||||
msgid "Running Assistent"
|
||||
msgstr "Starte den Assistenten"
|
||||
|
||||
#: hugin.lua:118
|
||||
msgid "Command hugin failed ..."
|
||||
msgstr "Aufruf von hugin fehlgeschlagen ..."
|
||||
|
||||
#: hugin.lua:124
|
||||
msgid "Hugin Panorama"
|
||||
msgstr "Hugin-Panorama"
|
||||
46
locale/de_DE/LC_MESSAGES/kml_export.po
Normal file
46
locale/de_DE/LC_MESSAGES/kml_export.po
Normal file
@@ -0,0 +1,46 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Lua gettextTest\n"
|
||||
"POT-Creation-Date: 2016-01-22 15:33+0100\n"
|
||||
"PO-Revision-Date: 2018-09-18 10:21+0200\n"
|
||||
"Last-Translator: Simon Legner <Simon.Legner@gmail.com>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: de\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.1.1\n"
|
||||
"X-Poedit-Basepath: .\n"
|
||||
"Plural-Forms: nplurals=2;t\" plural=(n != 1);\n"
|
||||
"X-Poedit-KeywordsList: gettext;dgettext:2;dcgettext:2;ngettext:1,2;dngettext:2,3\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
|
||||
msgid "KML/KMZ Export"
|
||||
msgstr "KML/KMZ-Export"
|
||||
|
||||
msgid "Export Image %i/%i"
|
||||
msgstr "Exportiere Bild %i/%i"
|
||||
|
||||
msgid "KML export: Open KML/KMZ file after export"
|
||||
msgstr "KML-Export KML/KMZ-Datei nach dem Export öffnen"
|
||||
|
||||
msgid "Opens the KML file after the export with the standard programm for KML files"
|
||||
msgstr "Öffnet die KML-Datei mit dem Standardprogram für KML-Dateien"
|
||||
|
||||
msgid "KML export: Export directory"
|
||||
msgstr "KML-Export: Export-Verzeichnis"
|
||||
|
||||
msgid "A directory that will be used to export the KML/KMZ files"
|
||||
msgstr "Verzeichnis in das die KML/KMZ-Dateien exportiert werden"
|
||||
|
||||
msgid "KML export: Connect images with path"
|
||||
msgstr "KML-Export: Bilder mit einer Linie verbinden"
|
||||
|
||||
msgid "connect all images with a path"
|
||||
msgstr "Verbinde alle Bilder mit einer Linie"
|
||||
|
||||
msgid "KML export: Create KMZ file"
|
||||
msgstr "KML-Export: KMZ-Datei erstellen"
|
||||
|
||||
msgid "Compress all imeges to one KMZ file"
|
||||
msgstr "Alle Bilder in einer KMZ-Datei komprimieren"
|
||||
73
locale/de_DE/LC_MESSAGES/photils.po
Normal file
73
locale/de_DE/LC_MESSAGES/photils.po
Normal file
@@ -0,0 +1,73 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Lua photils\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-12 13:12+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: de\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "get tags"
|
||||
msgstr "hole stichwörter"
|
||||
|
||||
msgid "requires a restart to be applied"
|
||||
msgstr "erfordert einen Neustart um angewendet zu werden"
|
||||
|
||||
msgid "min confidence value"
|
||||
msgstr "min vertrauenswert"
|
||||
|
||||
msgid ""
|
||||
"The suggested tags were not generated\n"
|
||||
" for the currently selected image!"
|
||||
msgstr ""
|
||||
"Die vorgeschlagenen Stichwörter wurden für das\n"
|
||||
"aktuell ausgewählte Bild nicht generiert!"
|
||||
|
||||
#, lua-format
|
||||
msgid " page %s of %s "
|
||||
msgstr " seite %s von %s "
|
||||
|
||||
msgid "Tags successfully attached to image"
|
||||
msgstr "Stichwörter erfolgreich an Bild angefügt"
|
||||
|
||||
#, lua-format
|
||||
msgid "Error writing to `%s`"
|
||||
msgstr "Fehler beim Schreiben in `%s`"
|
||||
|
||||
#, lua-format
|
||||
msgid "%s failed, see terminal output for details"
|
||||
msgstr "%s fehlgeschlagen, siehe Terminal-Ausgabe für Details"
|
||||
|
||||
#, lua-format
|
||||
msgid "%s found %d tags for your image"
|
||||
msgstr "%s gefunden %d-Stichwörter für Ihr Bild"
|
||||
|
||||
msgid "No image selected."
|
||||
msgstr "Kein Bild ausgewählt."
|
||||
|
||||
msgid "This plugin can only handle a single image."
|
||||
msgstr "Dieses Plugin kann nur ein einziges Bild verarbeiten."
|
||||
|
||||
#, lua-format
|
||||
msgid "attach %d tags"
|
||||
msgstr "%d stichwörter anhängen"
|
||||
|
||||
msgid "photils-cli not found"
|
||||
msgstr "photils-cli nicht gefunden"
|
||||
|
||||
msgid ""
|
||||
"Select an image, click \"Get Tags\" and get \n"
|
||||
"suggestions for tags."
|
||||
msgstr ""
|
||||
"Wählen Sie ein Bild aus, drücken Sie \"Hole Stichwörter\"\n"
|
||||
" und erhalten Sie Vorschläge für Stichwörter."
|
||||
84
locale/de_DE/LC_MESSAGES/quicktag.po
Normal file
84
locale/de_DE/LC_MESSAGES/quicktag.po
Normal file
@@ -0,0 +1,84 @@
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
#
|
||||
# Christian Kanzian <christian.kanzian@gmx.at>, 2017.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-02-20 17:38+0100\n"
|
||||
"PO-Revision-Date: 2017-02-20 17:50+0100\n"
|
||||
"Last-Translator: Christian Kanzian <christian.kanzian@gmx.at>\n"
|
||||
"Language-Team: German <kde-i18n-de@kde.org>\n"
|
||||
"Language: de\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Generator: Lokalize 1.5\n"
|
||||
|
||||
#: quicktag.lua:64
|
||||
msgid "max. length of button labels"
|
||||
msgstr "Max. Länge der Schaltflächen-Beschriftung"
|
||||
|
||||
#: quicktag.lua:65
|
||||
msgid "may range from 15 to 60 - needs a restart"
|
||||
msgstr "Bereich von 15 bis 60 möglich - Neustart erforderlich"
|
||||
|
||||
#: quicktag.lua:78
|
||||
msgid "number of quicktag fields"
|
||||
msgstr "Anzahl von quicktag Feldern"
|
||||
|
||||
#: quicktag.lua:79
|
||||
msgid "may range from 2 to 20 - needs a restart"
|
||||
msgstr "Bereich von 2 bis 20 möglich - Neustart erforderlich"
|
||||
|
||||
#: quicktag.lua:119
|
||||
#, lua-format
|
||||
msgid "quicktag %i is empty, please set a tag"
|
||||
msgstr "quicktag %i ist leer - bitte Tag eingeben"
|
||||
|
||||
#: quicktag.lua:134
|
||||
msgid "no images selected"
|
||||
msgstr "keine Bilder ausgewählt"
|
||||
|
||||
#: quicktag.lua:144
|
||||
#, lua-format
|
||||
msgid "tag \"%s\" attached to %i image(s)"
|
||||
msgstr "Tag \"%s\" an %i Bild(er) angehängt"
|
||||
|
||||
#: quicktag.lua:165
|
||||
msgid "old quicktag"
|
||||
msgstr "Alter quicktag"
|
||||
|
||||
#: quicktag.lua:166
|
||||
msgid "select the quicktag to replace"
|
||||
msgstr "Wähle den quicktag der ersetzt werden soll"
|
||||
|
||||
#: quicktag.lua:182 quicktag.lua:206
|
||||
msgid "new quicktag"
|
||||
msgstr "Neuer quicktag"
|
||||
|
||||
#: quicktag.lua:185
|
||||
msgid "enter your tag here"
|
||||
msgstr "Bitte Tag hier eingeben"
|
||||
|
||||
#: quicktag.lua:189
|
||||
msgid "set quicktag"
|
||||
msgstr "Setze Tag"
|
||||
|
||||
#: quicktag.lua:193
|
||||
msgid "new quicktag is empty!"
|
||||
msgstr "Neuer Tag ist leer!"
|
||||
|
||||
#: quicktag.lua:197
|
||||
#, lua-format
|
||||
msgid "quicktag \"%s\" replaced by \"%s\""
|
||||
msgstr "quicktag \"%s\" ersetzt durch \"%s\" "
|
||||
|
||||
#: quicktag.lua:246
|
||||
#, lua-format
|
||||
msgid "quicktag %i"
|
||||
msgstr "quicktag %i"
|
||||
|
||||
|
||||
12
locale/de_DE/LC_MESSAGES/select_non_existing.po
Normal file
12
locale/de_DE/LC_MESSAGES/select_non_existing.po
Normal file
@@ -0,0 +1,12 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
|
||||
msgid "select non existing images"
|
||||
msgstr "nicht vorhandene Bilder auswählen"
|
||||
|
||||
msgid "select non existing"
|
||||
msgstr "nicht vorhandene auswählen"
|
||||
|
||||
msgid "select all non-existing images in the current images"
|
||||
msgstr "alle nicht vorhandenen Bilder in den aktuellen Bildern auswählen"
|
||||
27
locale/de_DE/LC_MESSAGES/select_untagged.po
Normal file
27
locale/de_DE/LC_MESSAGES/select_untagged.po
Normal file
@@ -0,0 +1,27 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: 2017-09-14 12:18+0200\n"
|
||||
"PO-Revision-Date: 2017-09-14 12:23+0200\n"
|
||||
"Last-Translator: Jannis_V\n"
|
||||
"Language-Team: \n"
|
||||
"Language: de_DE\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.8.7.1\n"
|
||||
"X-Poedit-Basepath: ../../../contrib\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Poedit-SearchPath-0: select_untagged.lua\n"
|
||||
|
||||
#: select_untagged.lua:38
|
||||
msgid "select untagged images"
|
||||
msgstr "Auswahl von Bildern ohne Tags"
|
||||
|
||||
#: select_untagged.lua:64
|
||||
msgid "select untagged"
|
||||
msgstr "Ohne Tags"
|
||||
|
||||
#: select_untagged.lua:64
|
||||
msgid "select all images containing no tags or only tags added by darktable"
|
||||
msgstr "Wähle alle Bilder der aktuellen Sammlung aus, die keine Tags oder nur automatisch durch darktable erzeugte Tags enthalten"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user