问题
how can i get dpi of an image using asp.net c#
回答1:
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;
回答2:
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");
}
}
}
来源:https://stackoverflow.com/questions/2054540/how-to-get-dpi-of-image-in-c-sharp