I am trying to validate certain images to not allow images lower than 300 pixels per inch, is there a way to find it on ASP.NET using C#?
相关问题
- Views base64 encoded blob in HTML with PHP
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- How to get the background from multiple images by
- Carriage Return (ASCII chr 13) is missing from tex
You've got to read EXIF data from the image.
Here you have an example of how you can do it, using ExifLib
ExifLib - A Fast Exif Data Extractor for .NET 2.0+
Be warned that not all jpeg images have the resolution information. And, that even if they have it, you can print them using a completely different resolution. I.e. a pic 200px wide can be printed using 1 inch width is 200dpi. This same image printed using 2 inches is 100dpi, and using 1/2 inch is 400dpi.
EDIT: It's even possible to get this info with native .NET framework Image.PropertyItems Property
The
Image
object of the .NET Framework will give you the PPI of a Bitmap (including a JPG).Seems to work for me. I was able to discern that a specific image I am using in a PDF is 90 ppi.