# Color information and analysis

Imager X comes with a bunch of methods for working with colors. For starters you can use craft.imager.getDominantColor and craft.imager.getColorPalette to get color information from an image.

{% set dominantColor = craft.imager.getDominantColor(image) %}
{% set palette = craft.imager.getColorPalette(image) %}

<p>
    Look at that dominant color: 
    <span style="background: {{ dominantColor }}; width: 20px; height: 20px; display: inline-block;"></span>
</p>

<p>
    And look at this color palette:
    {% for color in palette %}
        <span style="background: {{ color }}; width: 20px; height: 20px; display: inline-block;"></span>
    {% endfor %}
</p>    

If you need to convert between RGB and HEX color values, there's craft.imager.hex2rgb and craft.imager.rgb2hex.

{% set rgb = craft.imagerx.hex2rgb('#f9c344') %}
Color in RGB is: {{ 'rgb(' ~ rgb[0] ~ ',' ~ rgb[1] ~ ',' ~ rgb[2] ~ ')' }}

{% set hex = craft.imagerx.rgb2hex([249, 195, 68]) %}
Color in hex is: {{ hex }}

Imager also comes with a ton of different helper methods for analyzing colors. There's nifty stuff like craft.imager.getBrightness, craft.imager.getPercievedBrightness, craft.imager.getContrastRatio, and many more. Together with craft.imager.getDominantColor these can be used to analyze the color of your image, and adapt your design based on it (think, light text on dark images and vice versa).