how can i get dpi of an image using asp.net c#
Asked
Active
Viewed 2.2k times
2 Answers
26
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;

Andrew Truckle
- 17,769
- 16
- 66
- 164

Benny
- 8,547
- 9
- 60
- 93
-
The property comment says that that's _pixels_ per Inch, though... not dots per inch. Not sure if there's a difference... – Nyerguds Jan 09 '18 at 15:28
1
The answer is stated in this post, which sources it's code from here:
using System;
using System.Drawing;
namespace BitmapDpi
{
class Program
{
static void Main(string[] args)
{
Bitmap bmp = new Bitmap("winter.jpg");
Console.WriteLine("Image resolution: " + bmp.HorizontalResolution + "DPI");
}
}
}

JHBonarius
- 10,824
- 3
- 22
- 41

garyj
- 1,302
- 2
- 13
- 22