Skip to content

Getting image accent colors

ekez edited this page Aug 22, 2022 · 1 revision

A number of DAO DAO components include an accent gradient that has a color that is normally set by the dominant color of an image. For example, the voting card:

image

For some of these accent colors we can use the fast-average-color library inside of getStaticProps to retrieve them. When page content is dynamic though (for example, when listing DAOs on the homepage) we need to hit an API for that information.

We have such an api at fac.withoutdoing.com. This has two routes:

  1. fac.withoutdoing.come/<image_url> which returns a plaintext response containing the hex color of the specified image (example).
  2. fac.withoutdoing.com/show/<image_url> which returns a nice visual that a human can look at (example):
image