thephpleague / color-extractor

Extract colors from an image like a human would do.
thephpleague.com
MIT License
1.3k stars 159 forks source link

ability to convert int and hex to rgb + tests #41

Closed sleimanx2 closed 8 years ago

MatTheCat commented 8 years ago

I wonder if I can consider this out of scope, would you really use an array of RGB values instead of an hex string?

sleimanx2 commented 8 years ago

I actually use both , hex is handy when used in css while rgb is useful if you want search images by colors.

for instance you would query elasticsearch with the following query

[
    [
        'range' => [
            'images.main_color_rgb.r' => [
                "gte" => $color['r'] - $tolerance,
                "lte" => $color['r'] + $tolerance
            ]
        ]
    ],
    [
        'range' => [
            'images.main_color_rgb.g' => [
                "gte" => $color['g'] - $tolerance,
                "lte" => $color['g'] + $tolerance
            ]

        ]
    ],
    [
        'range' => [
            'images.main_color_rgb.b' => [
                "gte" => $color['b'] - $tolerance,
                "lte" => $color['b'] + $tolerance
            ]

        ]
    ]
]
MatTheCat commented 8 years ago

Ok seems legit ^^ I let some comments and I'll test it later.

Thanks.

MatTheCat commented 8 years ago

Closed by aba310ceef94f922c00949313e74a97dec7fb0a9. I'll work on the tests later.