TechnikTobi / little_exif

A little library for reading and writing EXIF data in pure Rust.
Apache License 2.0
22 stars 5 forks source link

Could not get IFD0 tags! #11

Closed mschnell1 closed 2 months ago

mschnell1 commented 2 months ago

I do see e.g. comments inserted in a jpg file by the Windows 10+ explorer,but when trying to examine a file from a digital camera I get no fields but an errorCould not get IFD0 tags! (no panic).

I also tried the "revolt" fork with the same result.

Can this be improved ?

TechnikTobi commented 2 months ago

Hi, could you please provide an example image file so that I can reproduce this?

mschnell1 commented 2 months ago

-> https://www.bitvibe.de/Upload/A0579575.jpg

TechnikTobi commented 2 months ago

Thanks! Short update: The reason why this fails is that two EXIF tags are written using the wrong format (ExifImageWidth and ExifImageHeight should be INT32U but are written as INT16U). I'll work on a way for trying to convert values to the right format in such cases. You may expect an update with this feature in the upcoming days.

Edit: *sigh* according to the exiftool resource those two tags actually are supposed to be INT16U (I can't recall where I got the INT32U). However: Checking with the CIPA DC-008-2019 Exif 2.32 Specification page 41 and the updated Version 3.0 page 54 these tags may be either format. Nevertheless, I am working on a way to make this work either way for the user.

mschnell1 commented 2 months ago

This is a very new camera :) "ThumbsPlus" and "exiftool" seemingly can handle those jpgs. Great ! Thanks !

TechnikTobi commented 2 months ago

Please check if version 0.4.1 resolves this issue.

mschnell1 commented 2 months ago

Thanks a lot for the very fast update !

Seems to work now with an image from a -> Make("FUJIFILM") Model("X-T5") trying more pictures later today ....

does not work with an image from a "Xiaomi" "2312DRAABG" (whatever this is....) Error messages: Could not get IFD0 tags: Could not decode SubIFD: Illegal format for known tag! Tag: ExifVersion([]) Expected: UNDEF Got: STRING

I'll upload that file later today....

mschnell1 commented 2 months ago

In the debugger at metadata.rs line567 I see: number_of entries = 21, i = 9, hex_tag = 36864, hex_format= 2, hex_component_number = 4, encoded data = 0, '*', 0x82, 0x9Aa 0, 5, 0, 0, 0, 1, 0, 0, 5, 0x84, 0x82, 0x9d, .... maybe this helps....

mschnell1 commented 2 months ago

By a rust program I did using the kamadak-exif crate (whose writing feature is denoted "experimental" and I could not get it working at all), with another jpg file I see

Tiff 270
**** id ImageDescription = Thumbs Annotation 

but a rust program I did using little_exif does not show the description when doing

            for field in meta.data().iter() {
                match field {
                    ExifTag::ImageDescription(s) => {
                        println!("ImageDescription  : {}", s);
                    }

but does count 40 fields in that loop.

is TIFF ID 270 something different form little's ExifTag::ImageDescription ?

mschnell1 commented 2 months ago

now I used the example code from the readme file to write an image description to this file.

    let mut metadata = Metadata::new();
    metadata.set_tag(ExifTag::ImageDescription("Hello World!".to_string()));
    let res = metadata.write_to_file(std::path::Path::new(&file_path));
    println!("res: {:?}", res);

This does work without an error.

But then trying to read that file again with the "little_exif" code that worked before gets the error message:

thread 'main' panicked at C:\Users\mschnell\.cargo\registry\src\index.crates.io-6f17d22bba15001f\little_exif-0.4.1\src\metadata.rs:461:70:
range end index 2 out of range for slice of length 0

writing to the file made it from length 782701 to length 781906. The picture still can be shown and Windows Explorer indeed show "Hello World!" as "Betreff" (which before had been "Thumbs Annotation" ). But the ThumbsPlus software does not show any fields any more. Several Fields Explorer shows have been stayed intact, but the fields Auflösungseinheit Farbdardstellung Kamerahersteller Kameramodell Blendenzahl ISO Lichtwert Brennweite Maximale Blende Messmodus ... (and many more) Exif-Version (had been 0232)

are empty now.

mschnell1 commented 2 months ago

The not working picture is here -> https://bitvibe.de/Upload/IMG_20240828_184255.jpg

Error messages: Could not get IFD0 tags: Could not decode SubIFD

TechnikTobi commented 2 months ago

I referenced the different comments in their respective new issue just so that things don't get mixed up/confused.