Feature #1323

Add lens "Sigma 18-300mm f/3.5-6.3 DC Macro OS HS" for Canon ID 197

Added by Ronny Heidenreich about 4 years ago. Updated about 4 years ago.

Target version:
Start date:
11 Nov 2017
Due date:
% Done:


Estimated time:
1.00 h


$ exiv2 -pt IMG_6312.cr2 | grep -ai lens
Exif.CanonCs.LensType Short 1 Canon EF 75-300mm f/4-5.6 IS USM
Exif.CanonCs.Lens Short 3 18.0 - 300.0 mm
Exif.Canon.LensModel Ascii 70 18-300mm
Exif.Photo.LensSpecification Rational 4 18/1 300/1 0/0 0/0
Exif.Photo.LensModel Ascii 70 18-300mm
Exif.Photo.LensSerialNumber Ascii 12 0000000000


IMG_6559.JPG (2.66 MB) IMG_6559.JPG Ronny Heidenreich, 12 Nov 2017 10:14



Updated by Robin Mills about 4 years ago

  • Category set to lens
  • Status changed from New to Assigned
  • Assignee set to Robin Mills
  • Target version set to 0.27
  • % Done changed from 0 to 10
  • Estimated time set to 2.00 h

Can you attach an image taken with this lens and I will investigate.


Updated by Robin Mills about 4 years ago

  • % Done changed from 10 to 50

Thanks for the test file. The quick fix for this in Exiv2 v0.26 is to add the following to ~/.exiv2:

197=Sigma 18-300mm f/3.5-6.3 DC Macro OS HS

Lens recognition is not simple because manufacturers often use the same lens id (in this case 197) for more than one lens. You could modify the code in src/canonmn.cpp to be:

        { 197, "Sigma 18-300mm f/3.5-6.3 DC Macro OS HS"                    },

However in order to permanently add the recognition of your lens, we have to provide a function such as:

        { 197, printCsLensByFocalLength }, // not tested
The function printCsLensByFocalLength has to be "tuned" to examine all the metadata in the image to distinguish your lens from another with ID = 197.

I added the file ~/.exiv2 for the following reasons:
1) You can overwrite the "built in" definition without waiting for a new release of Exiv2
2) to save me the effort to add code to determine which of several lens is in use
3) When you update your version of Exiv2, your definition in ~/.exiv2 remains valid.

Here's the documentation for this feature:


Updated by Robin Mills about 4 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 50 to 100
  • Estimated time changed from 2.00 h to 1.00 h

I'm going to close this issue. If you wish to discuss this further, you are welcome to add comments and I will reopen the case.

If you'd like to accept the challenge of updating the code in printCsLensByFocalLength to identify your lens, I'm always looking for volunteers to join Team Exiv2. You'll find this interesting, rewarding and a little frustrating. I assure you of great mentoring and encouragement from other team members.

Also available in: Atom PDF