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

img2petscii

v0.0.8

Published

Converts images to Commodore 64 PETSCII

Downloads

5

Readme

img2petscii

Converts images to Commodore 64 PETSCII

Outputs a Petmate file to enable further editing.

This is a command line tool aimed at developers and graphic artists.

Install

There is no need to download img2petscii, just do this:

  • Make sure Node.js 17 or higher is installed
  • npm install -g img2petscii

You now have a command called img2petscii

Usage

Usage: img2petscii [options] <file|folder>

Convert images to PETSCII

Options:
  -V, --version               output the version number
  -o, --output <output name>  set filename or folder for output
  -f, --format <name>         output format (choices: "petmate", "png",
                              default: "petmate")
  -c, --charset <name>        which ROM character set to use (choices:
                              "uppercase", "lowercase", default: "uppercase")
  -m, --method <method>       method for matching PETSCII characters (choices:
                              "slow", "fast", default: "slow")
  -b, --background <method>   method for choosing background color (choices:
                              "optimal", "firstPixel", default: "optimal")
  --loadConfig <filename>     load config from a json file
  --saveConfig <filename>     saves config to a json file
  --overwrite                 force overwrite of existing files
  --mono                      single color mode
  --threshold <value>         threshold (0-255) for --mono mode (default: 128)
  -h, --help                  display help for command

Input

The input name can be a file, or a folder. In case of a folder, all supported images in that folder will be converted into multiple frames in the resulting Petmate file, in alphabetical order. Supported extensions are .png, .jpg and .webp.

Some simple cropping occurs to make the image 320x200 pixels in size.

Output

-f, --format <name>
  • petmate creates a Petmate file. In case a folder with multiple images was used as input, the images will result in multiple frames in one Petmate file, in alphabetical order. This is the default.
  • png saves as PNG. In case a folder with multiple images was used as input, one PNG file per input image is created.
-o, --output <output name>

Optional output filename. If not supplied, img2petscii will make one up for you.

  • for petmate, this should be a file.
  • for png, this can be a filename or an (existing) folder name. The folder name can be useful because every frame is exported as a separate png file.

Options

-m, --method <method>

Both methods render all the supported characters with a background and foreground color, and find the best match by minimizing the Euclidian (RGB) distance with an 8x8 pixel tile in the image.

The slow method renders all the characters in all the colors in the palette.

The fast method renders all the characters in one color, which it will determine by first quantizing the tile to the c64 palette, and then selecting the most occuring color.

-b, --background <method>

The optimal method quantizes each image to the c64 palette and selects the most occuring color as the background color for that frame.

The firstPixel method quantizes the first pixel in the first image and uses that as background color. This is useful for converting multiple images to an animation, where the optimal setting might decide on different background colors for different frames in the animation. The firstPixel option always uses one background color for the whole animation.

--mono
--threshold

Monochrome mode. First converts input to black and white. Use --threshold to change the quantization threshold. When --threshold is not supplied, a threshold of 128 is used. Using --method together with --mono has no effect; the matching method is always fast.

--saveConfig <filename>
--loadConfig <filename>

Save configuraton to a JSON file, or load a saved configuration. The configuration file holds the values supplied on the command line, and default values. In addition it contains the list of screencodes that are allowed. Editing this JSON file enables you to limit these screencodes.

Converting animated GIF

img2petscii was written for the Commodore 64 demo "Staying Alive" for converting animated GIF to PETSCII. You cannot supply an animated GIF directly to img2petscii, but you need to extract the frames of the GIF first. The process is explained in this blogpost about "Staying Alive"