Skip to main content
██████╗ ██╗██╗  ██╗███████╗██╗     ██╗███████╗██╗ ██████╗ █████╗ ████████╗██╗ ██████╗ ███╗   ██╗
██╔══██╗██║╚██╗██╔╝██╔════╝██║     ██║██╔════╝██║██╔════╝██╔══██╗╚══██╔══╝██║██╔═══██╗████╗  ██║
██████╔╝██║ ╚███╔╝ █████╗  ██║     ██║█████╗  ██║██║     ███████║   ██║   ██║██║   ██║██╔██╗ ██║
██╔═══╝ ██║ ██╔██╗ ██╔══╝  ██║     ██║██╔══╝  ██║██║     ██╔══██║   ██║   ██║██║   ██║██║╚██╗██║
██║     ██║██╔╝ ██╗███████╗███████╗██║██║     ██║╚██████╗██║  ██║   ██║   ██║╚██████╔╝██║ ╚████║
╚═╝     ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝╚═╝     ╚═╝ ╚═════╝╚═╝  ╚═╝   ╚═╝   ╚═╝ ╚═════╝ ╚═╝  ╚═══╝

No pixels created. No pixels destroyed. Only rearranged.

Python PyPI CUDA License


◈ What Is This?

Pixelification is a terminal tool built on a single elegant constraint:

Every pixel in the output must come from the source. Nothing is invented.

It uses optimal transport via colour sorting to rearrange pixels — either between two images or across video frames — creating hypnotic, mathematically-grounded transformations. Think of it as a pixel teleporter: your source image's pixels physically migrate to approximate the structure of a target.


◈ Modes

▸ Image Mode

Rearrange pixels from a source image to approximate the layout of a target image, then watch a 60-frame pixel-sliding animation.

┌──────────────────────────────────────────────────────────────────────┐
│                                                                        │
│   SOURCE            TARGET            RECONSTRUCTION                  │
│   ┌──────┐          ┌──────┐          ┌──────┐                       │
│   │ 🌆   │          │ 🌊   │          │ ✦ ✦  │  ← pixels sliding    │
│   │      │ ──────▶  │      │ ──────▶  │  ✦   │    into place        │
│   │      │          │      │          │ ✦  ✦ │                       │
│   └──────┘          └──────┘          └──────┘                       │
│                                                                        │
└──────────────────────────────────────────────────────────────────────┘

How it works — in three steps:

  1  ╔═══════════════════╗    2  ╔═══════════════════╗    3  ╔════════════════════╗
     ║   SORT BY COLOUR  ║       ║   MAP BY RANK     ║       ║   ANIMATE          ║
     ║                   ║       ║                   ║       ║                    ║
     ║  lum → hue → sat  ║  ──▶  ║  rank i (source)  ║  ──▶  ║  60-frame lerp     ║
     ║                   ║       ║  → position of    ║       ║  all pixels move   ║
     ║  darkest  = 0     ║       ║  rank i (target)  ║       ║  simultaneously    ║
     ║  lightest = N-1   ║       ║                   ║       ║                    ║
     ╚═══════════════════╝       ╚═══════════════════╝       ╚════════════════════╝
Step What happens
Sort Every pixel in both images is ranked by luminance, then hue, then saturation
Map Source pixel with rank i teleports to where target pixel with rank i lives
Animate Each pixel slides from origin to destination over 60 frames via linear interpolation

When multiple pixels land on the same display cell, their colours are averaged — a natural blending effect.


▸ ASCII Art Mode

Turn any image into terminal ASCII art — a scrollable character-based rendering using 10 luminance levels with auto-contrast and Floyd-Steinberg dithering.

  ┌─────────────────────────────────────────────────────────────┐
  │  @@@@@@%####****+==--::..          Shift+arrows scroll      │
  │  @@@%%%###***+++==--::..           PgUp/PgDn jump          │
  │  @%@%%%####***+++==--::..            10 levels + dither    │
  │  @@@%%%###***+++==--::..                                   │
  └─────────────────────────────────────────────────────────────┘

How it works:

Step What happens
Read Image loaded via OpenCV, converted to luminance using Rec. 601 (0.299R + 0.587G + 0.114B)
Contrast Histogram stretched to full 0–255 range for maximum tonal depth
Resize Aspect-corrected resize (0.55 char ratio) to fit terminal width
Dither Floyd-Steinberg error diffusion distributes quantization error across neighboring pixels
Map Each pixel's brightness mapped to one of 10 characters @%#*+=-:. sorted by ink coverage

▸ Video Mode

