blob: 73386ef5607a1d872b4c81af52d4ed7a8b5073a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<?php
namespace Studip\StockImages;
use ColorThief\ColorThief;
final class PaletteCreator
{
/**
* @param \StockImage $stockImage
*/
public function __invoke(\StockImage $stockImage): void
{
$sourceImage = $stockImage->getPath(\StockImage::SIZE_SMALL);
$palette = ColorThief::getPalette($sourceImage, 3);
$stockImage->palette = json_encode($palette);
$stockImage->store();
}
}
|