views:

47

answers:

1

I want to know if its possible (and how) to check for real image quality (.jpg) using the GD library.

Obviously we need to check for file size, colors, image size, and number of pixels and compare between them.

For example if an 1200x600px image has a size of 60kb probably its in bad quality. But if the image is in grey scale, or uses only some colors, then maybe its in good quality...

So... any ideas?

+2  A: 

What you want is a no-reference image quality assessment. I don't know of a specific implementation for PHP but you can take a look in IEEE Transactions on Image Processing for algorithms.

There's an implementation with focus on JPEG compression here:

http://www.cns.nyu.edu/~zwang/files/research/nr_jpeg_quality/index.html

Vitor Py
I'm looking for something more simple, using the GD library...
Jonathan
Image quality when you don't have a reference image to compare to is not usually simple. I'd suggest you just to write down some heuristics - like if it's a color image, it should have at least 24 bits per pixel. Not perfect, but simple.
Vitor Py
Any hints on a basic check using GD library?
Jonathan
@Jonathan, a very very very (I can't express *very* enough) basic check is to require a true color image. http://www.php.net/manual/en/function.imageistruecolor.php
Vitor Py