如何检查图像质量

如何检查图像质量

本文介绍了如何检查图像质量/分辨率/dpi/ppi?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检查所选输入图像文件的当前质量(分辨率/dpi/ppi).

i want to check selected input image file's current quality (Resolution/dpi/ppi).

我的控件是图片上传器jquery插件.

my control is image uploader jquery plugin.

如何获取所选文件的质量?

How can i get the quality of selected file?

(我需要选择图像文件的分辨率而不是屏幕分辨率)

推荐答案

注意:

答案是在C#中而不是Javascript中,没有办法在JS中做到这一点,这在原始问题中不是必需的.

Note:

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

这很大程度上取决于您认为高质量"的内容.图片(BTW不错).但是无论如何,品质因数不会直接存储在JPEG文件中,因此您无法直接从文件中读取.

This is a big dependency of what you consider a "high quality" Image (nice reading BTW). But anyway the quality factor is not stored directly in the JPEG file, so you cannot read directly from the file.

这些因素大多数涉及复杂的成像算法.但是请不要失望,您可以使用Image类的PropertyItems属性读取一些属性,并进行一些计算,以便根据尺寸和dpi或ppi了解图像的质量.这是一个简单的示例:

Most of these factors involve complex imaging algorithms. But do not be disappointed, you can read some properties using the PropertyItems property on the Image class and make some calculations to get an idea of the quality of the image 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);

这也将有所帮助:

如果要在上传之前检查图像质量(如您在评论中所述),那么这是一个很大的问题.唯一要获取的数字的内置方法是创建一个新实例(并对整个图像进行解码),这将非常低效.但是...嘿!这是一个起点:

If you want to check the image quality before upload (as you said in comments), that's a big plus to the question. The only built-in method to get the numbers you're after is by creating a new instance (and decoding the entire image) - which is going to be highly inefficient. But... hey! here is a start point: How do I reliably get an image dimensions in .NET without loading the image?

  • Reading Image Headers to Get Width and Height
  • http://en.wikipedia.org/wiki/Image_quality

这篇关于如何检查图像质量/分辨率/dpi/ppi?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 22:07