Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fast-average-color/fast-average-color
🍏🍊🍅 Fast Average Color
https://github.com/fast-average-color/fast-average-color
average-color box-shadow canvas color fast gradient htmlimageelement htmlvideoelement imagebitmap js offscreencanvas ts video
Last synced: 5 days ago
JSON representation
🍏🍊🍅 Fast Average Color
- Host: GitHub
- URL: https://github.com/fast-average-color/fast-average-color
- Owner: fast-average-color
- License: mit
- Created: 2018-02-04T09:56:19.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2025-01-15T22:17:06.000Z (18 days ago)
- Last Synced: 2025-01-21T16:04:55.918Z (12 days ago)
- Topics: average-color, box-shadow, canvas, color, fast, gradient, htmlimageelement, htmlvideoelement, imagebitmap, js, offscreencanvas, ts, video
- Language: TypeScript
- Homepage: https://fast-average-color.github.io/examples/background.html
- Size: 16.4 MB
- Stars: 1,359
- Watchers: 13
- Forks: 56
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-canvas - fast-average-color - average-color.github.io/examples/background.html)] - 🍏🍊🍅 Fast Average Color. ![](https://img.shields.io/github/stars/fast-average-color/fast-average-color?style=social) ![](https://img.shields.io/github/forks/fast-average-color/fast-average-color?style=social) (Libraries / Image processing)
README
# 🍏🍊🍅 Fast Average Color
[![NPM version](https://img.shields.io/npm/v/fast-average-color.svg)](https://www.npmjs.com/package/fast-average-color)
[![NPM Downloads](https://img.shields.io/npm/dm/fast-average-color.svg?style=flat)](https://www.npmjs.org/package/fast-average-color)
[![bundlephobia](https://badgen.net/bundlephobia/minzip/fast-average-color)](https://bundlephobia.com/result?p=fast-average-color)
[![install size](https://packagephobia.com/badge?p=fast-average-color)](https://packagephobia.com/result?p=fast-average-color)
![Coveralls](https://img.shields.io/coveralls/github/hcodes/fast-average-color)[Demo](https://fast-average-color.github.io/examples/background.html)
A simple library that calculates average or dominant color of any images or videos in browser environment.
## Features
- Bet on [speed](https://fast-average-color.github.io/examples/canvas.html)
- Some algorithms: simple, sqrt (default) and dominant
- [Small bundle size](https://bundlephobia.com/result?p=fast-average-color), tree shaking
- Average color can be obtained from:
+ [image](https://fast-average-color.github.io/examples/background.html)
+ string (url of image or base64)
+ [video](https://fast-average-color.github.io/examples/timeline.html)
+ [canvas](https://fast-average-color.github.io/examples/canvas.html) or `OffscreenCanvas`
+ `ImageBitmap`
+ array of numbers, `Uint8Array` or `Uint8ClampedArray`
- Average color can be obtained from specific part of resource
- Support for transparency (PNG, SVG and other formats)
- Support for web workers
- [Support for Node.js](https://github.com/fast-average-color/fast-average-color-node/)## Table of contents
- [Using](./docs/using.md)
+ [Install](./docs/using.md)
+ [CommonJS](./docs/using.md#commonjs)
+ [ES Modules or TypeScript](./docs/using.md#es-modules-or-typescript)
+ [Node.js](./docs/using.md#nodejs)
- [Examples](./docs/examples.md)
+ [Get average color from loaded image](./docs/examples.md#from-loaded-image)
+ [Get average color from unloaded image](./docs/examples.md#from-unloaded-image)
+ [Get average color from image url](./docs/examples.md#from-image-url)
+ [Get average color with ignored color](./docs/examples.md#get-average-color-with-ignored-color)
+ [Get average color with multiple ignored colors](./docs/examples.md#get-average-color-with-multiple-ignored-colors)
+ [Get average color with ignored color and threshold](./docs/examples.md#get-average-color-with-ignored-color-and-threshold)
- [Algorithms](./docs/algorithms.md)
- [API](./docs/api.md)
+ [.getColor(resource, [options])](./docs/api.md#getcolorresource-options)
+ [.getColorAsync(resource, [options])](./docs/api.md#getcolorasyncresource-options)
+ [.getColorFromArray4(arr, [options])](./docs/api.md#getcolorfromarray4arr-options)
+ [.destroy()](./docs/api.md#destroy)
- [Different Builds](./dist/README.md)
- [Development](./docs/development.md)## Unhandled Rejection (SecurityError): The operation is insecure.
> The crossOrigin attribute allows images that are loaded from external origins to be used in canvas like the one they were being loaded from the current origin. Using images without CORS approval taints the canvas. Once a canvas has been tainted, you can no longer pull data back out of the canvas. By loading the canvas from cross origin domain, you are tainting the canvas.>You can prevent this by setting crossorigin="anonymous".
- [Details](https://github.com/lokesh/color-thief/issues/196)
- [Storing an image from a foreign origin](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image#Storing_an_image_from_a_foreign_origin)## [More examples](https://fast-average-color.github.io/examples/background.html)
+ [Background](https://fast-average-color.github.io/examples/background.html)
+ [Timeline](https://fast-average-color.github.io/examples/timeline.html)
+ [Box shadow](https://fast-average-color.github.io/examples/box-shadow.html)
+ [Box shadow, 4 sides](https://fast-average-color.github.io/examples/box-shadow-4-sides.html)
+ [Border](https://fast-average-color.github.io/examples/border.html)
+ Gallery: [borders](https://fast-average-color.github.io/examples/gallery.html) or [vertical-horizontally](https://fast-average-color.github.io/examples/gallery_vertical.html)
+ [Gradient](https://fast-average-color.github.io/examples/gradient.html)
+ [Gradient as stripes](https://fast-average-color.github.io/examples/gradient_stripes.html)
+ [Canvas](https://fast-average-color.github.io/examples/canvas.html)
+ [Text photo](https://fast-average-color.github.io/examples/text-photo.html)
+ [Ambilight](https://fast-average-color.github.io/examples/ambilight.html)
+ [Define the average color for your images](https://fast-average-color.github.io/examples/define.html)[See code](https://github.com/fast-average-color/examples)
## [License](LICENSE)
MIT License## Similar projects
- [fast-average-color-node](https://github.com/fast-average-color/fast-average-color-node/)
- [color-thief](https://github.com/lokesh/color-thief)
- [node-vibrant](https://github.com/Vibrant-Colors/node-vibrant)
- [image-palette](https://github.com/FormidableLabs/image-palette)
- [react-color-extractor](https://github.com/nitin42/react-color-extractor)## Friends
- [Check device online](https://checkdevice.online/?from=github-fac)