Project

General

Profile

Patch #1306

the lens TAMRON SP 15-30mm F/2.8 Di VC USD A012 is not properly recognised

Added by rene ernenwein over 4 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
lens
Target version:
Start date:
29 Jul 2017
Due date:
% Done:

100%

Estimated time:
2.00 h

Description

hello
i own a TAMRON SP 15-30mm F/2.8 Di VC USD A012 mounted on a Canon 6D
i know the lens type (136) seen by exiv2
i allready put in ~/.exiv2 with success
but how to get it integrated in exiv2 for future version

  1. exiv2 -pv --grep lens/i 101CANON/IMG_0509.JPG
    0x0016 CanonCs LensType Short 1 136
    0x0017 CanonCs Lens Short 3 30 15 1
    0x0095 Canon LensModel Ascii 74 TAMRON SP 15-30mm F/2.8 Di VC USD A012
    0xa432 Photo LensSpecification Rational 4 15/1 30/1 0/1 0/1
    0xa434 Photo LensModel Ascii 39 TAMRON SP 15-30mm F/2.8 Di VC USD A012
    0xa435 Photo LensSerialNumber Ascii 11 0000000000
  1. exiv2 -pa --grep lens/i 101CANON/IMG_0509.JPG
    Exif.CanonCs.LensType Short 1 my own lens
    Exif.CanonCs.Lens Short 3 15.0 - 30.0 mm
    Exif.Canon.LensModel Ascii 74 TAMRON SP 15-30mm F/2.8 Di VC USD A012
    Exif.Photo.LensSpecification Rational 4 15/1 30/1 0/1 0/1
    Exif.Photo.LensModel Ascii 39 TAMRON SP 15-30mm F/2.8 Di VC USD A012
    Exif.Photo.LensSerialNumber Ascii 11 0000000000

Files

IMG_0509.JPG (4.04 MB) IMG_0509.JPG rene ernenwein, 29 Jul 2017 14:10

Related issues

Related to Exiv2 - Bug #1304: Lens missing Tamron SP 90mm f/2.8 Di Macro 1:1 VC USD F017Closed26 Jul 2017

Actions

History

#1

Updated by Robin Mills over 4 years ago

  • Category set to lens
  • Status changed from New to Closed
  • Assignee set to Robin Mills
  • Priority changed from High to Normal
  • Target version set to 0.27
  • % Done changed from 0 to 100
  • Estimated time set to 1.00 h

Regretfully, I think it's not possible to get this handled correctly in future versions of Exiv2. The challenge is presented by the metadata stored by Canon:

580 rmills@rmillsmbp:~/Downloads $ exiv2 -pa --grep lens/i IMG_0509.JPG 
Exif.CanonCs.LensType                        Short       1  Canon EF 300mm f/2.8L
Exif.CanonCs.Lens                            Short       3  15.0 - 30.0 mm
Exif.Canon.LensModel                         Ascii      74  TAMRON SP 15-30mm F/2.8 Di VC USD A012
Exif.Photo.LensSpecification                 Rational    4  15/1 30/1 0/1 0/1
Exif.Photo.LensModel                         Ascii      39  TAMRON SP 15-30mm F/2.8 Di VC USD A012
Exif.Photo.LensSerialNumber                  Ascii      11  0000000000
581 rmills@rmillsmbp:~/Downloads $ exiv2 -pv --grep lens/i IMG_0509.JPG 
0x0016 CanonCs      LensType                    Short       1  136
0x0017 CanonCs      Lens                        Short       3  30 15 1
0x0095 Canon        LensModel                   Ascii      74  TAMRON SP 15-30mm F/2.8 Di VC USD A012
0xa432 Photo        LensSpecification           Rational    4  15/1 30/1 0/1 0/1
0xa434 Photo        LensModel                   Ascii      39  TAMRON SP 15-30mm F/2.8 Di VC USD A012
0xa435 Photo        LensSerialNumber            Ascii      11  0000000000
582 rmills@rmillsmbp:~/Downloads $ 
I've received hundreds of requests for different lens which can all correspond to the same lens ID (in this case 136). When you update ~/.exiv2, all applications using Exiv2 know about your lens. It's unlikely (although possible) for you to have two different lens with ID==136.

We have code in Exiv2 which will further process a given LensID. That code examines other metadata (such the Canon.Lens.Model string, or Exif.Canon.FocalLength) to "guess" your lens. The "guessing" code is a maintenance nightmare and that's why I added ~/.exiv2.

You are of course welcome to read the "guessing" code in src/canomn.cpp and write a patch. However, I'd like you to live with ~/.exiv2 and let's see if this matter deserves further attention.

#2

Updated by rene ernenwein over 4 years ago

what i don't understand is if the tag LensModel contain the "good information"
it could be used directly without relaying on lenstype which is buggy in many cases

#3

Updated by Robin Mills over 4 years ago

The aim of exiv2 is to correctly report (and modify) the metadata in an image and that's exactly what we do.

The metadata isn't a single data stream, the manufacturer writes makernotes which may duplicate and contract other tags. In this case Canon have chosen to write 6 tags about your lens and we correctly report them all. Very confusingly, Canon have stored both a 39 byte string and a 74 byte string with LensModel. Is one of those strings nul or space padded? I don't know. I've given you a method to allow you to convert "136" into a description of your lens.

