Bug #1083

Exiv2::focalLength returns multiple values for CRW files

Added by Pedro Côrte-Real over 6 years ago. Updated about 6 years ago.

Target version:
Start date:
17 May 2015
Due date:
% Done:


Estimated time:


For CRW files1 Exiv2::focalLength returns 4 unsigned short values in total in the form [0, X, 914, 610] where X is the actual focal length. The exiv2 tool seems to do the right thing and report X but a naive implementation that just does getFloat() will get 0 instead of X. It would probably make more sense to return X directly unless the other values actually mean anything.

In darktable I just fixed it by taking the first non-zero value2, but that could very well be wrong in some cases still.




Updated by Pedro Côrte-Real over 6 years ago

exiftool seems to think the second value is the focal length and the other two are the sensor width and height:


Updated by Robin Mills about 6 years ago

  • Category changed from image format to not-a-bug
  • Status changed from New to Closed
  • Assignee set to Robin Mills
  • Target version set to 0.26

Exiv2 correctly lists the information in the file:

714 rmills@rmillsmbp:~/Downloads $ exiv2 -pv -g Focal RAW_CANON_300D.CRW 
0x0002 Canon        FocalLength                 Short       4  0 36 914 610
715 rmills@rmillsmbp:~/Downloads $ 
If can wanted to report an array of 4 shorts, that is what they have chosen to do. Exiv2 is not a metadata policeman, he reports what is in the file.


Updated by Pedro Côrte-Real about 6 years ago

Calling tag 0x1029 or the CRW format FocalLength was exiv2's decision it's not a particularly good name as the focal length is the second value and there are two other potentially useful values there. Additionally even if you want the tag to return the 4 values surely focalLength(), if it's going to be useful, needs to actually deal with the quirks each format has. For the CRW format that means taking the second value in that tag.


Updated by Robin Mills about 6 years ago

  • % Done changed from 0 to 100

Updated by Pedro Côrte-Real about 6 years ago

This makes no sense but we need to carry the workaround for this bug for existing versions anyway...

Also available in: Atom PDF