How to get image size from base64
in C#?
Is it possible to do at all?
Not directly as it depends on what data/format is encoded in the Base64 string. A rough approach would be (code not tested):
byte[] image = Convert.FromBase64String("Your Base64 string here");
using (var ms = new MemoryStream(image))
{
Image img = Image.FromStream(ms);
return new Tuple<int, int>(img.Width, img.Height); // or some other data container
}
Note: Image class comes from System.Drawing
.
See also the MSDN System.Drawing.Image class' documentation documentation.
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