clamp-palette

A tool to clamp an image's palette to a user-provided array of colors.


Keywords
color, palette, color-scheme
License
Other
Install
npm install clamp-palette@1.2.0

Documentation

Clamp Palette

A drawing of bees becomes Sepia Bees

A photo of a Game Boy becomes Game Boy'd Game Boy

Spaghetti becomes Sharp Spaghetti

Give any photo a limited, user-defined palette with just a few lines of code. Check example.js to see how the above images were generated.

Install

npm install clamp-palette

Usage

const ClampPalette = require("clamp-palette").default;
ClampPalette({
    imagePath: "path to image file",
    imageBuffer: "optionall use a buffer instead",
    colors: ["an array of #RRGGBB colors"],
    mimetype: "the mime type of the output image; image/png by default, image/jpeg and image/bmp are also supported",
    callback: (buffer) => console.log("a callback where you can do whatever you want with the resultant buffer"),
    errorcallback: (error) => console.log("callback for if it fails")
});

Contributing

Sure.

License

Code is licensed under the GNU Affero General Public License. I am not a lawyer, but what I intend for that to mean is, if you use this to generate images locally or as a dev dependency for something, have fun. If you use it as a standard dependency for your project and its code is included in your app/package/whatever, then you must distribute your work under an AGPL-compatible license.