Jump to Content

Objective HTML

Photo Frame

exp:photo_frame:average_color

This method allows you to fetch the average color of photo. By default it returns an rgb string. This tag works in a couple of different ways for maximum flexibility.

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. You may define the photo file path or url in two ways. 1 using the file parameter, and the other using the tag data.

Example 1


	{exp:photo_frame:average_color file="http://example.org/some/image/path.jpg"}
	

Example 2


{exp:photo_frame:average_color}
	http://example.org/some/image/path.jpg
{/exp:photo_frame:average_color}

Example 3


{exp:photo_frame:average_color file="http://example.org/some/image/path.jpg"}
	{color:rgb}
	{color:hex}
{/exp:photo_frame:average_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.

type=

This parameter is only applicable if you don't define any tagdata. This parameter accepts rgb or hex. By default, the single tag will return an rgb value. If you want to return hex, use this parameter.


	{exp:photo_frame:average_color file="http://example.org/some/image/path.jpg"}
// returns rgb(X,Y,Z)
	

	{exp:photo_frame:average_color file="http://example.org/some/image/path.jpg" type="hex"} 
// returns #XYZABC
	

prefix=

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


{exp:photo_frame:average_color file="http://example.org/some/image/path.jpg"}
	{color:rgb}
	{color:hex}
{/exp:photo_frame:colors}

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

Variables

rgb
An rgb string
hex
A hex string