Kirby-colorextractor Average colour

Hi,

Can anyone share the template code for the plugin Kirby 3 – Color extractor (kirby-colorextractor) to get the average colour?

I have the plugin installed and working and can extract the dominant colour. I’ve also added the following line to config/config.php:

'sylvainjule.colorextractor.average' => true,'

I’ve checked the docs but can’t find a template example for the average colour.

Thanks.

https://github.com/sylvainjule/kirby-colorextractor#4-displaying-and-using-the-color, last paragraph:

<?php 
// make sure $image is a File object
$image = $page->image('image.jpg');  
echo $image->color(); ?>

(assuming that the field where the color is stored is called color like in the example.

Hi texnixe,

I have that working and it returns the images dominant colour, what I would like is both the dominant and the average colour.

There’s a note in the plugin docs about how to update the config to grab the average colour. But an example for the average colour template code is missing. I’ve had a look at the plugin code but couldn’t see anything obvious.

I don’t know if both is possible at the same time, as far as I understand, you can have either/or.

@sylvainjule?

1 Like