bugGNU Octave - Bugs: bug #67203, imfinfo does not import full EXIF...

 
 

bug #67203: imfinfo does not import full EXIF data from a jpeg file

Submitter:  Jack Huang <yhuangtc>
Submitted:  Mon 09 Jun 2025 03:06:48 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Jack Huang Open/Closed:  * Open
Release:  * 10.1.0 Release: 
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 13 Jun 2025 01:38:08 AM UTC, comment #7: 

Attached is a combined diff that fixes error in reading "FileSource" tag and adding "ISO" and "ISOSpeedRatings" tags.
(file das_magick_00.diff). The diff is very small, I vote to apply it to stable branch (10.3).


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 21:30:13 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);
@@ -2198,7 +2201,9 @@
               "PhotographicSensitivity",
               "StandardOutputSensitivity",
               "RecommendedExposureIndex",
+              "ISO",
               "ISOSpeed",
+              "ISOSpeedRatings",
               "ISOSpeedLatitudeyyy",
               "ISOSpeedLatitudezzz",
               "FocalPlaneResolutionUnit",
@@ -2216,7 +2221,6 @@
               "LightSource",
               "Flash",
               "SensingMethod",
-              "FileSource",
               "CustomRendered",
               "ExposureMode",
               "WhiteBalance",


Dmitri.
--


