Bug #1324

Pentax Makernote written twice

Added by Dominique Nerriec 29 days ago. Updated 26 days ago.

Status:AssignedStart date:19 Nov 2017
Priority:NormalDue date:
Assignee:Robin Mills% Done:

10%

Category:makernoteEstimated time:4.00 hours
Target version:0.27

Description

Bug found with JPG files from Pentax K-3.
Sample attached : IMKT1330.JPG

How to reproduce ?
Execute an "exiv2 -M" command that triggers an "intrusive writting". Example :

exiv2  -M"set Exif.Image.Software mon logiciel a moi coucou coucou coucou" IMKT1330.JPG

We see that Pentax Makernote fields are written twice :

exiv2 -p a IMKT1330.JPG |sort|uniq -d

And if we try a second "intrusive writting", it fails :

IMKT1330.JPG (323 KB) Dominique Nerriec, 19 Nov 2017 20:38

History

#1 Updated by Dominique Nerriec 29 days ago

...And if we try a second "intrusive writting", it fails :

$ exiv2 -M"del Exif.Image.Software" IMKT1330.JPG 
Warning: Exif tag Exif.PentaxDng.0x0406 not encoded
Warning: Exif tag Exif.PentaxDng.0x0406 not encoded
Exiv2 exception in modify action for file IMKT1330.JPG:
Taille du segment JPEG Exif est plus grand que 65535 octets

What happens ?
It seems that there is a mix up between 'PentaxDng' group and 'Pentax' group.
In exif written in JPG by exiv2, there is a 0xC634 tag, which should be written only in DNG file.

Why was it ok with previous Camera ?
For example in K7 files, the Pentax header signature was "AOC" in JPG, and "PENTAX" in DNG.
But in K3, signature is "PENTAX" for both.

----+-----------+---------
    |    DNG    |    JPG
----+-----------+---------
K7  |  PENTAX   |    AOC
----+-----------+---------
K3  |  PENTAX   |  PENTAX
----+-----------+---------

Where is the bug ?
exiv2 relies on that header to choose between pentaxDngId and pentaxId.
This is in makernote.cpp newPentaxMn().

Here is a suggestion to fix. It worked for me (fixed the issue for JPG files, no regression on DNG files)

       if (   size > 8
            && std::string(reinterpret_cast<const char*>(pData), 8) == std::string("PENTAX \0", 8)) {
            // Require at least the header and an IFD with 1 entry
            if (size < PentaxDngMnHeader::sizeOfSignature() + 18) return 0;
// my change BEGIN            
          //return newPentaxDngMn2(tag, group, pentaxDngId);
            return newPentaxDngMn2(tag, group, (tag == 0xc634 ? pentaxDngId:pentaxId)) 
// my change END

I'm using 0.25-3.1 release.
Last July, I downloaded sources from trunk, the bug was the same.

I downloaded samples of other Pentax cameras. It seems that the bug is the same for K70.

I hope that will help... thanks in advance to fix that in official product.

#2 Updated by Robin Mills 29 days ago

  • Category set to makernote
  • 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

We've both tried to update this issue. I see you've given me more information. I'll look at this on Monday.

Here's what I was going to say:Dominique:

I can't reproduce this behaviour.

517 rmills@rmillsmbp:~/Downloads $ !curl
curl -O http://dev.exiv2.org/attachments/download/1200/IMKT1330.JPG
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  322k    0  322k    0     0   405k      0 --:--:-- --:--:-- --:--:--  407k
518 rmills@rmillsmbp:~/Downloads $ exiv2 -pa --grep Software IMKT1330.JPG 
Exif.Image.Software                          Ascii      24  PENTAX K-3 Ver. 1.30   
519 rmills@rmillsmbp:~/Downloads $ exiv2  -M"set Exif.Image.Software another software that goes on and on and on you know" IMKT1330.JPG
520 rmills@rmillsmbp:~/Downloads $ exiv2 -pa --grep Software IMKT1330.JPG 
Exif.Image.Software                          Ascii      53  another software that goes on and on and on you know
521 rmills@rmillsmbp:~/Downloads $ 
I can't reproduce this with your command arguments.
506 rmills@rmillsmbp:~/Downloads $ curl -O http://dev.exiv2.org/attachments/download/1200/IMKT1330.JPG
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  322k    0  322k    0     0   296k      0 --:--:--  0:00:01 --:--:--  342k
507 rmills@rmillsmbp:~/Downloads $ exiv2  -M"set Exif.Image.Software mon logiciel a moi coucou coucou coucou" IMKT1330.JPG
508 rmills@rmillsmbp:~/Downloads $ exiv2  -M"set Exif.Image.Software mon logiciel a moi coucou coucou coucou" IMKT1330.JPG
509 rmills@rmillsmbp:~/Downloads $ exiv2  -M"set Exif.Image.Software mon logiciel a moi coucou coucou coucou" IMKT1330.JPG
510 rmills@rmillsmbp:~/Downloads $ exiv2 -pa --grep Software IMKT1330.JPG 
Exif.Image.Software                          Ascii      40  mon logiciel a moi coucou coucou coucou
511 rmills@rmillsmbp:~/Downloads $ <pre>

#3 Updated by Dominique Nerriec 28 days ago

Hello,
thanks for working on that issue.

Only Makernote is written twice.
I should give such example in my description :

$ exiv2 -pa IMKT1330.JPG |grep AELock
Exif.PentaxDng.AELock                        Short       1  Off
$ exiv2 -M"set Exif.Image.Software mon logiciel a moi coucou coucou coucou" IMKT1330.JPG
$ exiv2 -pa IMKT1330.JPG |grep AELock
Exif.PentaxDng.AELock                        Short       1  Off
Exif.PentaxDng.AELock                        Short       1  Off
$

And the second modification fails only if it also triggers "intrusive writting" :
$ exiv2 -M"set Exif.Image.Software mon logiciel a moi coucou coucou coucou" IMKT1330.JPG
$ exiv2 -M"set Exif.Image.Software mon logiciel a moi coucou coucou coucou" IMKT1330.JPG
$ exiv2 -M"set Exif.Image.Software mon logiciel a moi coucou coucou coucou longer" IMKT1330.JPG
Warning: Exif tag Exif.PentaxDng.0x0406 not encoded
Warning: Exif tag Exif.PentaxDng.0x0406 not encoded
Exiv2 exception in modify action for file IMKT1330.JPG:
Size of Exif JPEG segment is larger than 65535 bytes
$

#4 Updated by Dominique Nerriec 28 days ago

(in my comments a few minutes ago, I used exiv2-0.26-trunk.tar.gz)

#5 Updated by Robin Mills 27 days ago

  • Estimated time changed from 2.00 to 4.00

Dominique:

I have only had 30 minutes today to look at this. I'm not going to have time until Monday December 4 to investigate this further. Alison and I live in England and will fly tomorrow to Vietnam to attend the wedding of a member of Team Exiv2. I'm not going to be able to look at this until I'm home (and recovered from the journey).

I'm not sure what's going on here, however this issue seems to have been in the code for years. So while I understand your concern, I don't feel this is urgent. You can report the issue on http://github.com/exiv2/exiv2 (and reference this issue report). Another team member may take on the challenge. However, I would prefer that you wait for my return. We hope to reach Exiv2 v0.27 RC1 in December and I would like the team to retain focus on their current tasks.

#6 Updated by Dominique Nerriec 26 days ago

thanks Robin, I agree it is not urgent. Have a good journey !

Also available in: Atom PDF

Redmine Appliance - Powered by TurnKey Linux