Jump to Content

Objective HTML

Photo Frame

exp:photo_frame:extract_colors

This method allows you to extract the most common colors in a photo in real-time. This is a looping tag with each iteration being a color that has been extracted from the photo. This tag is different than the exp:photo_frame:colors tags in that the colors tag pulls saved colors from the database, while this tag extracts them from the raw file each time the tag is ran.

Parameters

granularity=

This parameter will change the granularity of the photo used to calculate the average photo color. A lower granularity will result in a more accurate average, but take longer to calculate. So if you are perform these calculations in a loop, then it's best to raise the granularity. The default value is 45. This parameter accepts integers.

file=

This parameter will allow you to define the photo file path or url.

limit=

This parameter will allow you to limit the colors that are returned. If you extract 8 colors and limit 1, there will only be 1 color returned.

offset=

This parameter will allow you to offset the colors that are returned. If you extract 8 colors and offset by 1, there will only be 7 colors returned (all by the first .

prefix=

This parameter will change the default prefix, which is "color:".

total=

This parameter will change the number of colors used to generate the average color. By default, the 10 most used colors will be used to calculate the average.


Variables

rgb
An rgb string
hex
A hex string

Examples


{exp:photo_frame:extract_colors file="/some/image/path.jpg"}
	{color:rgb}
	{color:hex}
{/exp:photo_frame:extract_colors}

{exp:photo_frame:extract_colors prefix="var" file="http://example.org/some/image/path.jpg"}
	{var:rgb}
	{var:hex}
{/exp:photo_frame:extract_colors}