First, I wonder how you can crawl sites / directories to find a specific color of an image if you don't have a large list of websites. If this is not related to your question, then just ignore it.
Returning to your question, I personally think that this is an interesting question. Since this requires a lot of research, I just want to point out some ideas for you.
What you need to do is get the user-defined hexadecimal colors and convert them to RGB colors, because most of the image functions in PHP, which, as I know, work only with RGB. Now, if you have a list of directories that you can search for, just scan them and use some basic functions to get the contents of the desired web page (for example, file_get_contents or cURL ). If you have the content of a specific page, you will need to use the DOM functions to get the URLs of the images from that page (you can solve it yourself using: getElementsByTagName () and getAttribute () ), Now, assuming you keep the list The URLs of the images, now you need to get their colors and try to match them with the colors you specify (don't forget to convert everything to RGB).
In PHP, we have a very handy GD library that works with images. If your server supports GD2, you can look at imagecolorclosest () . This function "Returns the color index in the palette of the image" closest "to the specified RGB value." Note that the function returns only the closest match (it doesnβt exactly match), so you need to make some comparisons to select the correct images (I find this easy because now you have RGB colors with very convenient values ββfor work, say using some method of subtraction and adjustment).
In addition, not only images, when you have certain content on the page, you can try to find the color scheme of this page (getting its value "background-color"), there are quite a few details that you can get and play with :) Of course, the image color is somehow related to the colors of the page styling scheme, to think logically wider.
If I say something incomprehensible, feel free to comment on my answer :)
Happy coding.
user743234
source share