Our great sponsors
-
color-thief-react
🎨 A React component with hooks for Color Thief. Grab color palette from an image with javascript
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
You can use Color Thief to process your images and get back information like the dominant color in any JS framework. For React there's also color-thief-react (although I haven't tried that personally). The library polished will also work in any JS framework.
While not necessary for this technique to work I'm using Gatsby and gatsby-plugin-image to handle and display the images. I'm doing this because gatsby-plugin-image and its gatsbyImageData supports the placeholder value DOMINANT_COLOR and gives back this value as backgroundColor -- so you can directly query the dominant color of an image. Set up a new site and install the necessary plugins for gatsby-plugin-image following its instructions, e.g. with npm init gatsby and the Add responsive images option at the end.
Related posts
- The gatsby build command will not complete or terminate
- Converting a Gatsby Site to Use TypeScript
- RFC: Adapters - Making it easier to build & deploy Gatsby on any platform
- Can anyone help me with the WordPress Gatsby setup?
- [Showoff Saturday] I FINALLY redesigned my 4 y/o portfolio (nothing fancy, just pure usability + 99/100 pagespeed 😎)