0

I've donwloaded an image from user manual (see attachment) and need to transform it. When I tried to load it via following code, I got the exception: "Image cannot be loaded. Available decoders:\r\n - JPEG : JpegDecoder\r\n - PNG : PngDecoder\r\n - GIF : GifDecoder\r\n - BMP : BmpDecoder\r\n". Is it possible to apply custom decoder and where can I found them?

using (var originalImage = new MemoryStream(...))
using (var image = Image.Load<Rgba32>(originalImage))
{

}
shaddow
  • 107
  • 1
  • 1
  • 12
  • 1
    you will find you have likely just not reset the memory stream position before you tried loading as an image. Your sample isn't what you've described as the problem it probably related to the way you care gettting the stream etc rather than Image.Load – tocsoft May 03 '19 at 12:44
  • Unfortunately, no... There is something strange with the image. I've tried to download the image (click save as) and it perfectly been transformed, but the original image (click on "open with" and then "download" on the dropbox window) it fails as described abowe. Moreover, command `Image.DetectFormat` returns null – shaddow May 05 '19 at 19:50

1 Answers1

1

The linked image can be decoded using ImageSharp. As @tocsoft says in the comments it likely you forgot to reset your input stream position.

Here's the two images. The second we've loaded and flipped vertically using the following code:

using (var image = Image.Load(Path.Combine(inPath, "-7bH2hfA.png")))
{
    image.Mutate(x => x.Flip(FlipMode.Vertical));

    image.Save(Path.Combine(outPath, "-7bH2hfA-flipped.png"));
}

Your input image:

Input image

Our flipped output image:

Flipped output image

EDIT

When I originally tested the image I used r-click save which gave me a valid png. I have since used the direct download from Dropbox which yields the original file.

It's not a png! It is, in fact, a webp file.

Hex Dump of original image

James South
  • 10,147
  • 4
  • 59
  • 115
  • Can you please read my the latest comment for the issue. It seems that theris something strange with the image. – shaddow May 05 '19 at 20:35