I'm working on a simple image gallery project and I'd like to implement the ability to search based on a color hex code. So if someone enters 'ff1212' into the search, it will display only those images that contain that particular shade of red. I've seen a website that has a search that works the way I want: http://cssline.com (the AJAX part is nice, but its the server-side stuff I'm after).
I can't figure out how to store the color data from each image. Should I get each unique hex code used in an image and store them as tags in a database? It seems like this would create a huge dataset which would slow down the search. What about storing the images themselves in the database and scanning their colors during the search? That also sounds like it would be slow. I know that once I figure out how to store the data for speedy searching I can figure out how to code the search itself.
Does anybody have any tips or advice that can help me?