How to read the width and height of a physical image-type file?

3

How to get width and height of a physical image file?

    
asked by anonymous 21.01.2015 / 15:01

2 answers

4

You can get this information by using the Image , through the Height and Width .

System.Drawing.Image img = System.Drawing.Image.FromFile(@"c:\Path.jpg");
MessageBox.Show("Width: " + img.Width + ", Height: " + img.Height);

Font

    
21.01.2015 / 15:04
3

You can for some supported formats:

var imagem = Image.FromFile("teste.jpg");
var largura = imagem.Width;
var altura = imagem.Height;

According to documentation you can open BMP, GIF, JPEG, PNG and TIFF files.

    
21.01.2015 / 15:05