How would you develop something similar to what is described in this DabbleDB blog post?
How would you develop something similar to what is described in this DabbleDB blog
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just answered a kinda related SO question yesterday. Some of the concepts there, along with the resulting test code (on git hub) could be a good start.
As evolve mentions, scanning every pixel in an image (or even just the border) can be resource intensive. However, in this case (since you want to identify far more than just average color) it may be the way to go. Resizing the logo to a sane size would help reduce the server load, and shouldn’t really effect the output.
Update: For these examples assume an image object has been created and
$widthand$heighthave been determined usingimagesx(),getimagesize(), etc.Background Color
Here use
imagecolorat()to find the corner colors. Alternatively, use the average border color method from the referenced answer at the top.Saturation
You can use the RGB to HSL functions at the
imagecolorsforindex()manual page along with the pixel scanning code mentioned at the top to find color values with high saturation.Luminance
This SO thread lists different RGB to luminance calculations. I’m not certain what method is best (or technically correct) to convert 0-255 RGB images. But for what this is accomplishing (should the text be dark or light), I don’t think it’ll matter that much.