recolor-img
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

recolor-img

Recolor an image (SVG and PNG), useful for recoloring toolbar icons.

Installation

yarn add recolor-img

Usage

Node.js

import { recolorSVGString, recolorPNGImage } from 'recolor-img';

Browser

<script src="./node_modules/recolor-img/dist/main.js"></script>
<script>
  const { recolorPNGImage, recolorSVGString } = window.recolorImg;
</script>

Example

<script>
  const { recolorPNGImage, recolorSVGString } = window.recolorImg;
  // recolorPNGImage recolors image of the given <img> element with the specified color.
  recolorPNGImage(document.getElementById('png'), '#83c400');

  // recolorSVGString recolors the given SVG string with the specified color.
  const svg1 = `<svg>...</svg>`;
  document
    .getElementById('svg1')
    .setAttribute('src', recolorSVGString(svg1, '#83c400', true));
</script>

Package Sidebar

Install

npm i recolor-img

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

56.2 kB

Total Files

8

Last publish

Collaborators

  • mgenware