bugGNU Octave - Bugs: bug #67212, "imfinfo" should handle...

 
 

bug #67212: "imfinfo" should handle corrupted EXIF better.

Submitter:  Dmitri A. Sergatskov <dasergatskov>
Submitted:  Thu 12 Jun 2025 09:52:16 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Release: 
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 13 Jun 2025 09:01:36 PM UTC, comment #6: 

in matlab 2024b, FileSource is 'DSC'


a=imfinfo ('DSCN0010.jpg')

a =

  struct with fields:

              Filename: 'C:\temp\DSCN0010.jpg'
           FileModDate: '13-Jun-2025 16:54:48'
              FileSize: 161713
                Format: 'jpg'
         FormatVersion: ''
                 Width: 640
                Height: 480
              BitDepth: 24
             ColorType: 'truecolor'
       FormatSignature: ''
       NumberOfSamples: 3
          CodingMethod: 'Huffman'
         CodingProcess: 'Sequential'
               Comment: {}
               XMPData: [1×1 struct]
      ImageDescription: '                               '
                  Make: 'NIKON'
                 Model: 'COOLPIX P6000'
           Orientation: 1
     AutoOrientedWidth: 640
    AutoOrientedHeight: 480
           XResolution: 300
           YResolution: 300
        ResolutionUnit: 'Inch'
              Software: 'Nikon Transfer 1.1 W'
              DateTime: '2008:11:01 21:15:07'
      YCbCrPositioning: 'Centered'
         DigitalCamera: [1×1 struct]
               GPSInfo: [1×1 struct]
         ExifThumbnail: [1×1 struct]

>> a.ExifThumbnail

ans =

  struct with fields:

                    Compression: 'OJPEG'
                    XResolution: 72
                    YResolution: 72
                 ResolutionUnit: 'Inch'
          JPEGInterchangeFormat: 4548
    JPEGInterchangeFormatLength: 6702

>> a.DigitalCamera

ans =

  struct with fields:

               ExposureTime: 0.0133
                    FNumber: 5.9000
            ExposureProgram: 'Normal program'
            ISOSpeedRatings: 64
                ExifVersion: [48 50 50 48]
           DateTimeOriginal: '2008:10:22 16:28:39'
          DateTimeDigitized: '2008:10:22 16:28:39'
    ComponentsConfiguration: 'YCbCr'
          ExposureBiasValue: 0
           MaxApertureValue: 2.9000
               MeteringMode: 'Pattern'
                LightSource: 'unknown'
                      Flash: 'Flash did not fire, no strobe return detection function, compulsory flash suppression, flash function present, no red-eye reduction mode or unknown.'
                FocalLength: 24
                  MakerNote: [78 105 107 111 110 0 2 0 0 0 73 73 42 0 8 … ] (1×3298 double)
                UserComment: [65 83 67 73 73 0 0 0 32 32 32 32 32 32 32 … ] (1×126 double)
            FlashpixVersion: [48 49 48 48]
                 ColorSpace: 'sRGB'
           CPixelXDimension: 640
           CPixelYDimension: 480
        InteroperabilityIFD: [1×1 struct]
                 FileSource: 'DSC'
                  SceneType: 'A directly photographed image'
             CustomRendered: 'Normal process'
               ExposureMode: 'Auto exposure'
               WhiteBalance: 'Auto white balance'
           DigitalZoomRatio: 0
      FocalLengthIn35mmFilm: 112
           SceneCaptureType: 'Standard'
                GainControl: 'None'
                   Contrast: 'Normal'
                 Saturation: 'Normal'
                  Sharpness: 'Normal'
       SubjectDistanceRange: 'unknown'



Nicholas Jankowski <nrjank>
Group Member
Fri 13 Jun 2025 01:01:06 AM UTC, comment #5: 

So a dirty hack is to pretend that this filed is a "string" rather than uint8. And with diff:

diff -r d72e56ced110 libinterp/corefcn/__magick_read__.cc
--- a/libinterp/corefcn/__magick_read__.cc      Thu Jun 12 10:23:48 2025 +0200
+++ b/libinterp/corefcn/__magick_read__.cc      Thu Jun 12 20:59:39 2025 -0400
@@ -2182,6 +2182,9 @@
               // be strings.  Even if they're not GM returns a string anyway.
               "UserComment",
               "MakerComment",
+             //FIXME: This should be "int" but it is usually stored in oct
+             // format (e.g. `\003`) and that breaks "fill_exif_ints ()"
+              "FileSource",
               nullptr
             };
             static const string_vector exif_str (exif_str_fields);
@@ -2216,7 +2219,6 @@
               "LightSource",
               "Flash",
               "SensingMethod",
-              "FileSource",
               "CustomRendered",
               "ExposureMode",
               "WhiteBalance",


I see:

octave:2> imfinfo ("DSCN0010.jpg")
ans =

  scalar structure containing the fields:

    Filename = /home/dmitri/Downloads/DSCN0010.jpg
    FileModDate = 10-Jun-2025 00:20:02
    FileSize = 161713
    Format = JPEG
    FormatVersion =
    Width = 640
    Height = 480
