Imagesharp: how to get image format from an Image<Rgba32> instance

Created on 12 Jan 2018  Â·  9Comments  Â·  Source: SixLabors/ImageSharp

if use System.Drawing, Image.RawFormat poperty can do it.

and how to do it, if use Image<Rgba32>

thanks!

question

Most helpful comment

All 9 comments

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 when that's only what you have and your method didn't call the load.

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\ How can that function figure out the format of the 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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vad3x picture vad3x  Â·  4Comments

marcpabst picture marcpabst  Â·  3Comments

JimBobSquarePants picture JimBobSquarePants  Â·  3Comments

devedse picture devedse  Â·  3Comments

Sergio0694 picture Sergio0694  Â·  3Comments