Skip to content

Support for importing the in-camera ratings from Fujifilm cameras #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 14, 2017

Conversation

Sitwon
Copy link
Contributor

@Sitwon Sitwon commented Oct 11, 2017

No description provided.

Copy link
Contributor

@supertobi supertobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice script. I've added some comments perhaps you can improve the script even a little bit.

local function detect_rating(event, image)
local RAF_filename = tostring(image)
local JPEG_filename = string.gsub(RAF_filename, "%.RAF$", ".JPG")
local command = "exiftool -Rating " .. JPEG_filename
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add a check if exiftool is installed on the system like this:
if not checkIfBinExists("exiftool") then
return
end

--]]

darktable = require "darktable"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the version you have tested the script with, like this:

darktable.configuration.check_version(...,{4,0,0})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version I have is 2.2.5, but I notice scripts in the repo claiming 4,0,0 and 5,0,0. Could you explain how the version numbering works? Should I use 2,2,5 or 4,0,0?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API Version is not the same then the darktable version. You can get the version with dt.configuration.api_version_string. Or simply use this script:

https://github.com/darktable-org/lua-scripts/blob/master/examples/api_version.lua

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just run darktable --version.

if string.len(jpeg_result) > 0 then
jpeg_result = string.gsub(jpeg_result, "^Rating.*(%d)", "%1")
image.rating = tonumber(jpeg_result)
darktable.print_error("Using JPEG Rating: " .. tostring(jpeg_result))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could earn some bonus point if you would make the strings translatable. But that is not really needed for error messages.
Have a look at:
lua-scripts/examples/gettextExample.lua
or
lua-scripts/contrib/gimp.lua


darktable.register_event("post-import-image", detect_rating)

darktable.print_error("fujifilm_ratings loaded.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here is a print better then a print_error

@houz
Copy link
Member

houz commented Oct 11, 2017

Why do you want this as a Lua script? If you provide us with a sample file we can probably teach dt itself to understand that field.

@Sitwon
Copy link
Contributor Author

Sitwon commented Oct 11, 2017

You're right, it would probably be better if darktable could handle it directly, like it does for Nikon NEF files. I guess I'm just used to having to fix my own issues with open source projects.

Some things I've learned from trial and error:

  1. If you shoot in JPEG+RAW, the in-camera Rating will be written only to the JPEG file, so on import you need to look for the JPEG and read the Rating from there.
  2. If you shoot in RAW only, the in-camera Rating will be written to the RAF file.
  3. In my first pass at this problem, I wrote a Bash script to create a <filename>.XMP file, and discovered that darktable looks for <filename>.xmp (case-sensitive extension matching).
  4. A lot of tools seem to not understand Fujifilm's MakerNotes fields, but exiftool does (at least in recent versions).

I have put some samples here: https://drive.google.com/open?id=0B0p0PF3h5F9kTkF1X3gycmkweXM

@houz
Copy link
Member

houz commented Oct 11, 2017

Bad news: At least my copy of exiv2 (version 0.25) doesn't understand that tag yet. Until that changed there isn't much we can do on darktable's side. So you will have to keep using your script. Once that changes we will of course add support for it.

@Sitwon
Copy link
Contributor Author

Sitwon commented Oct 14, 2017

@supertobi I think I've addressed all of your feedback, thanks.

@supertobi supertobi merged commit 83fc339 into darktable-org:master Oct 14, 2017
@supertobi
Copy link
Contributor

Here we go, your script is in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants