Is it really necessary to raise an Exception for invalid exif data? #100
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I regularly get sent files containing the invalid exif rotation value 0 (only 1-8 is acceptable according to the specification). All other programs handle these files without trouble and just assume no rotation. Img2pdf stops with an ExifOrientationError, though.
I have now added a pre-processing code to my program that removes invalid exif data using piexif + tempfiles, but I quite dislike this workaround, some key reasons are:
Is it really necessary to raise an Exception for invalid rotation data? Wouldn't it be enough to just print a warning and continue?
Relevant code passage
see also: #61
IMHO, reporting the problem to the manufacturers of phones / cameras that produce these invalid rotation values is not a promising approach, because
I see the problem. I think I can be convinced to add an option to img2pdf which allows to ignore the exif rotation. And if rotation is ignored, it also doesn't make sense to error out on invalid rotation values.
Thank you, this would already be an acceptable solution.
However, completely ignoring exif rotation is not exactly what I was looking for. I rather meant an option to fall back to no rotation if the exif value is invalid or unsupported. If there is a valid rotation tag, I'd like to use it.
This pains me. If I tell a program "use the exif data for rotation" and the exif rotation data is invalid, then I expect the program to fail because it cannot fulfill my request. I understand that you want a "use exif data for rotation if the exif information is valid". How about an option like this:
The same functionality would of course be exposed in the library interface.
Yes, that looks very good.
@mara0004 Do you happen to have examples of software, cameras or phones that do set the invalid exif rotation of zero?
Yes. According to the exif data, the problematic files I have were produced by a
Huawei VOG-L29
phone. The detailed version string is10.1.0.181(C431E23R2P5)
. Though the cause might also be the application the pictures were taken (or edited) with, this I do not know.