Adsence750x90

Thursday, November 27, 2008

Get DPI of a Image in C# ASP.NET - calculate dots per inch ( DPI )

What is DPI of a Image? DPI means dots per inch. how to get DPI of a Image when we upload file?

System.IO.MemoryStream mm = new System.IO.MemoryStream();
mm.Write(FileUpload1.FileBytes, 0, FileUpload1.FileBytes.Length);
System.Drawing.Image img = System.Drawing.Image.FromStream(mm);
Response.Write("Horizondal Resolution :" + img.HorizontalResolution.ToString());
Response.Write("Veritcal Resolution :" + img.VerticalResolution.ToString());
Response.Write("Pixel Format :" + img.PixelFormat);
Response.Write("Physical Dimension Height:"+img.PhysicalDimension.Height.ToString());
Response.Write("Physical Dimension Width:"+ img.PhysicalDimension.Width.ToString());
img.Dispose();
mm.Dispose();

Output
Horizondal Resolution :89.9922
Veritcal Resolution :89.9922
Pixel Format :Format32bppArgb
Physical Dimension Height :1200
Physical Dimension Width :1600

1 comment:

Sameer said...

Hi,
I wanted to know if there is any way we can calculate ink to be used to print a file (say .pdf, .doc etc.). Is there any way we can calculate the RGB or CMYK or dots on a file and can convert it into ink to be used to print the same file?