How to get resolution from an image? I have a web application and I need to get this data from an image on localhost.
How to get resolution from an image? I have a web application and I need to get this data from an image on localhost.
If it's height and width, it's fairly simple:
string path = @"C:\caminho\qualquer\minha_imagem.jpg";
var img = Image.FromFile(path);
// img.Width é a largura
// img.Height é a altura
Now, if you want the pixels per inch (semantically closer to an image resolution), it would look something like:
string path = @"C:\caminho\qualquer\minha_imagem.jpg";
var img = Image.FromFile(path);
var graf = Graphics.FromImage(img);
var resolucao = (bmp.Width / bmp.HorizontalResolution) * graf.DpiX;