<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>251920</bug_id>
          
          <creation_ts>2010-09-21 13:11:30 +0000</creation_ts>
          <short_desc>Digikam should match lenses on Exif.CanonCs.LensType, not ExifCanonCs.Lens</short_desc>
          <delta_ts>2017-08-06 21:08:47 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>digikam</product>
          <component>Plugin-Editor-LensCorrection</component>
          <version>1.4.0</version>
          <rep_platform>Mandriva RPMs</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Buchan Milne">bgmilne</reporter>
          <assigned_to name="Digikam Developers">digikam-bugs-null</assigned_to>
          <cc>caulier.gilles</cc>
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin>1.5.0</cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1022245</commentid>
    <comment_count>0</comment_count>
    <who name="Buchan Milne">bgmilne</who>
    <bug_when>2010-09-21 13:11:30 +0000</bug_when>
    <thetext>Version:           1.4.0 (using KDE 4.4.3) 
OS:                Linux

Digikam Lens correction wasn&apos;t automatically choosing the correct lens from the lensfun database. Canon cameras return different information for the Lens and LensType tags:

$ exiv2 -pa IMG_2775.JPG |grep Lens
Exif.CanonCs.LensType                        Short       1  Canon EF 70-300mm f/4-5.6 IS USM
Exif.CanonCs.Lens                            Short       3  70.0 - 300.0 mm

While the Lens tag has valid information, the actual Lens model is only correct in LensType.

With the attached patch (only, no other patches), digikam automatically matches the correct lens.

Reproducible: Always

Steps to Reproduce:
Find an image taken on a Canon DSLR (I used Canon EOS 500D) with a lens listed in the lensfun database (I used &quot;Canon EF-S 17-85mm f/4-5.6 IS USM&quot;, which is in lensfun 0.2.5, and and &quot;Canon EF 70-300mm f/4-5.6 IS USM&quot; for which I have created a lens profile). Enter the editor, Enhance-&gt;Lens-&gt;Auto-correction

Actual Results:  
See that you need to select the lens manually.

Expected Results:  
The lens should be selected automatically.

With the attached patch, images taken with both lenses I have resulted in automatic selection of the correct lens profile.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1022247</commentid>
    <comment_count>1</comment_count>
      <attachid>51856</attachid>
    <who name="Buchan Milne">bgmilne</who>
    <bug_when>2010-09-21 13:20:29 +0000</bug_when>
    <thetext>Created attachment 51856
Trivial patch to use LensType tag on Canon</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1022249</commentid>
    <comment_count>2</comment_count>
      <attachid>51857</attachid>
    <who name="Buchan Milne">bgmilne</who>
    <bug_when>2010-09-21 13:23:00 +0000</bug_when>
    <thetext>Created attachment 51857
Patch formatted better to retain comment alignment</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1022250</commentid>
    <comment_count>3</comment_count>
    <who name="">caulier.gilles</who>
    <bug_when>2010-09-21 13:24:05 +0000</bug_when>
    <thetext>digiKam 1.5.0 has already a similar patch applied.

http://lxr.kde.org/source/extragear/graphics/digikam/libs/dmetadata/dmetadata.cpp#968

Gilles Caulier</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1022457</commentid>
    <comment_count>4</comment_count>
    <who name="Buchan Milne">bgmilne</who>
    <bug_when>2010-09-21 21:19:58 +0000</bug_when>
    <thetext>I applied the fix in http://websvn.kde.org/branches/extragear/graphics/digikam/libs/dmetadata/dmetadata.cpp?r1=1165407&amp;r2=1172473 to 1.4.0, and it did not work as expected. Instead of automatically matching the exact lens, it matched a different lens which had a focal length range that covered the shortest focal length. In the quick test I did, instead of matching EF-S 17-85mm f/4-5.6 IS USM, it matched EF-S 10-22mm f/3.5-4.5 USM.

If I instead place the append call with Exif.CanonCs.LensType before Exif.CanonCs.Lens, then it works as expected.

I should probably build from svn, but assuming no other major changes were made, I think this is not fixed.