Rearrange every frame of a source video (or a still image looped as a video) to match the frames of a target video.

  Frame 0  ──[sort]──┬──[rank-map]──▶  Output Frame 0 ──┐
  Frame 1  ──[sort]──┼──[rank-map]──▶  Output Frame 1   ├──▶  video file
    ...              │                      ...          │
  Frame N  ──[sort]──┴──[rank-map]──▶  Output Frame N ──┘

Key differences from Image Mode:

Feature Image Mode Video Mode
Animation 60-frame pixel-slide None — direct sort + write
Aspect ratio handling N/A Black bars to preserve content
Still image as source ✗ ✓ looped for every target frame
Progress feedback Visual window Terminal progress bar
Status: Video: [████████████░░░░░░] 62.0% (124/200)

▸ Audio Mode

Rearrange audio between two files. By default it performs spectral cross-synthesis – the source's pitch/timbre are preserved while its spectral structure is reshaped toward the target. A time-domain cut-and-splice mode, pitch shifting, and more are available via the Advanced Audio Options screen or aud2aud CLI flags:

Default        spectral magnitude remap (source phase)
--time         also/splice segments and reorder them
--pitch 7      pitch shift (+7 semitones)
--randomize    shuffle segments
--dry-wet 0.5  blend with the original

Audio I/O is handled by soundfile/libsndfile — WAV, FLAC, OGG, AIFF, and MP3 with no FFmpeg required.


◈ Installation

Install Pixelification as a global tool:

uv tool install pixelification

Run it from anywhere:

pixelification

Using pip

pip install pixelification

Then run:

pixelification

Using pipx

No installation required:

pipx run pixelification

◈ Hardware Support

Platform Acceleration Notes
NVIDIA GPU ✅ CUDA 13 Full GPU acceleration via cupy-cuda13x[ctk]
Intel CPU/GPU ⚡ CPU (NumPy) Automatic fallback, no extra packages needed

On first launch, Pixelification writes a small runtime config to your OS config directory with the detected hardware-acceleration flag. It just works.


◈ Usage — TUI

Launch the interactive terminal UI (no arguments needed):

pixelification

A keyboard-navigated menu opens:

  ■ Pixel Rearrangement Tool

  ● Rearrange Images    sort pixels between two images
  ○ Rearrange Videos    sort frames between two videos
  ○ Rearrange Audio     spectral cross-synthesis between two audio clips
  ○ ASCII               convert images to ASCII art
  ○ Quit                exit the application

Keyboard Controls

Key Action
↑ ↓ Navigate menu items
Enter Select highlighted item
1–N Jump directly to item N
Shift+↑ ↓ ← → Scroll ASCII art (vertical / horizontal)
PgUp / PgDn Scroll ASCII art by one page
q / Esc Quit

Image Mode

  1. Select your source image
  2. Select your target image
  3. Watch the rearrangement play out in an OpenCV window — three panels: Source · Target · Reconstruction
  4. Press ESC or q to quit the animation
  5. Click "Save Result Image" to export a PNG

