I took some raw (CR2) photos and want to edit them in darktable. The focal length is quite low and the distortion high.

Usually I correct the distortion by using darktable's lens correction module which automatically chooses the right values based on the exif information. It works for DSLRs but for this very camera the values are not known.

lens correction

My question:

  • What's the way to correct the distortion in darktable, if I cannot choose the right objective from the drop down menu in the lens correction module?
  • How do I determine the values? Which values should I choose?

2 Answers 2


Unfortunately, as of right now, darktable doesn't have a very good way of doing ad hoc distortion correction for a lens you don't have a lensfun profile for. The following is a dirty hack that may be useful in cases where the barrel distortion at the wide end of a zoom is so strong that even "incorrect" correction might be an improvement...

In the lens correction module:

  • Click on the top (camera) dropdown list and select Generic --> Crop-factor 1.0 (Full Frame)
  • For the lens dropdown: Select Generic --> Rectilinear 10-1000mm f/1.0.
  • Change the geometry to fish-eye
  • Change mode to distort

Now, when you change the value in the "mm" dropdown menu, you should get different degrees of generic "defishing"; start at the largest mm values and work down the list until you find something that looks closest to correct. Clicking the circular arrow button to the right of the "scale" slider will auto-adjust the scale to the largest crop with no blank pixels.

If you're trying to correct "pincushion" distortion at the long end of a zoom, change the mode to "correct" instead of "distort".

  • \$\begingroup\$ Good info. But I believe that lensfun 0.3.95 (development) has info for the G5 X, so perhaps just an update to 0.3.95 is all that's necessary? \$\endgroup\$
    – scottbb
    Commented Oct 7, 2018 at 19:32
  • \$\begingroup\$ @scottbb Yeah, but that's been covered elsewhere, and this seemed like a good place to introduce this little workaround. ;) \$\endgroup\$ Commented Oct 8, 2018 at 8:31
  • \$\begingroup\$ @CRThaze and others: There's now a github issue regarding how to improve this situation, here... if you would find the added manual controls useful, consider leaving a comment to that effect. \$\endgroup\$ Commented Feb 8, 2019 at 4:26
  • \$\begingroup\$ I had to cycle "correction method" to "only manual vignette" and then back to "Lensfun database" for "target geometry" and other relevant controls to be enabled. \$\endgroup\$
    – Rolf
    Commented Feb 5 at 18:29

Missing lenses are probably added in the latest version of lensfun. The problem is that lensfun don't get updates via the packet manager. To update the database you need to run this command lensfun-update-data as root.

  • 2
    \$\begingroup\$ Well, that's half true. ;) The command may be run as root, but doesn't need to be. It should also be noted that it requires python3, and that many Linux distros don't include it in the base Lensfun package, but in an additional package named "lensfun-tools" or similar. Also, saying a given lens is "probably" available in an update is a bit of a stretch... it may or may not be. Check that here. Feel free to work this information into your answer. :) \$\endgroup\$ Commented Mar 22, 2019 at 4:00
  • 1
    \$\begingroup\$ When running without root: it stores the files to ~/.local/share/lensfun/update. However, I had to move (or sym-link) the xml files one level up (i.e. to ~/.local/share/lensfun), otherwise the new lenses where not available in Darktable. Not sure if this is an issue of lensfun or of Darktable. Credit for this goes to Victor Klos. \$\endgroup\$
    – luator
    Commented Dec 22, 2020 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.