I suggest you discuss this with Canon and let me know their response. However, as things stand, I believe Exiv2 is behaving correctly.

#4

Updated by rene ernenwein over 4 years ago

i took a look at the source code you mention
i do know much better c as c++

i see that in structure canonCsLensType several lens definitions are listed for the same lenstype id

i don't find any code which will choose one of the definitions from the list of the definitions

is the list of the definition purely informational for the code reader ?

#5

Updated by Robin Mills over 4 years ago

You'll have to read further into the code (I didn't write it). There's a function that gets called for each tag. For LensType, the function is printCsLensType You'll see the comment #1034 which my change to look in the config file.

When printCsLensType, you can read all the Exif metadata (in the const ExifData* metadata). So, you could do something like:

if (Internal::readExiv2Config(section,value.toString(),undefined) == undefined
  && metadata["Exif.CanonCs.LensType"].toString() == "136" 
  && metadata["Exif.Photo.LensModel"].toString().size()
) {
  return os << metadata["Exif.Photo.LensModel"].toString();
}

Caution I've simply typed in this code to explain the concept. The code has to be debugged and tested and I don't have time at the moment to do this for you.

The code is saying "If this lens isn't mentioned in the config file and Exif.CanonCs.LensType == 136 and Exif.Photo.LensModel isn't an empty string, report the value of Exif.Photo.LensModel.

#6

Updated by rene ernenwein over 4 years ago

ok thank you for your code, i will try out your code sample

and also add number 747 because i already have some photos taken with "Canon EF 100-400mm f/4.5-5.6L IS II USM" and others with "Tamron SP 150-600mm F5-6.3 Di VC USD G2" !

regarding my question,
is there somewhere in the code a logic which takes decision if several definitions exist in structure canonCsLensType ?
or are the multiple definitions in canonCsLensType purely informational for the source code reader ?

#7

Updated by Robin Mills over 4 years ago

I don't know the answer to your question about several definitions exist in structure canonCsLensType as I didn't write the code. It's a pity that lens recognition was put into Exiv2 as it involves guess work. Niels looked after this code and left the project when we released v0.25. I added the ~/.exiv2 feature to reduce the maintenance headache. Your questions are bringing back my headache. You will have to read the code. I am unpaid volunteer. Words such as "please" or "thank you" are appreciated.

If you want me to support number 747, could you provide a sample file so that I can test my fix. In addition to changing the code, I add test files to our test suite to ensure the fix does not regress. I only extract the metadata into a .exv file which does not include your image.

#8

Updated by Robin Mills over 4 years ago

  • % Done changed from 100 to 50
  • Estimated time changed from 1.00 h to 4.00 h
#9

Updated by Robin Mills over 4 years ago

  • Status changed from Closed to Assigned
#10

Updated by Matze G over 4 years ago

Hey, I think my pullrequest should fix your problem rene.

https://github.com/Exiv2/exiv2/pull/20

#11

Updated by rene ernenwein over 4 years ago

Hello Mike
I am sorry that so are offended but this was not intention. I thank you for the work you are doing for exiv2.

My question was informational because i didn't understood how adding simply lines in the structure canonCsLensType could make it work.

Yet i have seen patch from mfg92 and i saw that also an additional line is needed in structure lensIdFct which makes the whole more comprehensive.

To my question original question :
why doing complicated things with lenstype and not returning lensmodel in all cases ?
what am i missing ?

#12

Updated by rene ernenwein over 4 years ago

and also thanks to Matze for its code to make my lens recognized by exiv2.

I think in darktable the patch will be usable in the near timeframe if the patch is accepted.

But for my NAS it will take some time before a fresh exiv2 version is integrated into it...

#13

Updated by Robin Mills over 4 years ago

Thanks very much indeed to both of you for discussing and working on this. It's my intention to review and accept this patch. I'm on vacation at the moment and arrive home on Wednesday. I'll review and submit this by the weekend. When I submit any patch, I like to update the test suite to be sure I get an alert if the patch regresses. I intend to copy the metadata from images attached to #1304 and #1306 and put them in the test suite.

At the moment, Ben and I are working on a major change on 'master' and regrettably the build has been broken while we have both been on vacation. Getting the build fixed is my first priority when I get home.

To my question original question :
why doing complicated things with lenstype and not returning lensmodel in all cases ?
what am i missing ?

I didn't write Exiv2, so I can only discuss the code as I understand from reading and using it. In general, Exiv2 reports the data in the file with the option -pv (print values). The option -pa (== -pt "translated values") does conversion to "human" values. Figuring out the lens type depends on the Manufacturer's MakeNotes (which are different for every manufacturer). Phil Harvey (of ExifTool fame) described it as a "heuristic". I've seen images for which both Exiv2 and ExifTool get the lens wrong.

Exiv2 is open-source. Everybody is welcome to contribute. You are welcome to find a better way. I have worked on Exiv2 for 10 years and I have never rejected any contributor's patch.

It is my intention to make a "dot" release in September. Exiv2 v0.26.1 will include your patch for both #1304 and #1306. Please provide a test image for "747" and that can also be serviced.

#14

Updated by Robin Mills about 3 years ago

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

Discussion of this issue will continue on https://github.com/Exiv2/exiv2/issues/532

I am closing this issue on Redmine in preparation for Exiv2 v0.27 (expected 2018-12-31) when Redmine will become read-only.

Also available in: Atom PDF