Get started with color-thief CDN

MIT licensed

Color Thief is a Python library that extracts color palettes from images.

Tags:
  • color
  • palette
  • sampling
  • image
  • picture
  • photo
  • canvas

Stable version

Copied!

How to start using color-thief CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with color-thief CDN - cdnhub.io</title>
  <script src="https://cdn.cdnhub.io/color-thief/2.4.0/color-thief.min.js"></script>
</head>
<body>
  <button id="extract-colors">Extract Colors</button>
  <script>
    const colorThief = new ColourThief();
    const button = document.getElementById('extract-colors');

    button.addEventListener('click', () => {
      const img = new Image();
      img.src = 'https://example.com/image.jpg';

      img.onload = () => {
        const palette = colorThief.getColorPalette(img, 5);
        console.log(palette);
      };
    });
  </script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!

All versions