How to check image quality / resolution / dpi / ppi?

I want to check the current quality of the selected input image file (Resolution / dpi / ppi) .

My control is a jQuery plugin for loading images.

How can I get the quality of the selected file?

(I need the selected image file resolution not to be screen resolution)

+7
source share
1 answer

Note:

The answer to C # is not Javascript, there is no way in JS to do this, and this was not a requirement in the original question.

About your original question

This is very dependent on what you consider to be a “high-quality” image (a pleasant reading of BTW). But in any case, the quality factor is not stored directly in the JPEG file, so you cannot read directly from the file.

Most of these factors are associated with complex visualization algorithms. But don't be disappointed, you can read some properties using the PropertyItems in the Image class and do some calculations to get an idea of ​​the image quality based on size and dpi or ppi. This is a simple example:

 Bitmap bmp = new Bitmap("winter.jpg"); Console.WriteLine("Image resolution: " + bmp.HorizontalResolution + " DPI"); Console.WriteLine("Image resolution: " + bmp.VerticalResolution + " DPI"); Console.WriteLine("Image Width: " + bmp.Width); Console.WriteLine("Image Height: " + bmp.Height); 

This will also help: How can I get image resolution? (JPEG, GIF, PNG, JPG)

"But I want to check the quality of the selected files before downloading"

If you want to check the image quality before downloading (as you said in the comments), this is a big plus to the question. The only built-in method for getting the numbers you use is to create a new instance (and decode the whole image), which will be very inefficient. But hey! here's the starting point: How can I reliably get image sizes in .NET without loading the image?

Further reading:

+5
source

All Articles