Video Mode

  1. Select a source video (or still image — it'll be looped)
  2. Select a target video
  3. Watch the terminal progress bar as frames are processed
  4. Result plays in an OpenCV window — loops until ESC/q or window close
  5. Click "Save Result Video" to export

Audio Mode

  1. Select a source and a target audio file
  2. Optionally open "Advanced Audio Options" to tune the pipeline
  3. Press "Run Audio Rearrangement" (default: spectral cross-synthesis)
  4. "Play Result Audio" previews the temp result with your system player
  5. "Save Result Audio" writes morphed_{src}_from_{tgt}.wav

See docs/audio.md for a full explanation of every advanced setting.

ASCII Art Mode

  1. Select an image file
  2. Press "Run ASCII Conversion" — the art renders instantly in the terminal
  3. Use Shift+arrows to scroll, PgUp/PgDn to jump by page
  4. "Copy to Clipboard" pipes the full result to your system clipboard (clip.exe)
  5. "Save Result" writes a .txt file to the current directory

◈ Usage — CLI

For scripting, batch processing, or headless environments, use the subcommand interface:

pixelification img2img <source> <target> [options]
pixelification vid2vid <source> <target> [options]
pixelification img2ascii <image> [options]
pixelification aud2aud <source> <target> [options]

Output paths default to auto-named files in the current directory (e.g. reconstructed_src_from_tgt.png).

Commands

pixelification img2img <source> <target>
  Rearrange pixels from a source image to approximate a target image.

  -o, --output FILE    output image path (default: auto-named)
  --show               open an OpenCV window with the result
  --cpu                force CPU-only mode

pixelification vid2vid <source> <target>
  Rearrange every frame of a source (video or still image) to match
  a target video. Prints a progress bar to stderr.

  -o, --output FILE    output video path (default: auto-named)
  --show               play the result in an OpenCV window
  --cpu                force CPU-only mode

pixelification img2ascii <image>
  Convert an image to ASCII art. Prints to stdout and saves to file.

  -o, --output FILE    output text path (default: auto-named)
  -w, --width CHARS    output width in characters (default: 120)
  --no-dither          disable Floyd-Steinberg dithering

pixelification aud2aud <source> <target>
  Rearrange audio (spectral cross-synthesis by default). Writes a WAV.

  -o, --output FILE    output audio path (default: auto-named)
  --spectral / --no-spectral   toggle spectral frequency remapping
  --time               enable time-domain segment reordering
  --chunk-ms FLOAT     segment length in ms for time reorder (default: 60)
  --crossfade FLOAT    crossfade between segments in ms (default: 0)
  --fft INT / --hop INT         spectral FFT size / hop (default: 2048 / 512)
  --sort-key KEY       energy|amplitude|zcr|centroid|none (default: energy)
  --randomize / --seed INT      shuffle segments / seed
  --reverse            reverse segment order
  --pitch FLOAT        pitch shift in semitones (e.g. -12, +7)
  --phase MODE         source|target|random (default: source)
  --energy             match per-segment loudness to target
  --dry-wet FLOAT      dry/wet mix 0.0-1.0 (default: 0)
  --no-normalize       disable peak normalization

pixelification --version / -v
  Print the installed version.

◈ Requirements

Python     ≥ 3.10
OpenCV     cv2
NumPy
prompt_toolkit
soundfile     # audio: WAV/FLAC/OGG/AIFF/MP3 (bundles libsndfile, no FFmpeg)

# Optional — installed automatically on supported platforms:
cupy-cuda13x[ctk]    # NVIDIA CUDA acceleration (Linux / Windows)
python3-tk           # Linux only — for file dialog fallback
                     # sudo apt install python3-tk

◈ Documentation

Full, user-and-developer documentation lives in docs/:

Document Covers
docs/index.md Overview, quick start, table of contents
docs/installation.md Install, requirements, CUDA, config file
docs/cli.md Complete CLI reference
docs/tui.md Interactive terminal UI guide
docs/audio.md Audio engine, advanced settings, presets
docs/python-api.md Code / API reference
docs/troubleshooting.md Troubleshooting

◈ The Algorithm (Deep Dive)

For the curious: this is discrete optimal transport solved via sorting. The classical OT problem asks "how do I move mass from distribution A to distribution B at minimum cost?" When cost = squared distance and both distributions have the same total mass, the solution on a 1D sorted line is simply to pair the ith element of one with the ith element of the other.

Pixelification extends this to colour space: pixels are projected onto a 1D ordering by (luminance, hue, saturation), making the sort a tractable proxy for true 2D optimal transport. The result is perceptually coherent pixel migration — similar tones find similar homes.

flowchart LR
    A[Source Image] --> C[lexsort\nlum → hue → sat]
    B[Target Image] --> D[lexsort\nlum → hue → sat]
    C --> E[s_order]
    D --> F[t_order]
    E --> G[forward mapping\nforward at s_order = t_order]
    F --> G
    G --> H[per-pixel position lerp]
    H --> I[scatter render\nnp.add.at]
    I --> J[60-frame animation]

Every pixel has a story. This tool just reassigns the ending.

Metadata

Release files for pixelification 1.3.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pixelification 1.3.5
File Size Uploaded Provenance Actions
pixelification-1.3.5.tar.gz 71.0 kB Without provenance Details for pixelification-1.3.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pixelification 1.3.5
File Interpreter ABI Platform Actions
pixelification-1.3.5-py3-none-any.whl Python 3 none any Details for pixelification-1.3.5-py3-none-any.whl

Total release size: 99.8 kB

Release files / pixelification-1.3.5.tar.gz

Download URL pixelification-1.3.5.tar.gz
Size 71.0 kB
Tags Source
SHA-256 checksum
How to use checksums
208f8c28e90120af626e31797670ce20222475da7576968245b65d81ba11c3f2
BLAKE2b-256 checksum
How to use checksums
fd6e49248fdae5353b6140c84c82d9f707ce4f4975fdb484bd04b46dcde431d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pixelification-1.3.5-py3-none-any.whl

Download URL pixelification-1.3.5-py3-none-any.whl
Size 28.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b89fc2aca076f91be3a3ed4c7b8d481a5b65ef818823b2d78675a9623762e8e0
BLAKE2b-256 checksum
How to use checksums
fc126fd7b5975389c08a5bf709d5fe7b1f3b52c59246bcfa7acc0831b180f5cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for pixelification 1.3.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page