I can supply a sample image if that would help test (I assume some other Canon DSLRs, such as 40D, work with the Exif.CanonCs.Lens tag, and we actually would prefer both types to work, not one or the other).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1022470</commentid>
    <comment_count>5</comment_count>
    <who name="">caulier.gilles</who>
    <bug_when>2010-09-21 22:10:32 +0000</bug_when>
    <thetext>yes send me by mail a test image, or give me a web link to download it

Gilles Caulier</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1023068</commentid>
    <comment_count>6</comment_count>
    <who name="Buchan Milne">bgmilne</who>
    <bug_when>2010-09-23 11:53:55 +0000</bug_when>
    <thetext>Looks like it is fixed in trunk in r1178204</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1035766</commentid>
    <comment_count>7</comment_count>
    <who name="Martin Klapetek">mklapetek</who>
    <bug_when>2010-10-22 23:13:50 +0000</bug_when>
    <thetext>In 2.0 branch it still detects the wrong lens for &quot;Canon EF-S 18-55mm f/3.5-5.6 IS&quot; as &quot;Canon EF-S 10-22mm f/3.5-4.5 USM&quot;. Although the database has only &quot;Canon EF-S 18-55mm f/3.5-5.6&quot; (without the IS), so that may be the problem. I&apos;d propose to do a regular expression match (if it isn&apos;t already, not sure).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1035824</commentid>
    <comment_count>8</comment_count>
    <who name="">caulier.gilles</who>
    <bug_when>2010-10-23 09:32:09 +0000</bug_when>
    <thetext>Martin,

There is 2 way to fix this problem: the regex is done in liblensfun using GLib2. I suspect that code is not perfect at this place. This can be fixed in lensfun code of course and reported to lensfun project to backport patch. 

This is done by this stage 1 : 

http://lxr.kde.org/source/extragear/graphics/digikam/libs/dimg/filters/lens/lensfuniface.cpp#275

Another way is to patch the digiKam lenfun interface to process a regex based on Qt4::QString. Stage 2 is specific to Nikon camera/lens: 

http://lxr.kde.org/source/extragear/graphics/digikam/libs/dimg/filters/lens/lensfuniface.cpp#280

There is the last stage :

http://lxr.kde.org/source/extragear/graphics/digikam/libs/dimg/filters/lens/lensfuniface.cpp#294

I recommend to add a new stage for Canon camera before last stage, if you choose to patch digiKam lensfun interface source code.

Please patch trunk, i will backport later GSoC 2010 branch.

Gilles Caulier</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1037963</commentid>
    <comment_count>9</comment_count>
    <who name="Martin Klapetek">mklapetek</who>
    <bug_when>2010-10-28 13:51:27 +0000</bug_when>
    <thetext>By looking at that, I think that just doing a &quot;reverse search&quot; could be enough. Because now it takes the exiv data and looks into the database. But if this string is just longer by the &quot;IS&quot; or something, it won&apos;t match. But if it would be done the other way round - by matching the database to the exiv string, this would work. Consider a use case, when the manufacturer creates just new lenses and adds stuff to the string (like &quot;IS&quot; or something else) but the actual lenses stays the same, this would still get matched with my proposed way. 

Okay, I&apos;ll play with it a little and see what I can come up with.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>51856</attachid>
            <date>2010-09-21 13:20:29 +0000</date>
            <delta_ts>2010-09-21 13:23:00 +0000</delta_ts>
            <desc>Trivial patch to use LensType tag on Canon</desc>
            <filename>digikam-1.4.0-canon-use-lenstype-tag.patch</filename>
            <type>text/plain</type>
            <size>690</size>
            <attacher name="Buchan Milne">bgmilne</attacher>
            
              <data encoding="base64">LS0tIGRpZ2lrYW0tMS40LjAvbGlicy9kbWV0YWRhdGEvZG1ldGFkYXRhLmNwcH4JMjAxMC0wOC0y
