npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cbmp

v1.1.1

Published

CLI for converting cursor svg files to png.

Downloads

140

Readme

cbmp

cbmp

ci publish

CLI for converting cursor SVG files to PNG.

This library has the capability to rasterize both static and animated SVG files, regardless of whether they use SMIL, CSS, or other types of animations supported by modern browsers. It can transform these files into PNG sequences. Additionally, it offers a CLI tool named cbmp, which runs Puppeteer to load SVG files within a browser page, take screenshots using an algorithm, and save them.

Notices

shoutout-sponsors

Subscribe to this discussion to receive updates on breaking changes and deprecations.

Requirments

  • Node.js >= 16.16.0

Install

npm install ful1e5/cbmp
yarn add ful1e5/cbmp

Usage

Usage: cbmp [Args] [Options] ...

CLI for converting cursor svg files to png.

Arguments:
  path                                  Path to JSON configiruation file.

Options:
  -V, --version                         output the vers
ion number
  -d, --dir <path>                      Specify the directory to search for SVG files.
  -o, --out <path>                      Specify the directory where rasterized PNG files will be saved. (default: "./bitmaps")
  --puppeteer                           Use Puppeteer for rendering (requires internet) or default to '@resvg/resvg-js' for SVG rendering.
  -n, --themeName <string>              Specify the name of sub-directory inside output directory. (Deprecated: Use the '-o' option to specify the full output path instead.)
  -bc, --baseColor [string]             Specifies the CSS color for inner part of cursor. (optional)
  -oc, --outlineColor [string]          Specifies the CSS color for cursor's ouline. (optional)
  -wc, --watchBackgroundColor [string]  Specifies the CSS color for animation background. (optional)
  -fps, --fps [number|float]            Specifies the FPS for rendering animated SVGs. (default: 1)
  --debug                               Run Puppeteer in non-headless mode and print additional debugging logs.
  -h, --help                            display help for command

Getting Started

To begin, use the following command to convert convert SVG files from the svg directory and save the PNG files to the out directory:

npx cbmp -d svg -o out

For debugging and Inspect Puppeteer window, add the --debug with --puppeteer flag:

npx cbmp -d svg -o out --pupeeteer --debug

Config files

You can simplify the process by using a JSON configuration file.

This JSON configuration file represents a series of cbmp command. It's structured into separate sections, each focusing on a specific conversion task.

  • Sections: It is divided into sections, each representing a different conversion task.
  • Parameters:
    • "use": Specifies the library to render SVG files, either "puppeteer" or "default" (which uses @resvg/resvg-js).
    • "dir": Specifies the directory containing SVG files to convert.
    • "out": Specifies the output directory for the PNG sequence.
    • "fps": (Optional) Sets the frames per second (fps) for the animation.
    • "colors": (Optional) Allows you to define color replacements in the SVGs.
{
  "Sample Task": {             <--- Task Name
    "use": "puppeteer",        <--- Specify the rendering library - use "puppeteer" or "default"
    "dir": "svg",              <--- Specify Directory containing SVG files
    "out": "out",              <--- Specify output directory
    "fps": 60,                 <--- (Optional) Adjust FPS, applicable only when using "puppeteer"
    "colors": [                <--- (Optional) List of Color Replacements
      { "match": "#00FF00", "replace": "#FFFFFF" },
      { "match": "#0000FF", "replace": "#000000" },
      { "match": "#FF0000", "replace": "#FFF000" }
    ]
  }
}
npx cbmp sample.json

You can also control the frames per second (fps) using the -fps or --fps options:

npx cbmp sample.json -fps 30

sample.json

{
  "Sample 1": {
    "dir": "svg",
    "out": "out/sample1"
  },

  "Sample 2": {
    "use": "puppeteer",
    "dir": "svg",
    "out": "out/sample2"
    "fps": 10,
  },

  "Sample 3": {
    "dir": "svg",
    "out": "out/sample3",
    "colors": [
      { "match": "#00FF00", "replace": "#FFFFFF" },
      { "match": "#0000FF", "replace": "#000000" }
    ]
  },

  "Sample 4": {
    "use": "puppeteer",
    "dir": "svg",
    "out": "out/sample4",
    "fps": 60,
    "colors": [
      { "match": "#00FF00", "replace": "#FFFFFF" },
      { "match": "#0000FF", "replace": "#000000" },
      { "match": "#FF0000", "replace": "#FFF000" }
    ]
  }
}

LICENSE

This project is released under the terms of the MIT license. See opensource.org for more information.