How can I obtain human readable string(i.e. image format itself) from System.Drawing.ImageFormat object?
I mean if I have ImageFormat.Png
is that possible to convert it to "png" string?
EDIT: I see some misunderstanding here. Here is mine code:
Image objImage = Image.FromStream(file);
ImageFormat imFormat = objImage.RawFormat;
imFormat.ToString();
It returns "[ImageFormat: b96b3caf-0728-11d3-9d7b-0000f81ef32e]
" but I want "Png
"!
Use the ImageFormatConverter class from the System.Drawing namespace:
this.imageInfoLabel.Text =
new ImageFormatConverter().ConvertToString(this.Image.RawFormat);
For a PNG image it returns Png, and so on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With