I'm close to fully automating a process of stacking bursts of pictures into one image thanks to Hugin's command-line tools, however there's one part I can't automate yet, it's converting RAW into rectilinearised TIFF, which so far I must use Lightroom for, because somehow Lightroom knows how to correct the distortion properly, however Lightroom cannot be scripted.

So far I only know of two programs that know out of the box how to correct my camera's distortion, Lightroom and Canon's DPP, both of which can't do anything from the command-line.

Before you answer "dcraw", no, DCRaw does not correct distortion. Neither does RawTherapee, at least not without providing your own distortion values or lens profile, which I'm not going to do because unless you shoot at only one focal length then this is crazy, and there's no existing profile for my camera. Lensfun's database is old and doesn't have my camera (Canon G9 X II), and it seems like all the free programs either do no correction or ask you to provide your own parameters. Why does Lightroom even know what to do when it doesn't even know about my camera model (old version, I have to convert to DNG first) and all these free programs have no idea what to do?

Does any commercial program besides Lightroom do the correction properly out of the box? Can any of them do the job from the command-line?

  • \$\begingroup\$ For the record, Lightroom can be scripted using Lua. This means that one could, in theory, make it work from the command line. One approach and most certainly not worth it would be to create a server in lua to listen to a client that is called from the command line. But this is too impractical for you. \$\endgroup\$
    – Unapiedra
    Commented Mar 17, 2017 at 10:49

1 Answer 1


I think you might be best served by being patient — you say that the Lensfun database is old, but it's actually a current, ongoing project, with (as of this writing, of course) new lens information added just days ago. Your camera was just released last month, and even commercial software will just now be updating with the relevant profiles. (Lightroom might be working simply because the lens on your camera seems to be unchanged from the previous "Mark I" G9 X model.)

If you are feeling impatient, you could consider contributing RAW data to the lensfun project, which will certainly speed things up.

Then, you'll simply be able to use the Hugin workflow you're already using, since Hugin integrates Lensfun.

  • \$\begingroup\$ Your idea of being impatient involves sending data to someone hoping they do something maybe one day :D and they don't have the Mark I either which isn't so new (they don't even have the G5 X or G3 X either) so I don't think I should hold my breath. How about something that actually works today, not maybe one day, how about commercial software? Surely there must be one that both corrects properly and is scriptable? Btw I'm using a old version of Lightroom that doesn't know about the Mark I either, that's why I have to convert to DNG first. \$\endgroup\$ Commented Mar 14, 2017 at 1:12
  • \$\begingroup\$ They don't have the Mark I data because no one sent them the necessary files. \$\endgroup\$
    – mattdm
    Commented Mar 14, 2017 at 1:13
  • \$\begingroup\$ If you are really impatient, you can follow the information linked from the Lensfun site and do the calibration yourself (and then, ideally, contribute it back for others). \$\endgroup\$
    – mattdm
    Commented Mar 14, 2017 at 1:16
  • \$\begingroup\$ Four more lenses have been added in the three days since I posted this. \$\endgroup\$
    – mattdm
    Commented Mar 17, 2017 at 0:27

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.