PHP color related problem
Ok this time I've got a problem with PHP :D I've made a code that takes the images average color. That was the easy part but what I had in mind was a code that would check if the images average color is between certain RGB values. Like if the image is mostly blue or mostly yellow. The problem is that I can't just check for R, G and B that they are between the given R, G and B because it would include other colors too and not only the shades of that certain colour I want the image to be.
So does anyone know any code/way to check if color is between 2 given colors? Or would this go too complicated?
EDIT: I may have thought this wrong too. Probably stupid & impossible idea.
I only got the average color code (and upload code) but it's already working fine. I only tried to check if the average colors each value (R, G and B) were in between of given R, G and B… But it allows so many other colors so it won't work that way. If you want to see that code it's here:
$keski=explode("-",$keski);
if($keski[0]>103 && $keski[0]<256 && $keski[1]>30 && $keski[1]<223 && $keski[2]>15 && $keski[2]<112) {
$keskicheck = true;
}
$keski is the average color taken from the image and it's R-G-B so that's why I explode "-".
Hmm that's actually good idea :) If I use that AND check that all the R, G and B are between the RGB values I use then it might work.
EDIT: I did it like this now:
if($keski[0]>103 && $keski[0]<256 && $keski[1]>30 && $keski[1]<223 && $keski[2]>15 && $keski[2]<112) {
$keskicheck = true;
}
if($keski[0]>$keski[1] && $keski[0]>$keski[2] && $keski[1]>$keski[2]) {
$keskicheck2= true;
}```
Gotta go try if it works -->
Now it's working pretty well. I'm using it to check if the image is sepia like. Though you can still do something like write "LOL" with red in the center and it still passes it :/
But I've got solution for that too :D I check every pixel for sepia color and not the average. (It's almost same as my average script). I didn't think this would actually end up working!
Thanks richohealey!