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 🙏

© 2026 – Pkg Stats / Ryan Hefner

picross-image-processor

v1.4.3

Published

A library to convert images to picross board representations by mapping all non-transparent pixels

Downloads

1,057

Readme

Picross Image Processor

A TypeScript library to convert images to picross (nonogram) board representations by mapping all non-transparent pixels.

Installation

npm install picross-image-processor

Optional Canvas Support (Node.js only)

For Node.js file processing, optionally install canvas:

npm install canvas

Usage

Browser - From URL

import { processImageUrl } from 'picross-image-processor';

async function createPicrossBoard() {
  const result = await processImageUrl('https://example.com/pokemon.png');
  console.log(result.board.rowClues);      // Row hints
  console.log(result.boardSize);  // 16
}

Browser - From Canvas

import { processImageData } from 'picross-image-processor';

const canvas = document.getElementById('myCanvas') as HTMLCanvasElement;
const ctx = canvas.getContext('2d');
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);

const result = processImageData(imageData);

Node.js - From File

import { processImageFile } from 'picross-image-processor';

async function processLocalImage() {
  const result = await processImageFile('./pokemon.png');
  console.log(result.board.columnClues);
}

With Custom Configuration

import { processImageUrl, ProcessingConfig } from 'picross-image-processor';

const config: ProcessingConfig = {
  boardSize: 32,           // Default: 16
  colorThreshold: 100,     // Default: 80 (0-255, currently unused)
  alphaThreshold: 128,     // Default: 128 (0-255)
  colorMode: true          // Default: false
};

const result = await processImageUrl(imageUrl, config);

Configuration

ProcessingConfig

  • boardSize (number, default: 16): The size of the output picross board (NxN)
  • colorThreshold (number, default: 80): Reserved for future edge detection (currently unused)
  • alphaThreshold (number, default: 128): The minimum alpha value to consider a pixel opaque (0-255)
  • colorMode (boolean, default: false): When true, board values are 0..255 color indices instead of 255

How It Works

  1. Bounding Box Detection: Finds the smallest rectangle containing all opaque pixels
  2. Crop and Scale: Crops the image to the bounding box and scales it to the board size
  3. Opaque Mapping: Marks every non-transparent pixel as filled
  4. Board Values: Creates a 2D array where -1 = transparent, 0..255 = opaque (255 in mono mode)

API Reference

processImageData(imageData: ImageData, config?: ProcessingConfig): ProcessingResult

Process ImageData directly (browser compatible).

processImageUrl(imageUrl: string, config?: ProcessingConfig): Promise<ProcessingResult>

Process an image from a URL (browser compatible, requires CORS).

processCanvasImage(image: HTMLImageElement | HTMLCanvasElement, config?: ProcessingConfig): Promise<ProcessingResult>

Process an HTML image element or canvas.

processImageFile(filePath: string, config?: ProcessingConfig): Promise<ProcessingResult>

Process an image from a file path (Node.js only, requires canvas package).

Result

The ProcessingResult contains:

{
  board: PicrossBoardData;  // Rows + row/column clues
  boardSize: number;        // Size of the board
}

Example: Drawing the Board

function drawBoard(result: ProcessingResult) {
  const { board, boardSize } = result;
  const { rows } = board;
  const canvas = document.getElementById('board') as HTMLCanvasElement;
  const ctx = canvas.getContext('2d');
  
  const cellSize = 20;
  canvas.width = boardSize * cellSize;
  canvas.height = boardSize * cellSize;
  
  for (let row = 0; row < boardSize; row++) {
    for (let col = 0; col < boardSize; col++) {
      const x = col * cellSize;
      const y = row * cellSize;

      const cell = rows[row].cells[col];
      ctx.fillStyle = cell.enabled ? cell.color : '#fff';
      ctx.fillRect(x, y, cellSize, cellSize);
      ctx.strokeStyle = '#ccc';
      ctx.strokeRect(x, y, cellSize, cellSize);
    }
  }
}

License

MIT