You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Not able to read jpg from stream when other data comes first -> Missing SOI #818
I have verified that I am running the latest version of ImageSharp
I have verified if the problem exist in both DEBUG and RELEASE mode
I have searched open and closed issues to ensure it has not already been reported
Description
Writing a jpg to a stream and reading it back is working. But only when there is no other data in front. If we write something else to the stream first and the image data after that, we get an "missing SOI" exception while reading back (although we start at the correct stream position). When the exception is thrown, stream.Position is 4096. So my guess is, the data is read blockwise and there is one method that does not calculate the initial offset.
Steps to Reproduce
Open a memory stream
Write some data (e.g. an integer) to the stream, then write the image data (Image.SaveAsJpeg)
Set Stream.Position to 0
Get a BinaryReader on the stream
Read the Int32, so Stream.Position is now "4"
Now we should be able to read the jpg back but we get an exception ("Missing SOI"). Stream.Position is now 4096 (actual stream.Length is much longer).
Activity