...deleted...
    DigitalCamera =

      scalar structure containing the fields:

        DateTimeOriginal = 2008:10:22 16:28:39
        DateTimeDigitized = 2008:10:22 16:28:39
        UserComment = ASCII\000\000\000                                                                                                                     \000
        FileSource = \003
        ColorSpace = 1
        ExifImageWidth = 640
...deleted...


May be this is good enough for now.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 13 Jun 2025 12:21:49 AM UTC, comment #4: 

What does it return in Matlab? "3" or "Digital Camera"?

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 13 Jun 2025 12:01:42 AM UTC, comment #3: 

Yes. It is `\003` which is 3 (in octal) -- means "Digital Camera". I checked the other files and so it is common for this key to be in octal. So that needs to be changed, but I concider it "enhancements". The whole thing is a mess.
I actually have a new diff that returns the "bad" string that cannot be parsed, which should help with debugging.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Thu 12 Jun 2025 11:52:03 PM UTC, comment #2: 

Did the gm command give you an output for FileScource?

Nicholas Jankowski <nrjank>
Group Member
Thu 12 Jun 2025 10:02:01 PM UTC, comment #1: 

With the attache patch (file das_fill_exif.diff) I see:

octave:2> imfinfo ("DSCN0010.jpg")
warning: fill_exif_ints: skipping invalid EXIF value for key 'FileSource'
warning: called from
    __imfinfo__ at line 46 column 3
    imageIO at line 141 column 6
    imfinfo at line 166 column 3

ans =

  scalar structure containing the fields:

    Filename = /home/dmitri/Downloads/DSCN0010.jpg
    FileModDate = 10-Jun-2025 00:20:02
    FileSize = 161713
    Format = JPEG
    FormatVersion =
    Width = 640
    Height = 480
    BitDepth = 8
    ColorType = truecolor
    DelayTime = 0
    DisposalMethod =
    LoopCount = 0
    ByteOrder = undefined
    Gamma = 0
    Chromaticities = [](1x0)
    Comment =
    Quality = 75
    Compression = undefined
    Colormap = [](0x0)
    Orientation = 1
    ResolutionUnit = undefined
    XResolution = 0
    YResolution = 0
    Software = Nikon Transfer 1.1 W
    Make = NIKON
    Model = COOLPIX P6000
    DateTime = 2008:11:01 21:15:07
    ImageDescription =
    Artist =
    Copyright =
    DigitalCamera =

      scalar structure containing the fields:

        DateTimeOriginal = 2008:10:22 16:28:39
        DateTimeDigitized = 2008:10:22 16:28:39
        UserComment = ASCII\000\000\000                                                                                                                     \000
        ColorSpace = 1
        ExifImageWidth = 640
        FocalLengthIn35mmFilm = 112
        ExposureProgram = 2
        MeteringMode = 5
        LightSource = 0
        Flash = 16
        FileSource = [](0x1)
        CustomRendered = 0
        ExposureMode = 0
        WhiteBalance = 0
        SceneCaptureType = 0
        GainControl = 0
        Contrast = 0
        Saturation = 0
        Sharpness = 0
        SubjectDistanceRange = 0
        ExposureTime = 0.013333
        FNumber = 5.9000
        ExposureBiasValue = 0
        MaxApertureValue = 2.9000
        FocalLength = 24
        DigitalZoomRatio = 0

    GPSInfo =

      scalar structure containing the fields:

        GPSLatitudeRef = N
        GPSLongitudeRef = E
        GPSAltitudeRef = .
        GPSSatellites = 06
        GPSMapDatum = WGS-84
        GPSDateStamp = 2008:10:23
        GPSLatitude =

           43.0000
           28.0000
            2.8140

        GPSLongitude =

           11.0000
           53.0000
            6.4560

        GPSTimeStamp =

           14.0000
           27.0000
            7.2400

which I think is much better result.

Dmitri.
--





(file #57289)

Dmitri A. Sergatskov <dasergatskov>
Thu 12 Jun 2025 09:52:16 PM UTC, original submission:  

Currently, when reading EXIF with some corrupted values,
infinfo just quits with an error. E.g. with the file attached
(file DSCN0010.jpg)


octave:1> imfinfo ("DSCN0010.jpg")
error: fill_exif_ints: failed to read EXIF value as float
error: called from
    __imfinfo__ at line 46 column 3
    imageIO at line 141 column 6
    imfinfo at line 166 column 3
octave:2>


Yet, "gm identify -verbose DSCN0010.jpg" provides quite reasonable output.

Dmitri.
--


Dmitri A. Sergatskov <dasergatskov>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #57289:  das_fill_exif.diff added by dasergatskov (6KiB - text/x-patch)
file #57288:  DSCN0010.jpg added by dasergatskov (158KiB - image/jpeg)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by dasergatskov (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-06-12 dasergatskov Attached File- Added das_fill_exif.diff, #57289
    2025-06-12 dasergatskov Attached File- Added DSCN0010.jpg, #57288

    Back to the top

    Powered by Savane 3.15-e6e5.
    Corresponding source code