Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content
TechByPixelPublic

About

Turn high-detail images into clean pixel-art sprites. Open-source TypeScript toolkit with no runtime dependencies.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

PixelKit

Everything in pixels. Everything in code.

PixelKit is an open-source toolkit for turning high-detail images into pixel art that is ready for a game: the right size, a limited palette, crisp edges and clean clusters, produced the same way every time, on your own machine.

License: MIT

A detailed character (0), a typical resize-and-reduce filter (1) and PixelKit 0.1.0 (2), both 128 px tall with 32 colours, enlarged 3×

0: source picture. 1: box-average resize plus median-cut palette, the way most "pixelate" filters work. 2: PixelKit 0.1.0 with its default settings. Both pixel-art versions are 128 px tall with 32 colours, shown at 3×.

Packages

Package What it does Status
@techbypixel/pixelkit Image-to-pixel-art conversion: palette-first voting in OKLab, cleanup, optional outline and ordered dithering 0.1.0 on npm

The first release does one thing: conversion. More tools (editing, palettes, sprite sheets, export to game engines) will follow only once the conversion quality has been proven on more kinds of pictures.

Example

import { convert } from "@techbypixel/pixelkit";

const { image, palette } = convert(imageData, { height: 128, colours: 32 });

See the package README for every option, the building blocks, how the algorithm works and its limits.

More examples

The same comparison on seven more AI-generated test pictures from apps/benchmark/public/inputs: the source (0), a classic resize-and-reduce filter (1) and PixelKit 0.1.0 with its default settings (2), each 128 px tall with 32 colours, shown at 3×. They are visual comparisons only; the numbers in the package README come from the character and weapon pictures.

Where PixelKit helps

A knight in flat vector style (0), the classic filter (1) and PixelKit (2)

Flat vector style: the filter blurs the dark outlines into grey, while PixelKit keeps flat fills and solid outlines.

A 3D-rendered treasure chest (0), the classic filter (1) and PixelKit (2)

3D render: PixelKit keeps the gold trim crisper and the highlights brighter. The small red gem is lost in both versions.

A glass potion bottle (0), the classic filter (1) and PixelKit (2)

Glass: the highlights on the bottle stay sharper.

Where it still falls short

A photograph of a red sneaker (0), the classic filter (1) and PixelKit (2), stacked from top to bottom

Photograph: PixelKit turns the canvas texture into speckled noise, while the filter's averaging gives a smoother fill. Photographs are not what PixelKit is tuned for yet.

A bow with a thin string (0), the classic filter (1) and PixelKit (2) A staff with thin hanging chains (0), the classic filter (1) and PixelKit (2)

Thin lines: the bowstring is 2–3 px wide in the source, about a fifth of an output pixel at this size, and disappears in both versions; the chains on the staff break into loose dots.

A fire spirit with a soft glow (0), the classic filter (1) and PixelKit (2)

Soft glow: the semi-transparent aura becomes a solid pale ring around the creature in both versions.

Repository layout

pixelkit/
├── packages/
│   └── pixelkit/        @techbypixel/pixelkit: the library (TypeScript, no dependencies)
├── apps/
│   └── benchmark/       Interactive page and scripts comparing nine conversion pipelines on the same pictures
└── docs/images/         Pictures used in this README

The benchmark imports the library's own functions for every step the library has, so pipeline 8 on the benchmark page gives exactly the pixels of convert(). The other pipelines are kept for comparison.

Development

Requirements: Node.js 24 (the scripts run TypeScript files directly) and pnpm 11.

pnpm install
pnpm test          # tests of the library and the benchmark
pnpm typecheck
pnpm build         # builds packages/pixelkit
pnpm dev           # benchmark page at http://localhost:3210
pnpm bench         # writes contact sheets and numbers to apps/benchmark/benchmark-results

During development the benchmark resolves @techbypixel/pixelkit to the library's TypeScript sources through the @techbypixel/source export condition, so the library does not need to be rebuilt after every change.

The benchmark

The page shows a source picture and the result of each pipeline side by side, at native size and enlarged, and lets you change the frame height, palette, quantizer, downsampling method, dithering, outline and cleanup. You can drop in any picture of your own; it never leaves the browser.

The fixed set of test pictures in apps/benchmark/public/inputs is part of the repository and covered by the same MIT licence as the code, so you can use it for your own comparisons.

Contributing

Issues and pull requests are welcome. Before opening a pull request:

  1. Run pnpm test and pnpm typecheck.
  2. If you change the algorithm, run pnpm bench and compare the contact sheets before and after: a change that improves a number but makes the pictures look worse is not an improvement.
  3. Keep the library free of runtime dependencies and of DOM or Node APIs.

Commit messages follow Conventional Commits.

License

MIT © TechByPixel

About

Turn high-detail images into clean pixel-art sprites. Open-source TypeScript toolkit with no runtime dependencies.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages