thekid / dialog

Dialog photoblog
2 stars 1 forks source link

Extract colors using color quantization #36

Open thekid opened 1 year ago

thekid commented 1 year ago

Idea

Use the palette color to create the border or a maybe ambient glow in the lightbox - see #34. We would extract the palette during import and store it in MongoDB. These colors could also be used for a "search for similar images" feature, or for grouping images as seen in http://dialog.friebes.info/topic/colors__green

Examples

Created via https://gist.github.com/thekid/795c35bec603c0f217cb5445cc901ded

Street art

Street art

Urban

Urban

Nature / people

Nature / people

Colors

Colors Colors: #273218, #cdcdce, #9ea79b, #818877, #939898, #67775d, #5d655b, #58613d, #ac848c, #ac8c74

Inspiration

Ported from https://github.com/lokesh/color-thief

thekid commented 1 year ago

Search by HSL bracket:

$hsl= sscanf($q, '(%d,%d,%d)');
$range= [
  'h' => [max(0, $hsl[0] - 5), min(360, $hsl[0] + 5)],
  's' => [max(0, $hsl[1] - 20), min(100, $hsl[1] + 20)],
  'l' => [max(0, $hsl[2] - 20), min(100, $hsl[2] + 20)],
];

image

image