oozcitak / exiflibrary

A .Net Standard library for editing Exif metadata
MIT License
131 stars 48 forks source link

Add an option to continue when invalid/unsupported tags are found? #85

Open ziriax opened 3 years ago

ziriax commented 3 years ago

The attached JPEG causes ExifLibrary to crash. Would it make sense to add an option to continue on errors, forwarding any unsupported or invalid tags to an event or callback?

subifd

ziriax commented 3 years ago

This doesn't seem to crash with the latest master bits. Nevertheless ExifPropertyFactory still does throw new ArgumentException("Unknown property type.");. It would make more sense to add such an exception to the Errors no?

ziriax commented 3 years ago

It seems extra code was added to check the tag types when loading, however, it seems that in JPEGFile.cs the code is:

                    // Calculate the bytes we need to read
                    uint baselength = 0;
                    if (type == 1 || type == 2 || type == 6 || type == 7)
                        baselength = 1;
                    else if (type == 3 || type == 8)
                        baselength = 2;
                    else if (type == 4 || type == 9)
                        baselength = 4;
                    else if (type == 5 || type == 10)
                        baselength = 8;
                    else // Unknown or invalid type
                        continue; // Skip and keep going

while in ExifLibrary/ExifPropertyFactory.cs, also the types 11 and 12 are checked.

Maybe types 11 and 12 can't occur in a JPEG file? Not sure