jenissimo/unfake.js

★ 920⑂ 59

Fix AI pixel art and vector images right in your browser

About jenissimo/unfake.js

jenissimo/unfake.js is an open-source project on GitHub, mainly written in JavaScript. Fix AI pixel art and vector images right in your browser It currently holds 920 stars and 59 forks with 0 open issues, and was last pushed on an unknown date (repository created unknown).

Project Overview

AI Homed tracks it on the AI Image Projects board and on the AI AI Image Projects list.

GitHub Repository Details

Repository jenissimo/unfake.js · default branch - · size 0 KB · watchers 0 · source: GitHub REST API and repository README

README

unfake.js

unfake.js is a versatile JavaScript library designed to bridge the gap between AI-generated images and clean, usable assets. It offers two primary modes of operation: a powerful Pixel Art Processor and a sophisticated Image Vectorizer. The library is bundled with a feature-rich browser-based tool for easy, interactive use.

Browser Tool Screenshot for Pixel Art Browser Tool Screenshot for Vectorize

Deep-Dive Articles

Want to learn more about how it works under the hood? Check out these in-depth articles on the pixel art cleanup pipeline:

Integrations & Online Demo ---

Features

1. Pixel Art Processor

This mode is tailored for cleaning up pixel art, especially pieces generated by AI that often suffer from inconsistent pixel sizes, color bleeding, and other artifacts.

2. Image Vectorizer

This mode converts raster images (PNG, JPG) into clean, scalable SVG files. It's an intelligent wrapper around imagetracer.js with extensive pre- and post-processing capabilities powered by the unfake-core WASM filters.

Browser Tool

The project includes a browser-based tool (/browser-tool) that provides a user-friendly interface for all of the library's features.

How to Use

Running the Browser Tool Locally

⚠️ You need a local server!
> Modern browsers do not allow ES module imports (importmap, type="module") from local files (file://). To use the browser tool, you must run it via a local http(s) server.

Quick ways to start a server:

  python -m http.server 8080
  # or
  python3 -m http.server 8080
  
Then open: http://localhost:8080/browser-tool/
  npx http-server -p 8080
  
Then open: http://localhost:8080/browser-tool/ Click "Go Live" at the bottom of VSCode and select the browser-tool folder.

---

1. Start a local server using one of the methods above. 2. Open http://localhost:8080/browser-tool/ in your browser (or the port you chose). 3. Upload an image, tweak the settings, enjoy!

Using the Library (unfake.js) in Your Own Project

The library is written as ES modules. You can import and use its core functions processImage and vectorizeImage.

1. Pixel Processing Example:

import unfake from './lib/index.js';

const fileInput = document.getElementById('my-file-input'); const file = fileInput.files[0];

const options = { file: file, maxColors: 32, detectMethod: 'auto', // 'auto', 'runs', 'edge' downscaleMethod: 'dominant', snapGrid: true, cleanup: { morph: true, jaggy: true } };

try { const { png, imageData, palette, manifest } = await unfake.processImage(options); // png is a Uint8Array of the final PNG file const blob = new Blob([png], { type: 'image/png' }); const url = URL.createObjectURL(blob); // Now you can use the URL for an tag or download link document.getElementById('result-image').src = url;

} catch (error) { console.error("Pixel processing failed:", error); }

2. Vectorization Example:

import unfake from './lib/index.js';

const fileInput = document.getElementById('my-file-input'); const file = fileInput.files[0];

const options = { file: file, preProcess: { enabled: true, filter: 'bilateral', value: 15 }, quantize: { enabled: true, maxColors: 'auto' // or a number like 16 }, // imagetracer.js options ltres: 1, qtres: 1, };

try { const { svg, palette, manifest } = await unfake.vectorizeImage(options); // svg is a string containing the SVG markup document.getElementById('result-container').innerHTML = svg;

} catch (error) { console.error("Vectorization failed:", error); }

Architecture

The image-processing core lives in unfake-core, a headless Rust crate compiled to WebAssembly for the browser tool and to a native binary for the CLI (crates/; unfake detect / snap / downscale / quantize, with fixed palettes, a reserved chroma color, and a JSON pipeline manifest). It owns scale detection, grid snapping, downscaling (dominant / median / mode / mean / qvote), morphological cleanup, color quantization (imagequant), content-adaptive downscaling, the vector pre/post filters, and PNG encoding — no OpenCV. The JavaScript layer in browser-tool/ is a thin interface: file I/O, canvas, the Tweakpane UI, and calls into the WASM core.

bun run core:wasm   # build the WASM core into browser-tool/vendor/unfake-core/
bun run core:test   # cargo test
bun run core:eval   # CLI scale-detection eval on the bghira corpus

Core Dependencies

License

This project is licensed under the MIT License. See the LICENSE file for details.

GitHub Stars & Activity

920Stars
59Forks
0Open issues
JavaScriptLanguage

GitHub Popularity

GitHub stars920
Forks59
Open issues0
Primary languageJavaScript
License-
Stars gained today0
Created-
Last pushed-

Trending History

Trending statusnot on today's boards

Related AI Projects

1

Anil-matcha / Open-Generative-AI

JavaScript★ 28,946⑂ 5,267
2

saharmor / dalle-playground

JavaScript★ 2,740⑂ 571
3

opencv / opencv

C++★ 90,909⑂ 57,033
4

ultralytics / ultralytics

Python★ 61,829⑂ 11,787
5

ultralytics / yolov5

Python★ 58,057⑂ 17,469
6

roboflow / supervision

Python★ 50,960⑂ 4,848
7
8

lucidrains / vit-pytorch

Python★ 25,514⑂ 3,495

More AI Rankings