i want to check selected input image file’s current quality (Resolution/dpi/ppi).
my control is image uploader jquery plugin.
How can i get the quality of selected file?
(i need selected image file’s resolution not screen resolution)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.
About your original question
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.
Most of these factors involve complex imaging algorithms. But do not be disappointed, you can read some properties using the
PropertyItemsproperty 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:This will help too: How can I get the resolution of an image? (JPEG, GIF, PNG, JPG)
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?
Further reading: