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

Can't open JPG file - Wrong signature #26

Closed mschnell1 closed 1 month ago

mschnell1 commented 1 month ago

With one file I get

Error during decoding: Custom { kind: InvalidData, error: "Can't open JPG file - Wrong signature!" }
WARNING: Can't read metadata - Create new & empty struct
Error: Can't open JPG file - Wrong signature!

even though I use new_from_vec and hence no fir to be opened.

Other than with the other "New Exif" messages of the library, here this is the last line I see then the program terminates within the library without a panic.

Thumbsplus tells me that this file as an alpha lane (I did not know that is possible with jpg)

I suppose it's a png with a wrong jpg extension. So I converted it to jpg and it does work. :)

the file is www.bitvibe.de/Upload/Weihegold_adam_2017.jpg

mschnell1 commented 1 month ago

BTW.: I found that the files that don't have exif information seem top be decently handles and jet just the ImageDescription Tag. Unfortunately ThumbsPlus does not see same, but Explorer does. The message printed by the galley is not necessary in the released version, as the caller can see the fact that the exif information is new by data.len() = 0

BTW.: the text provided by the library states several different reasons for creating new EXIF.

TechnikTobi commented 1 month ago

even though I use new_from_vec and hence no fir to be opened.

That's because the contents of the vec are conceptually treated as a file, hence the message.

Thumbsplus tells me that this file as an alpha lane (I did not know that is possible with jpg)

It isn't possible. It's a PNG.

I suppose it's a png with a wrong jpg extension. So I converted it to jpg and it does work. :)

It's a PNG.

the file is www.bitvibe.de/Upload/Weihegold_adam_2017.jpg

Strangely enough, when downloading this file on my machine it automatically adds a .png extension (because, yes, it's a PNG).

File extensions are merely a hint to the user and possibly an application and not definitive about the file format. You could consider this to be a shortcoming of little_exif, where a .jpg file is expected to have the structure of a JPG file. I'm thinking about an "Auto-Detect" feature that is not based on file names but on the first few bytes of the file. Of course, in cases like yours you would remain unaware of the wrong extension with such a feature.

TechnikTobi commented 1 month ago

BTW.: I found that the files that don't have exif information seem top be decently handles and jet just the ImageDescription Tag. Unfortunately ThumbsPlus does not see same, but Explorer does. The message printed by the galley is not necessary in the released version, as the caller can see the fact that the exif information is new by data.len() = 0

BTW.: the text provided by the library states several different reasons for creating new EXIF.

If I understand you correctly, this is already covered by issue #29, correct? If so I'm closing this issue to prevent any chaos.

mschnell1 commented 1 month ago

Yep !