if use System.Drawing, Image.RawFormat poperty can do it.
and how to do it, if use Image<Rgba32>
thanks!
There's an overload for Image.Load that passes an IImageFormat as an out parameter which will give you what you need.
P.S. We have a Gitter channel for questions. 😄
this still does not answer how to get format From Image
this still does not answer how to get format From Image when that's only what you have and your method didn't call the load.
What? This makes no sense.
Assume a function takes an "Image\
OK I understand now. Thanks.
At some point in your code you will have to load the image. That is when you capture the input format and pass it along to any other methods. We don't capture and hold the IImageFormat because it is a shared reference across all images and does more than the System.Drawing ImageFormat class which is basically a static class containing predefined identifiers.
A System.Drawing image has no defined format unless it is loaded from a stream. The format identifier defaults to an empty Guid.
I see.
Thank you.
No problem, happy to help.
what about LoadAsync()? It does not have this overload
well, then you would want to use LoadWithFormatAsync: :)
https://github.com/SixLabors/ImageSharp/blob/d95a996ed5ba14a1421dafeb844a56ab08211ead/src/ImageSharp/Image.FromStream.cs#L427
Most helpful comment
well, then you would want to use LoadWithFormatAsync: :)
https://github.com/SixLabors/ImageSharp/blob/d95a996ed5ba14a1421dafeb844a56ab08211ead/src/ImageSharp/Image.FromStream.cs#L427