-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0594819
commit 2b46803
Showing
2 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 BlankParticle | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# 🎨 Get Palette | ||
|
||
A simple JS library to get the dominant color or color palette of an image just by its URL. | ||
|
||
--- | ||
|
||
<div align="center"> | ||
<a href="https://github.com/BlankParticle/get-palette/stargazers"> | ||
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/BlankParticle/get-palette?style=for-the-badge"/> | ||
</a> | ||
<a href="https://github.com/BlankParticle/get-palette/graphs/contributors"> | ||
<img alt="GitHub contributors" src="https://img.shields.io/github/contributors/BlankParticle/get-palette?style=for-the-badge"/> | ||
</a> | ||
<a href="https://github.com/BlankParticle/get-palette/blob/main/LICENSE"> | ||
<img alt="License" src="https://img.shields.io/github/license/BlankParticle/get-palette?style=for-the-badge"/> | ||
</a> | ||
<a href="https://www.npmjs.com/package/get-palette"> | ||
<img alt="Npm Downloads" src="https://img.shields.io/npm/dm/get-palette?style=for-the-badge"> | ||
</a> | ||
<a href="https://github.com/BlankParticle/get-palette/actions/workflows/release.yml"> | ||
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/BlankParticle/get-palette/release.yml?style=for-the-badge"/> | ||
</a> | ||
<a href="https://github.com/sponsors/BlankParticle"> | ||
<img alt="GitHub Sponsors" src="https://img.shields.io/github/sponsors/BlankParticle?style=for-the-badge"/> | ||
</a> | ||
</div> | ||
|
||
## ❄️ Installation | ||
|
||
First install the package using a package manager of your choice. | ||
|
||
```bash | ||
# using npm | ||
npm install get-palette | ||
# or pnpm | ||
pnpm install get-palette | ||
# or bun | ||
bun add get-palette | ||
``` | ||
|
||
## 🚀 Usage | ||
|
||
```js | ||
import { getPalette, getColor } from "get-palette"; | ||
|
||
// it will return an array of [r,g,b] values | ||
const palette = await getPalette("https://source.unsplash.com/random?size=1920x1080"); | ||
|
||
// it will return a single dominant [r,g,b] value | ||
const color = await getColor("https://source.unsplash.com/random?size=1920x1080"); | ||
``` | ||
|
||
## 🛠️ Configuration | ||
|
||
### `getPalette(url, colorCount, quality)` | ||
|
||
| Parameter | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| `url` | `string`/`URL` | - | The URL of the image | | ||
| `colorCount` | `number` | `10` | The number of colors to be returned | | ||
| `quality` | `number` | `10` | Sampling quality of the image | | ||
|
||
### `getColor(url, quality)` | ||
|
||
| Parameter | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| `url` | `string`/`URL` | - | The URL of the image | | ||
| `quality` | `number` | `10` | Sampling quality of the image | | ||
|
||
## 🏗️ How to contribute | ||
|
||
### 🐛 Reporting Bugs | ||
|
||
If you encounter any bugs, please report them in the [Issues](https://github.com/BlankParticle/get-palette/issues). | ||
|
||
### 🎋 Adding new features | ||
|
||
You need to first [fork](https://docs.github.com/en/get-started/quickstart/contributing-to-projects#about-forking) this repository and then [clone](https://docs.github.com/en/get-started/quickstart/contributing-to-projects#cloning-a-fork) it to your local machine. | ||
|
||
```bash | ||
git clone https://github.com/<your-username>/get-palette | ||
cd get-palette | ||
``` | ||
|
||
Now you need to create a new branch for your changes. For features, you may want to use `feat/<feature-name>` as the branch name. | ||
|
||
```bash | ||
git checkout -b feat/<feature-name> | ||
``` | ||
|
||
Now you can make your changes. After you are done, you need to commit your changes. | ||
|
||
```bash | ||
git add . | ||
git commit -m "feat: ✨ My Awesome feature" | ||
``` | ||
|
||
We follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) for commit messages. | ||
|
||
Now you need to push the changes to your forked repository. | ||
|
||
```bash | ||
git push origin feat/<feature-name> | ||
``` | ||
|
||
Now you need to create a [Pull Request](https://docs.github.com/en/get-started/quickstart/contributing-to-projects#making-a-pull-request) to the original repository. And you are done! | ||
|
||
We will review your changes and merge them if everything looks good. | ||
|
||
### 💸 Sponsorship | ||
|
||
If you find this plugin useful, please consider [sponsoring me](https://github.com/sponsors/BlankParticle). This will help me spend more time on these projects. | ||
|
||
## 📜 License | ||
|
||
This project is licensed under the [MIT License](https://github.com/BlankParticle/get-palette/blob/main/LICENSE). |