kamadak / exif-rs

Exif parsing library written in pure Rust
BSD 2-Clause "Simplified" License
190 stars 42 forks source link

Get a NotFound("JPEG") Error #28

Closed firewave-remo closed 1 year ago

firewave-remo commented 1 year ago

Thanks for your library!

I do have a problem with the following image Lüftung2

The following code panics with the error: thread 'main' panicked at 'calledResult::unwrap()on anErrvalue: NotFound("JPEG")', src/main.rs:19:63

fn main() {
    let img = File::open("./Lüftung2.jpg").unwrap();
    let mut bufreader = BufReader::new(&img);
    let exifreader = exif::Reader::new();
    let exif = exifreader.read_from_container(&mut bufreader).unwrap();
}

Unfortunately, I don't know anything about JPEGs and if the image is malformed or if it is a bug. But I am happy to help if there are any questions.

Here is the output of ImageMagick and exiftool:

➜  image-test git:(master) ✗ identify -verbose Lüftung2.jpg 
Image:
  Filename: Lüftung2.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 960x1280+0+0
  Resolution: 72x72
  Print size: 13.3333x17.7778
  Units: PixelsPerInch
  Colorspace: sRGB
  Type: TrueColor
  Base type: Undefined
  Endianness: Undefined
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Pixels: 1228800
    Red:
      min: 36  (0.141176)
      max: 255 (1)
      mean: 155.556 (0.610025)
      standard deviation: 50.0169 (0.196145)
      kurtosis: -1.58156
      skewness: -0.497433
      entropy: 0.755686
    Green:
      min: 32  (0.12549)
      max: 255 (1)
      mean: 152.572 (0.598321)
      standard deviation: 54.5694 (0.213998)
      kurtosis: -1.58949
      skewness: -0.498145
      entropy: 0.757643
    Blue:
      min: 28  (0.109804)
      max: 255 (1)
      mean: 148.58 (0.582668)
      standard deviation: 58.4767 (0.22932)
      kurtosis: -1.60867
      skewness: -0.48949
      entropy: 0.765525
  Image statistics:
    Overall:
      min: 28  (0.109804)
      max: 255 (1)
      mean: 152.236 (0.597005)
      standard deviation: 54.3543 (0.213154)
      kurtosis: -1.54607
      skewness: -0.515057
      entropy: 0.759618
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: white
  Border color: srgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 960x1280+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 90
  Orientation: Undefined
  Properties:
    date:create: 2023-02-06T16:22:51+00:00
    date:modify: 2023-02-06T16:15:45+00:00
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x2,1x1,1x1
    signature: ae7bf3b446d5765574b619e147fb764e092b47ebc8de29b09e34ee8168aa721e
  Artifacts:
    filename: Lüftung2.jpg
    verbose: true
  Tainted: False
  Filesize: 84886B
  Number pixels: 1228800
  Pixels per second: 87.8001MB
  User time: 0.010u
  Elapsed time: 0:01.013
  Version: ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25 https://imagemagick.org
➜  image-test git:(master) ✗ exiftool Lüftung2.jpg 
ExifTool Version Number         : 12.40
File Name                       : Lüftung2.jpg
Directory                       : .
File Size                       : 83 KiB
File Modification Date/Time     : 2023:02:06 17:15:45+01:00
File Access Date/Time           : 2023:02:06 17:22:51+01:00
File Inode Change Date/Time     : 2023:02:06 17:22:51+01:00
File Permissions                : -rw-rw-r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : inches
X Resolution                    : 72
Y Resolution                    : 72
Image Width                     : 960
Image Height                    : 1280
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 960x1280
Megapixels                      : 1.2
kamadak commented 1 year ago

That file actually does not have Exif data. ImageMagick and exiftool are showing other metadata than Exif. See also issue #24.

firewave-remo commented 1 year ago

Thx, sorry I saw that issue but I did not carefully read everything. My bad. But maybe the error could have a better name? Like NoExifDataFound or something like that. Or maybe just return empty Exif data instead of an Error?

Thx anyway for your lib!