In a certain area of an educational website, students scan and submit their homework.
Problem: When students use pencil, the scans end up being very light and hard to read.
Can PHP be used to some how detect if a scan is too light? I'm wondering if something like Detecting colors for an Image using PHP or maybe How to detect "light" colors with PHP could be used, but I'm not sure. Thus the question.
I'm not asking for code necessarily, just seeing if it's possible and if there's some kind of function that already exists for this sort of thing.
UPDATE BASED ON h2ooooooo's ACCEPTED ANSWER
I'm wondering if PNG bit depth is causing a problem here. Using his (her?) solution, consider the following...
This image ("1.png") returns 97.8456638355 and has a bit depth of 32...
However, this image ("2.png") returns 98.4853859241 and has a bit depth of 24...
This is a difference of less than 1% and it seems like the 1.png should return with a lower number as it is significantly "crisper" and overall is darker than 2.png.
Does anyone have an idea if bit depth is causing the script to not work correctly?