{"action":"created","comment":{"url":"https://api.github.com/repos/darktable-org/lua-scripts/pulls/comments/24406732","id":24406732,"diff_hunk":"@@ -0,0 +1,116 @@\n+--[[\n+Autostyle\n+Automatically apply a given style when an exif tag is present in the file. This tagged is checked with exiftool, in order to be able to match very exotic tags.\n+I wrote this initially to be able to apply a style to compensate for Auto-DR from my Fujifilm camera\n+\n+AUTHOR\n+Marc Cousin (cousinmarc@gmail.com)\n+\n+INSTALATION\n+* copy this file in $CONFIGDIR/lua/ where CONFIGDIR\n+is your darktable configuration directory\n+* add the following line in the file $CONFIGDIR/luarc\n+  require \"autostyle\"\n+\n+USAGE\n+* set the exif configuration string in your lua configuration\n+  mine, for instance, is AutoDynamicRange=200%=>DR200\"\n+  meaning that I automatically want to apply my DR200 style on all\n+  images where exiftool returns '200%' for the AutoDynamicRange tag\n+* if you want to be able to apply it manually to already imported\n+  images, define a shortcut (lua shortcuts). As I couldn't find an event for\n+  when a development is removed, so the autostyle won't be applied again, \n+  this shortcut is also helpful then\n+* import your images, or use the shortcut on your already imported images\n+* To determine which tag you want, list all tags with exiftool:\n+  exiftool -j XE021351.RAF, and find the one you want to use\n+  you can check it with \n+  > exiftool -AutoDynamicRange XE021351.RAF\n+  Auto Dynamic Range              : 200%\n+\n+\n+LICENSE\n+GPLv2\n+\n+]]\n+\n+local darktable = require \"darktable\"\n+\n+\n+-- Forward declare the functions\n+local autostyle_apply_one_image,autostyle_apply,exiftool_attribute,capture\n+\n+-- Tested it with darktable 1.6.1 and darktable git from 2014-01-25\n+darktable.configuration.check_version(...,{2,0,2},{2,1,0})\n+\n+-- Apply the style to an image, if it matches the tag condition\n+function autostyle_apply_one_image (image)\n+  -- We need the tag, the value and the style_name provided from the configuration string\n+  local tag,value,style_name=string.match(darktable.preferences.read(\"autostyle\",\"exif_tag\",\"string\"),\"(%g+)%s*=%s*(%g+)%s*=>%s*(%g+)\")\n+\n+  -- check they all exist (correct syntax)\n+  assert (tag,\"EXIF TAG not found in \" .. darktable.preferences.read(\"autostyle\",\"exif_tag\",\"string\"));\n+  assert (value,\"value to match not found in \" .. darktable.preferences.read(\"autostyle\",\"exif_tag\",\"string\"));\n+  assert (style_name,\"style name not found in \" .. darktable.preferences.read(\"autostyle\",\"exif_tag\",\"string\"));\n+","path":"contrib/autostyle.lua","position":55,"original_position":55,"commit_id":"d797b565e0591bda260b74c372c8d3f641cd3429","original_commit_id":"d797b565e0591bda260b74c372c8d3f641cd3429","user":{"login":"marco44","id":294693,"avatar_url":"https://avatars.githubusercontent.com/u/294693?v=3","gravatar_id":"","url":"https://api.github.com/users/marco44","html_url":"https://github.com/marco44","followers_url":"https://api.github.com/users/marco44/followers","following_url":"https://api.github.com/users/marco44/following{/other_user}","gists_url":"https://api.github.com/users/marco44/gists{/gist_id}","starred_url":"https://api.github.com/users/marco44/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marco44/subscriptions","organizations_url":"https://api.github.com/users/marco44/orgs","repos_url":"https://api.github.com/users/marco44/repos","events_url":"https://api.github.com/users/marco44/events{/privacy}","received_events_url":"https://api.github.com/users/marco44/received_events","type":"User","site_admin":false},"body":"You mean the asserts, right ?","created_at":"2015-02-10T11:56:00Z","updated_at":"2015-02-10T11:56:00Z","html_url":"https://github.com/darktable-org/lua-scripts/pull/4#discussion_r24406732","pull_request_url":"https://api.github.com/repos/darktable-org/lua-scripts/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/darktable-org/lua-scripts/pulls/comments/24406732"},"html":{"href":"https://github.com/darktable-org/lua-scripts/pull/4#discussion_r24406732"},"pull_request":{"href":"https://api.github.com/repos/darktable-org/lua-scripts/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/darktable-org/lua-scripts/pulls/4","id":28985967,"html_url":"https://github.com/darktable-org/lua-scripts/pull/4","diff_url":"https://github.com/darktable-org/lua-scripts/pull/4.diff","patch_url":"https://github.com/darktable-org/lua-scripts/pull/4.patch","issue_url":"https://api.github.com/repos/darktable-org/lua-scripts/issues/4","number":4,"state":"open","locked":false,"title":"Add an autostyle lua script, which autoapplies a style on a tag found by...","user":{"login":"marco44","id":294693,"avatar_url":"https://avatars.githubusercontent.com/u/294693?v=3","gravatar_id":"","url":"https://api.github.com/users/marco44","html_url":"https://github.com/marco44","followers_url":"https://api.github.com/users/marco44/followers","following_url":"https://api.github.com/users/marco44/following{/other_user}","gists_url":"https://api.github.com/users/marco44/gists{/gist_id}","starred_url":"https://api.github.com/users/marco44/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marco44/subscriptions","organizations_url":"https://api.github.com/users/marco44/orgs","repos_url":"https://api.github.com/users/marco44/repos","events_url":"https://api.github.com/users/marco44/events{/privacy}","received_events_url":"https://api.github.com/users/marco44/received_events","type":"User","site_admin":false},"body":"Hi, I just added this autostyle lua script. I hope it may be useful to others.\r\n\r\nThis is useful when you want to automate a few operations and the tag you want to use isn't known by darktable.","created_at":"2015-02-10T07:23:17Z","updated_at":"2015-02-10T11:56:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7efc3de7c6f8e21cda90bed1d496cc0ea431865a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/darktable-org/lua-scripts/pulls/4/commits","review_comments_url":"https://api.github.com/repos/darktable-org/lua-scripts/pulls/4/comments","review_comment_url":"https://api.github.com/repos/darktable-org/lua-scripts/pulls/comments/{number}","comments_url":"https://api.github.com/repos/darktable-org/lua-scripts/issues/4/comments","statuses_url":"https://api.github.com/repos/darktable-org/lua-scripts/statuses/d797b565e0591bda260b74c372c8d3f641cd3429","head":{"label":"marco44:master","ref":"master","sha":"d797b565e0591bda260b74c372c8d3f641cd3429","user":{"login":"marco44","id":294693,"avatar_url":"https://avatars.githubusercontent.com/u/294693?v=3","gravatar_id":"","url":"https://api.github.com/users/marco44","html_url":"https://github.com/marco44","followers_url":"https://api.github.com/users/marco44/followers","following_url":"https://api.github.com/users/marco44/following{/other_user}","gists_url":"https://api.github.com/users/marco44/gists{/gist_id}","starred_url":"https://api.github.com/users/marco44/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marco44/subscriptions","organizations_url":"https://api.github.com/users/marco44/orgs","repos_url":"https://api.github.com/users/marco44/repos","events_url":"https://api.github.com/users/marco44/events{/privacy}","received_events_url":"https://api.github.com/users/marco44/received_events","type":"User","site_admin":false},"repo":{"id":30580119,"name":"lua-scripts","full_name":"marco44/lua-scripts","owner":{"login":"marco44","id":294693,"avatar_url":"https://avatars.githubusercontent.com/u/294693?v=3","gravatar_id":"","url":"https://api.github.com/users/marco44","html_url":"https://github.com/marco44","followers_url":"https://api.github.com/users/marco44/followers","following_url":"https://api.github.com/users/marco44/following{/other_user}","gists_url":"https://api.github.com/users/marco44/gists{/gist_id}","starred_url":"https://api.github.com/users/marco44/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marco44/subscriptions","organizations_url":"https://api.github.com/users/marco44/orgs","repos_url":"https://api.github.com/users/marco44/repos","events_url":"https://api.github.com/users/marco44/events{/privacy}","received_events_url":"https://api.github.com/users/marco44/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/marco44/lua-scripts","description":"","fork":true,"url":"https://api.github.com/repos/marco44/lua-scripts","forks_url":"https://api.github.com/repos/marco44/lua-scripts/forks","keys_url":"https://api.github.com/repos/marco44/lua-scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marco44/lua-scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marco44/lua-scripts/teams","hooks_url":"https://api.github.com/repos/marco44/lua-scripts/hooks","issue_events_url":"https://api.github.com/repos/marco44/lua-scripts/issues/events{/number}","events_url":"https://api.github.com/repos/marco44/lua-scripts/events","assignees_url":"https://api.github.com/repos/marco44/lua-scripts/assignees{/user}","branches_url":"https://api.github.com/repos/marco44/lua-scripts/branches{/branch}","tags_url":"https://api.github.com/repos/marco44/lua-scripts/tags","blobs_url":"https://api.github.com/repos/marco44/lua-scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marco44/lua-scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marco44/lua-scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/marco44/lua-scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marco44/lua-scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/marco44/lua-scripts/languages","stargazers_url":"https://api.github.com/repos/marco44/lua-scripts/stargazers","contributors_url":"https://api.github.com/repos/marco44/lua-scripts/contributors","subscribers_url":"https://api.github.com/repos/marco44/lua-scripts/subscribers","subscription_url":"https://api.github.com/repos/marco44/lua-scripts/subscription","commits_url":"https://api.github.com/repos/marco44/lua-scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/marco44/lua-scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/marco44/lua-scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/marco44/lua-scripts/issues/comments/{number}","contents_url":"https://api.github.com/repos/marco44/lua-scripts/contents/{+path}","compare_url":"https://api.github.com/repos/marco44/lua-scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marco44/lua-scripts/merges","archive_url":"https://api.github.com/repos/marco44/lua-scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marco44/lua-scripts/downloads","issues_url":"https://api.github.com/repos/marco44/lua-scripts/issues{/number}","pulls_url":"https://api.github.com/repos/marco44/lua-scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/marco44/lua-scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/marco44/lua-scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marco44/lua-scripts/labels{/name}","releases_url":"https://api.github.com/repos/marco44/lua-scripts/releases{/id}","created_at":"2015-02-10T07:20:09Z","updated_at":"2015-02-10T07:21:51Z","pushed_at":"2015-02-10T07:21:51Z","git_url":"git://github.com/marco44/lua-scripts.git","ssh_url":"git@github.com:marco44/lua-scripts.git","clone_url":"https://github.com/marco44/lua-scripts.git","svn_url":"https://github.com/marco44/lua-scripts","homepage":null,"size":125,"stargazers_count":0,"watchers_count":0,"language":"Lua","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"darktable-org:master","ref":"master","sha":"180563252abfe60610c09abc1ddad3055b85893f","user":{"login":"darktable-org","id":1561544,"avatar_url":"https://avatars.githubusercontent.com/u/1561544?v=3","gravatar_id":"","url":"https://api.github.com/users/darktable-org","html_url":"https://github.com/darktable-org","followers_url":"https://api.github.com/users/darktable-org/followers","following_url":"https://api.github.com/users/darktable-org/following{/other_user}","gists_url":"https://api.github.com/users/darktable-org/gists{/gist_id}","starred_url":"https://api.github.com/users/darktable-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darktable-org/subscriptions","organizations_url":"https://api.github.com/users/darktable-org/orgs","repos_url":"https://api.github.com/users/darktable-org/repos","events_url":"https://api.github.com/users/darktable-org/events{/privacy}","received_events_url":"https://api.github.com/users/darktable-org/received_events","type":"Organization","site_admin":false},"repo":{"id":27842813,"name":"lua-scripts","full_name":"darktable-org/lua-scripts","owner":{"login":"darktable-org","id":1561544,"avatar_url":"https://avatars.githubusercontent.com/u/1561544?v=3","gravatar_id":"","url":"https://api.github.com/users/darktable-org","html_url":"https://github.com/darktable-org","followers_url":"https://api.github.com/users/darktable-org/followers","following_url":"https://api.github.com/users/darktable-org/following{/other_user}","gists_url":"https://api.github.com/users/darktable-org/gists{/gist_id}","starred_url":"https://api.github.com/users/darktable-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darktable-org/subscriptions","organizations_url":"https://api.github.com/users/darktable-org/orgs","repos_url":"https://api.github.com/users/darktable-org/repos","events_url":"https://api.github.com/users/darktable-org/events{/privacy}","received_events_url":"https://api.github.com/users/darktable-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/darktable-org/lua-scripts","description":"","fork":false,"url":"https://api.github.com/repos/darktable-org/lua-scripts","forks_url":"https://api.github.com/repos/darktable-org/lua-scripts/forks","keys_url":"https://api.github.com/repos/darktable-org/lua-scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/darktable-org/lua-scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/darktable-org/lua-scripts/teams","hooks_url":"https://api.github.com/repos/darktable-org/lua-scripts/hooks","issue_events_url":"https://api.github.com/repos/darktable-org/lua-scripts/issues/events{/number}","events_url":"https://api.github.com/repos/darktable-org/lua-scripts/events","assignees_url":"https://api.github.com/repos/darktable-org/lua-scripts/assignees{/user}","branches_url":"https://api.github.com/repos/darktable-org/lua-scripts/branches{/branch}","tags_url":"https://api.github.com/repos/darktable-org/lua-scripts/tags","blobs_url":"https://api.github.com/repos/darktable-org/lua-scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/darktable-org/lua-scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/darktable-org/lua-scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/darktable-org/lua-scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/darktable-org/lua-scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/darktable-org/lua-scripts/languages","stargazers_url":"https://api.github.com/repos/darktable-org/lua-scripts/stargazers","contributors_url":"https://api.github.com/repos/darktable-org/lua-scripts/contributors","subscribers_url":"https://api.github.com/repos/darktable-org/lua-scripts/subscribers","subscription_url":"https://api.github.com/repos/darktable-org/lua-scripts/subscription","commits_url":"https://api.github.com/repos/darktable-org/lua-scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/darktable-org/lua-scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/darktable-org/lua-scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/darktable-org/lua-scripts/issues/comments/{number}","contents_url":"https://api.github.com/repos/darktable-org/lua-scripts/contents/{+path}","compare_url":"https://api.github.com/repos/darktable-org/lua-scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/darktable-org/lua-scripts/merges","archive_url":"https://api.github.com/repos/darktable-org/lua-scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/darktable-org/lua-scripts/downloads","issues_url":"https://api.github.com/repos/darktable-org/lua-scripts/issues{/number}","pulls_url":"https://api.github.com/repos/darktable-org/lua-scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/darktable-org/lua-scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/darktable-org/lua-scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/darktable-org/lua-scripts/labels{/name}","releases_url":"https://api.github.com/repos/darktable-org/lua-scripts/releases{/id}","created_at":"2014-12-10T22:27:55Z","updated_at":"2014-12-30T03:34:48Z","pushed_at":"2014-12-26T19:03:22Z","git_url":"git://github.com/darktable-org/lua-scripts.git","ssh_url":"git@github.com:darktable-org/lua-scripts.git","clone_url":"https://github.com/darktable-org/lua-scripts.git","svn_url":"https://github.com/darktable-org/lua-scripts","homepage":null,"size":388,"stargazers_count":4,"watchers_count":4,"language":"Lua","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/darktable-org/lua-scripts/pulls/4"},"html":{"href":"https://github.com/darktable-org/lua-scripts/pull/4"},"issue":{"href":"https://api.github.com/repos/darktable-org/lua-scripts/issues/4"},"comments":{"href":"https://api.github.com/repos/darktable-org/lua-scripts/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/darktable-org/lua-scripts/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/darktable-org/lua-scripts/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/darktable-org/lua-scripts/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/darktable-org/lua-scripts/statuses/d797b565e0591bda260b74c372c8d3f641cd3429"}}}}