Our clients will be uploading images to be printed on their documents and we have been asked to come up with a way to get the resolution of the image in order to warn them if the image has too low of a resolution and will look pixalated in the end-product
If it comes to it we could also go with the dimensions if anyone knows how to get those but the resolution would be preferred
Thank you
System.Drawing.Image
Image newImage = Image.FromFile("SampImag.jpg");
newImage.HorizontalResolution
It depends what you are looking for... if you want the DPI of the image then you are looking for the HorizontalResolution which is the DPI of the image.
Image i = Image.FromFile(@"fileName.jpg");
i.HorizontalResolution;
If you want to figure out how large the image is then you need to calculate the measurements of the image which is:
int docHeight = (i.Height / i.VerticalResolution);
int docWidth = (i.Width / i.HorizontalResolution);
This will give you the document height and width in inches which you could then compare to the min size needed.
DPI take sense when printing only. 72dpi is the Mac standard and 96dpi is the Windows standard. Screen resolution only takes pixels into account, so a 72dpi 800x600 jpeg is the same screen resolution than a 96dpi 800x600 pixels.
Back to the '80s, Mac used 72dpi screen/print resolution to fit the screen/print size, so when you had an image on screen at 1:1, it correspond to the same size on the printer. Windows increased the screen resolution to 96dpi to have better font display.. but as a consequence, the screen image doesn't fit the printed size anymore.
So, for web project, don't bother with DPI if the image isn't for print; 72dpi, 96dpi, even 1200dpi should display the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With