oozcitak / exiflibrary

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

Issue loading specific image #111

Open devedse opened 1 year ago

devedse commented 1 year ago

Hello,

I found another image that fails to load in ExifLibrary. As far as I can see it loads fine in other tools though: ECT_lmdonpba ECT_lmdonpba.zip

Could you maybe have a look into what's going on?

Devedse

devedse commented 1 year ago

@oozcitak , hey, wanted to ask if you had time to look into this yet.

T0T4R4 commented 1 year ago

I have the same issue here. An image which can load successfully in a MAUI app and to which the Exif metadata gets updated by this library fails to be loaded by a .NET 6 webapp, with the error below :

Source array was not long enough. Check the source index, length, and the array's lower bounds. (Parameter 'sourceArray')

thrown on this line(https://github.com/oozcitak/exiflibrary/blob/1e0f8381cf9ed1788fd24d9a0ee1b8a7d198abdc/ExifLibrary/ExifBitConverter.cs#L199)

   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length)

   at ExifLibrary.ExifBitConverter.ToURationalArray(Byte[] data, Int32 count, ByteOrder frombyteorder) in .\exiflibrary\ExifLibrary\[ExifBitConverter.cs:line 199]
   at ExifLibrary.ExifPropertyFactory.Get(UInt16 tag, UInt16 type, UInt32 count, Byte[] value, ByteOrder byteOrder, IFD ifd, Encoding encoding) in .\exiflibrary\ExifLibrary\ExifPropertyFactory.cs:line 141
   at ExifLibrary.JPEGFile.ReadExifAPP1() in .\exiflibrary\ExifLibrary\JPEGFile.cs:line 736
   at ExifLibrary.JPEGFile..ctor(MemoryStream stream, Encoding encoding, Boolean readTrailingData) in .\exiflibrary\ExifLibrary\JPEGFile.cs:line 176
   at ExifLibrary.ImageFile.FromStreamInternal(MemoryStream stream, Encoding encoding) in .\exiflibrary\ExifLibrary\ImageFile.cs:line 278
   at ExifLibrary.ImageFile.FromStream(Stream stream, Encoding encoding) in .\exiflibrary\ExifLibrary\ImageFile.cs:line 167
   at ExifLibrary.ImageFile.<FromStreamAsync>d__38.MoveNext() in .\exiflibrary\ExifLibrary\ImageFile.cs:line 252
   at ExifLibrary.ImageFile.<FromFileAsync>d__36.MoveNext() in .\exiflibrary\ExifLibrary\ImageFile.cs:line 230
   at ExifLibrary.ImageFile.<FromFileAsync>d__35.MoveNext() in .\exiflibrary\ExifLibrary\ImageFile.cs:line 214

   at MyWebsite.Controllers.MobileAppController.<ReadExif>d__6.MoveNext() in C:\Users\MyUser\Documents\MyWebsite\Controllers\MobileAppController.cs:line 62
   at MyWebsite.Controllers.MobileAppController.<SavePhoto>d__7.MoveNext() in C:\Users\MyUser\Documents\MyWebsite\Controllers\MobileAppController.cs:line 137