How to Get DPI of Image in C#

Avinash picture Avinash · Jan 13, 2010 · Viewed 17.7k times · Source

how can i get dpi of an image using asp.net c#

Answer

Benny picture Benny · Jan 13, 2010

How about Image.HorizontalResolution and Image.VerticalResolution? Like this:

System.Drawing.Image image = System.Drawing.Image.FromFile("TestImage.bmp");
var dpiX = image.HorizontalResolution;
var dpiY = image.VerticalResolution;