-1

I have a website with articles and pages having images. For sharing purposes, I need to get the dimensions of images for open graph meta property. The images are saved in a folder in my account.

Please tell me how can I get the dimensions of an image in my application folder.

Pankaj Upadhyay
  • 12,966
  • 24
  • 73
  • 104

2 Answers2

3
using (var bmp = Image.FromFile(@"path_to_image"))
{
    var width = bmp.Width;
    var height = bmp.Height;
}
bixarrio
  • 373
  • 1
  • 10
0

You'll load the image in, and access its width and height properties.

I suppose you'd like to see some code? Maybe in future post the code you have tried - and don't expect anyone to do it for you.

But here i am contradicting myself, you'll need something like this:

System.Drawing.Image image = System.Drawing.Image.FromFile("the/path/to/your/image.jpg");
// you then access properties like so:
image.Width;
image.Height;
Stuart
  • 6,630
  • 2
  • 24
  • 40