MiAwOTo1MzoyNi4wMDAwMDAwMDAgKzAxMDAKKysrIGRpZ2lrYW0tMS40LjAvbGlicy9kbWV0YWRh
dGEvZG1ldGFkYXRhLmNwcAkyMDEwLTA5LTIxIDExOjAzOjI5LjAwMDAwMDAwMCArMDEwMApAQCAt
OTY0LDcgKzk2NCw3IEBACiAKICAgICAvLyBJbiBmaXJzdCwgdHJ5IHRvIGdldCBMZW5zIGluZm9y
bWF0aW9uIGZyb20gbWFrZXJub3Rlcy4KIAotICAgIGxlbnNFeGlmVGFncy5hcHBlbmQoIkV4aWYu
Q2Fub25Dcy5MZW5zIik7ICAgICAgICAgIC8vIENhbm9uIENhbWVyYXMgTWFrZXJub3RlLgorICAg
IGxlbnNFeGlmVGFncy5hcHBlbmQoIkV4aWYuQ2Fub25Dcy5MZW5zVHlwZSIpOyAgICAgICAgICAv
LyBDYW5vbiBDYW1lcmFzIE1ha2Vybm90ZS4KICAgICBsZW5zRXhpZlRhZ3MuYXBwZW5kKCJFeGlm
LkNhbm9uLjB4MDA5NSIpOyAgICAgICAgICAvLyBBbHRlcm5hdGl2ZSBDYW5vbiBDYW1lcmFzIE1h
a2Vybm90ZS4KICAgICBsZW5zRXhpZlRhZ3MuYXBwZW5kKCJFeGlmLk5pa29uTGQxLkxlbnNJRE51
bWJlciIpOyAvLyBOaWtvbiBDYW1lcmFzIE1ha2Vybm90ZS4KICAgICBsZW5zRXhpZlRhZ3MuYXBw
ZW5kKCJFeGlmLk5pa29uTGQyLkxlbnNJRE51bWJlciIpOyAvLyBOaWtvbiBDYW1lcmFzIE1ha2Vy
bm90ZS4K
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>51857</attachid>
            <date>2010-09-21 13:23:00 +0000</date>
            <delta_ts>2010-09-21 13:23:00 +0000</delta_ts>
            <desc>Patch formatted better to retain comment alignment</desc>
            <filename>digikam-1.4.0-canon-use-lenstype-tag.patch</filename>
            <type>text/plain</type>
            <size>686</size>
            <attacher name="Buchan Milne">bgmilne</attacher>
            
              <data encoding="base64">LS0tIGRpZ2lrYW0tMS40LjAvbGlicy9kbWV0YWRhdGEvZG1ldGFkYXRhLmNwcH4JMjAxMC0wOC0y
MiAwOTo1MzoyNi4wMDAwMDAwMDAgKzAxMDAKKysrIGRpZ2lrYW0tMS40LjAvbGlicy9kbWV0YWRh
dGEvZG1ldGFkYXRhLmNwcAkyMDEwLTA5LTIxIDExOjAzOjI5LjAwMDAwMDAwMCArMDEwMApAQCAt
OTY0LDcgKzk2NCw3IEBACiAKICAgICAvLyBJbiBmaXJzdCwgdHJ5IHRvIGdldCBMZW5zIGluZm9y
bWF0aW9uIGZyb20gbWFrZXJub3Rlcy4KIAotICAgIGxlbnNFeGlmVGFncy5hcHBlbmQoIkV4aWYu
Q2Fub25Dcy5MZW5zIik7ICAgICAgICAgIC8vIENhbm9uIENhbWVyYXMgTWFrZXJub3RlLgorICAg
IGxlbnNFeGlmVGFncy5hcHBlbmQoIkV4aWYuQ2Fub25Dcy5MZW5zVHlwZSIpOyAgICAgIC8vIENh
bm9uIENhbWVyYXMgTWFrZXJub3RlLgogICAgIGxlbnNFeGlmVGFncy5hcHBlbmQoIkV4aWYuQ2Fu
b24uMHgwMDk1Iik7ICAgICAgICAgIC8vIEFsdGVybmF0aXZlIENhbm9uIENhbWVyYXMgTWFrZXJu
b3RlLgogICAgIGxlbnNFeGlmVGFncy5hcHBlbmQoIkV4aWYuTmlrb25MZDEuTGVuc0lETnVtYmVy
Iik7IC8vIE5pa29uIENhbWVyYXMgTWFrZXJub3RlLgogICAgIGxlbnNFeGlmVGFncy5hcHBlbmQo
IkV4aWYuTmlrb25MZDIuTGVuc0lETnVtYmVyIik7IC8vIE5pa29uIENhbWVyYXMgTWFrZXJub3Rl
Lgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>