(file #57291)

Dmitri A. Sergatskov <dasergatskov>
Fri 13 Jun 2025 01:32:23 AM UTC, comment #6: 

The ISO fix appears to be quite easy.
"ISOSpeedRatings" is a tag that was missing (apparently it could also be called "ISO" or "PhotographicSensitivity").
After adding it to (_magic_read_.cc)


@@ -2198,7 +2201,9 @@
               "PhotographicSensitivity",
               "StandardOutputSensitivity",
               "RecommendedExposureIndex",
+              "ISO",
               "ISOSpeed",
+              "ISOSpeedRatings",
               "ISOSpeedLatitudeyyy",
               "ISOSpeedLatitudezzz",
               "FocalPlaneResolutionUnit",


I see with the file <yhuangtc> sent me:

octave:2> imfinfo ("IMG_4935.jpeg")
ans =

  scalar structure containing the fields:

    Filename = /home/dmitri/Downloads/IMG_4935.jpeg
    FileModDate = 10-Jun-2025 01:13:51
    FileSize = 5207058
    Format = JPEG
...deleted...
    Make = Apple
    Model = iPhone 14 Plus
    DateTime = 2025:05:29 16:56:04
    ImageDescription =
...deleted...
   DigitalCamera =

      scalar structure containing the fields:

        DateTimeOriginal = 2025:05:29 16:56:04
        DateTimeDigitized = 2025:05:29 16:56:04
        SubSecTimeOriginal = 867
        SubSecTimeDigitized = 867
        ColorSpace = 65535
        ExifImageWidth = 4032
        ISOSpeedRatings = 40
        FocalLengthIn35mmFilm = 26
        SubjectArea = 2006
        ExposureProgram = 2
        MeteringMode = 5
        Flash = 16
...deleted...


Or with (file DSCN0010.jpg)

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

  scalar structure containing the fields:

    Filename = /home/dmitri/Downloads/DSCN0010.jpg
    FileModDate = 10-Jun-2025 00:20:02
    FileSize = 161713
...deleted...
        ExifImageWidth = 640
        ISOSpeedRatings = 64
        FocalLengthIn35mmFilm = 112
        ExposureProgram = 2
...deleted...


There are more improvements can be done, but those are more involved. Perhaps we can do it in steps.

Dmitri.
--




Dmitri A. Sergatskov <dasergatskov>
Thu 12 Jun 2025 09:55:30 PM UTC, comment #5: 

I made a separate bug report (#67203) about the error in reading (possibly corrupted) EXIF data. I think we need to fix this one first before filling in some other missing features.

Dmitri.
--


Dmitri A. Sergatskov <dasergatskov>
Tue 10 Jun 2025 05:06:54 AM UTC, comment #4: 

It looks like Matlab may use dynamic structure. The text on their help page is ambiguous:
"The set of fields in info depends on the file and the format of the file. This table describes the fields in the structure."


I also tried some file from the sample page and got this:

octave:3> 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


Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Tue 10 Jun 2025 04:22:54 AM UTC, comment #3: 

These are  rich EXIF test images
https://github.com/ianare/exif-samples

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Mon 09 Jun 2025 11:13:05 PM UTC, comment #2: 

I suspect the issue is that Octave uses GraphicsMagick to extract EXIF, but GM does not do full extraction, only the info it may use itself.

I guess we can write extractor based on EXIV2, but that would add another dependence.

Nick -- your image did not attach, either it is too big, or you forgot?

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Mon 09 Jun 2025 04:13:15 PM UTC, comment #1: 

confirming that testing with Octave 10.2 and Matlab 2024b, Octave does not appear to retrieve all of the EXIF data contained in the image file.

Attached a test image (GPS info removed, as that data seemed fine).

Octave 10.2:



> imfinfo testimage.jpg
ans =

  scalar structure containing the fields:

    Filename = <fullpath>\testimage.jpg
    FileModDate =  9-Jun-2025 12:03:13
    FileSize = 3425375
    Format = JPEG
    FormatVersion =
    Width = 4000
    Height = 3000
    BitDepth = 8
    ColorType = truecolor
    DelayTime = 0
    DisposalMethod =
    LoopCount = 0
    ByteOrder = undefined
    Gamma = 0
    Chromaticities = [](1x0)
    Comment =
    Quality = 75
    Compression = undefined
    Colormap = [](0x0)
    Orientation = 6
    ResolutionUnit = undefined
    XResolution = 0
    YResolution = 0
    Software =
    Make = motorola
    Model = moto g power (2021)
    DateTime = 2025:05:19 19:09:46
    ImageDescription =
    Artist =
    Copyright =
    DigitalCamera =

      scalar structure containing the fields:

        DateTimeOriginal = 2025:05:19 19:09:46
        DateTimeDigitized = 2025:05:19 19:09:46
        SubSecTime = 508261
        SubSecTimeOriginal = 508261
        SubSecTimeDigitized = 508261
        ColorSpace = 1
        ExifImageWidth = 4000
        FocalLengthIn35mmFilm = 27
        ExposureProgram = 2
        MeteringMode = 2
        LightSource = 21
        Flash = 24
        SensingMethod = 1
        ExposureMode = 0
        WhiteBalance = 0
        SceneCaptureType = 0
        ExposureTime = 0.025000
        FNumber = 1.7000
        ShutterSpeedValue = 5.3210
        ApertureValue = 1.5300
        BrightnessValue = 0.6700
        ExposureBiasValue = 0
        MaxApertureValue = 1.5300
        FocalLength = 4.7100
        DigitalZoomRatio = 1

    GPSInfo =

      scalar structure containing the fields:

        GPSAltitudeRef = .
        GPSDateStamp = 2025:05:19
        GPSTimeStamp =

           23
            9
           39


Matlab 2024b

a =

  struct with fields:

              Filename: '<fullpath>\testimage.jpg'
           FileModDate: '09-Jun-2025 12:03:13'
              FileSize: 3425375
                Format: 'jpg'
         FormatVersion: ''
                 Width: 4000
                Height: 3000
              BitDepth: 24
             ColorType: 'truecolor'
       FormatSignature: ''
       NumberOfSamples: 3
          CodingMethod: 'Huffman'
         CodingProcess: 'Sequential'
               Comment: {}
                  Make: 'motorola'
                 Model: 'moto g power (2021)'
           Orientation: 6
     AutoOrientedWidth: 3000
    AutoOrientedHeight: 4000
           XResolution: 72
           YResolution: 72
        ResolutionUnit: 'Inch'
              DateTime: '2025:05:19 19:09:46'
      YCbCrPositioning: 'Centered'
         DigitalCamera: [1×1 struct]
               GPSInfo: [1×1 struct]
           UnknownTags: [1×1 struct]
         ExifThumbnail: [1×1 struct]

>> a.DigitalCamera

ans =

  struct with fields:

               ExposureTime: 0.0250
                    FNumber: 1.7000
            ExposureProgram: 'Normal program'
            ISOSpeedRatings: 125
                ExifVersion: [48 50 50 48]
           DateTimeOriginal: '2025:05:19 19:09:46'
          DateTimeDigitized: '2025:05:19 19:09:46'
    ComponentsConfiguration: 'YCbCr'
          ShutterSpeedValue: 5.3210
              ApertureValue: 1.5300
            BrightnessValue: 0.6700
          ExposureBiasValue: 0
           MaxApertureValue: 1.5300
               MeteringMode: 'CenterWeightedAverage'
                LightSource: 'D65'
                      Flash: 'Flash did not fire, no strobe return detection function, auto flash mode, flash function present, no red-eye reduction mode or unknown.'
                FocalLength: 4.7100
                  MakerNote: [77 79 84 0 1 1 1 1 0 53 85 0 0 2 0 0 0 20 … ] (1×1144 double)
                 SubsecTime: '508261'
         SubsecTimeOriginal: '508261'
        SubsecTimeDigitized: '508261'
            FlashpixVersion: [48 49 48 48]
                 ColorSpace: 'sRGB'
           CPixelXDimension: 4000
           CPixelYDimension: 3000
              SensingMethod: 'Not defined'
                  SceneType: 'A directly photographed image'
               ExposureMode: 'Auto exposure'
               WhiteBalance: 'Auto white balance'
           DigitalZoomRatio: 1
      FocalLengthIn35mmFilm: 27
           SceneCaptureType: 'Standard'
                UnknownTags: [2×1 struct]

>> a.ExifThumbnail

ans =

  struct with fields:

                    Compression: 'OJPEG'
                    Orientation: 6
                    XResolution: 72
                    YResolution: 72
                 ResolutionUnit: 'Inch'
          JPEGInterchangeFormat: 2698
    JPEGInterchangeFormatLength: 13256

>> a.UnknownTags

ans =

  struct with fields:

        ID: 59932
    Offset: 170
     Value: [28 234 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 … ] (1×268 double)

>> a.DigitalCamera.UnknownTags

ans =

  2×1 struct array with fields:

    ID
    Offset
    Value

>> a.DigitalCamera.UnknownTags.ID

ans =

       59932


ans =

       59933

>> a.DigitalCamera.UnknownTags.Offset

ans =

   930


ans =

     0

>> a.DigitalCamera.UnknownTags.Value

ans =

  Columns 1 through 15

    28   234     0     0     0     1     0     0     0     0     0     0     0     0     0

  Columns 16 through 30

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  Columns 31 through 45

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  Columns 46 through 60

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  Columns 61 through 75

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  Columns 76 through 90

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  Columns 91 through 105

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  Columns 106 through 120

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  Columns 121 through 135

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  Columns 136 through 150

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  Columns 151 through 165

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  Columns 166 through 180

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  Columns 181 through 195

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  Columns 196 through 210

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  Columns 211 through 225

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  Columns 226 through 240

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  Columns 241 through 255

     0     0     0     0     0     0     0     0     0     0     0     0     0     0     0

  Columns 256 through 268

     0     0     0     0     0     0     0     0     0     0     0     0     0


ans =

   625

>>


Nicholas Jankowski <nrjank>
Group Member
Mon 09 Jun 2025 03:06:48 PM UTC, original submission:  

Please refer to the command.  Both Octave and Matlab output were list below.  The output result were quite different and I can not find the ISO value from Octave output.  FYI.

Sincerely 

[OCTAVE]

>>   [fn,pth]=uigetfile('*.jpg');
>>   info = imfinfo([pth,fn]);
>>   info.DigitalCamera
ans =

  scalar structure containing the fields:

    SubSecTimeOriginal = 867
    SubSecTimeDigitized = 867
    ColorSpace = 65535
    ExifImageWidth = 4032
    FocalLengthIn35mmFilm = 26
    SubjectArea = 2006
    ExposureProgram = 2
    MeteringMode = 5
    Flash = 16
    SensingMethod = 2
    ExposureMode = 0
    WhiteBalance = 0
    SceneCaptureType = 0
    ExposureTime = 8.2645e-03
    FNumber = 1.5000
    ShutterSpeedValue = 6.9219
    ApertureValue = 1.1699
    BrightnessValue = 5.2521
    ExposureBiasValue = 0
    FocalLength = 5.7000


[MATLAB]


>> info.DigitalCamera

ans =

  struct with fields:

               ExposureTime: 0.0083
                    FNumber: 1.5000
            ExposureProgram: 'Normal program'
            ISOSpeedRatings: 40
                ExifVersion: [48 50 51 50]
    ComponentsConfiguration: 'YCbCr'
          ShutterSpeedValue: 6.9219
              ApertureValue: 1.1699
            BrightnessValue: 5.2521
          ExposureBiasValue: 0
               MeteringMode: 'Pattern'
                      Flash: 'Flash did not fire, no strobe return detection function, compulsory flash suppression, flash function present, no red-eye reduction mode or unknown.'
                FocalLength: 5.7000
                SubjectArea: [2006 1506 2213 1327]
                  MakerNote: [65 112 112 108 101 32 105 79 83 0 0 1 77 77 0 50 0 1 0 9 0 0 0 1 0 0 0 15 0 2 0 7 0 0 2 0 0 0 2 108 0 … ] (1×1759 double)
         SubsecTimeOriginal: '867'
        SubsecTimeDigitized: '867'
            FlashpixVersion: [48 49 48 48]
                 ColorSpace: 'Uncalibrated'
           CPixelXDimension: 4032
           CPixelYDimension: 3024
              SensingMethod: 'One-chip color area sensor'
                  SceneType: 'A directly photographed image'
               ExposureMode: 'Auto exposure'
               WhiteBalance: 'Auto white balance'
      FocalLengthIn35mmFilm: 26
           SceneCaptureType: 'Standard'
                UnknownTags: [4×1 struct]




Jack Huang <yhuangtc>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #57291:  das_magick_00.diff added by dasergatskov (1KiB - text/x-patch)
file #57290:  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 dasergatskov (Posted a comment)
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by yhuangtc (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-06-13 dasergatskov Attached File- Added das_magick_00.diff, #57291
    2025-06-13 dasergatskov Attached File- Added DSCN0010.jpg, #57290
    2025-06-09 nrjank StatusNone Confirmed
        Summary(imfinfo) Can not get the isovalue from a jpeg file imfinfo does not import full EXIF data from a jpeg file

    Back to the top

    Powered by Savane 3.15-26b0.
    Corresponding source code