DEBUG and RELEASE modeTrying to load the JPG image below throws the following

SixLabors.ImageSharp.UnknownImageFormatException: Image cannot be loaded. Available decoders:
- TGA : TgaDecoder
- PNG : PngDecoder
- BMP : BmpDecoder
- JPEG : JpegDecoder
- GIF : GifDecoder
The sample code
using (Image image = await Image.LoadAsync(imageStream))
{
PngEncoder pngEncoder = new PngEncoder();
pngEncoder.CompressionLevel = PngCompressionLevel.BestCompression;
await image.SaveAsync(imageStream, pngEncoder);
imageStream.Seek(0, SeekOrigin.Begin);
}
Unless you have reset the position of the input stream before the code sample you posted then it looks like your input stream is in the wrong position. We do not reset that position for you on load unless explicitly instructed to do so.
Here's the result of loading the image and saving it as a png.

Hey @JimBobSquarePants
Thanks for the tip, I'll try it out.
Cheers.
Still not working. I suspect Github altered the original image.
Can you try again, please?
https://we.tl/t-85LLGWncqZ
using (Image image = await Image.LoadAsync(GetImageSharpConfiguration(), imageStream))
{
PngEncoder pngEncoder = new PngEncoder();
pngEncoder.CompressionLevel = PngCompressionLevel.BestCompression;
await image.SaveAsync(imageStream, pngEncoder);
imageStream.Seek(0, SeekOrigin.Begin);
}
private static Configuration GetImageSharpConfiguration()
{
var configuration = new Configuration();
configuration.ReadOrigin = ReadOrigin.Begin;
return configuration;
}
You haven't populated the new Configuration you have generated with any codecs.
If you want to return a new configuration containing all the existing codecs you should do this.
```c#
private static Configuration GetImageSharpConfiguration()
{
var config = new Configuration(
new PngConfigurationModule(),
new JpegConfigurationModule(),
new GifConfigurationModule(),
new BmpConfigurationModule(),
new TgaConfigurationModule());
config.ReadOrigin = ReadOrigin.Current;
return config;
}
If you want to reset the stream everywhere you use the library you can set the default config instead.
```c#
var config = Configuration.Default;
config.ReadOrigin = ReadOrigin.Begin;
Or change Configuration.Default.ReadOrigin, or (IMO the best solution) just imageStream.Seek(0, SeekOrigin.Begin) before the image loads on misaligned streams.
Yup, I would choose to be explicit and reset my stream positions. Less possibility of unintended results.