Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Nibnib: Image compression with extreme decompression speed

Nibnib is an image compression format designed specifically for its exceptional decompression speed. Originating as an experiment to test image quality and performance on an RP2350 microcontroller, nibnib is often used in low-bit depth images and palette lookup scenarios. With a limited budget of around 6 cycles per pixel, the format manages to decode two pixels simultaneously from a single byte of input, resulting in 4bpp compression.

The decoding process is straightforward and deterministic, with each decoded pixel being doubled up before fetching a byte from the input stream to add to the pixel's value, ultimately yielding two 16bpp pixels in RGB 565 format.

Encoding in nibnib is a more complex process, involving a search through possible encoded images to find one that closely matches the original. The current encoder is significantly slower than the decoding process, which allows for greater optimization in the decoding phase. Two main aspects of the search are the choice of palette and the selection of codewords.

The palette used in nibnib is a cube of delta values, with a block of random values added for added flexibility. This structure ensures proper handling of edge cases without risking overflow. The encoding loop attempts all 256 palette entries, choosing the one with the minimum error and distributing it using Floyd-Steinberg weights. Subsequent pixels are based on the source pixel value plus weighted errors from previous iterations.

The format is relatively simple, consisting of 2 bytes for width and height, followed by 256 32-bit palette entries, and then the image rows in order. Each row starts with two RGB 565 pixels, followed by ((width - 2) / 2) bytes indexing the palette. The row stride is rounded up to a multiple of 4 bytes. Currently, the format does not support additional metadata, as it is primarily intended for tight integration with the decoder.

Despite its simplicity, nibnib's performance is impressive, offering 4bpp compression with extreme decompression speed, making it an ideal choice for scenarios where speed is a critical factor.

Rewritten by urgent.news; may contain errors — check the original.

Read the original at github.com →

Report a problem with this story

More in Tech

After every save, I refetch the page I'm on — not page one

Here's a bug I've shipped more than once: you edit a user on page 3 of an admin table, save, and the table jumps back to page 1. The edit worked.

  • Users page refetches data after each edit or delete.
  • Server data considered authoritative source.
  • Refetching ensures correct page meta and concurrent changes.

Turning an Old Gaming Laptop into a Home Lab

I work in security evaluation, which mostly means looking at systems from the outside and checking whether they do what they say.

  • Author repurposes old Dell G7 7588 gaming laptop as home lab.
  • Installs Proxmox VE 9.2 hypervisor, allocates storage for guests.
  • Runs Debian 13 container as unprivileged LXC for security learning.

How to Turn Vertical Photos into WhatsApp Stickers (512 512 WebP, Under 100 KB)

Every phone gallery is full of tall photos — your cat mid-yawn, a birthday cake, a friend pulling a face. WhatsApp stickers are square.

  • WhatsApp stickers must be 512x512 pixels and WebP format under 100KB
  • Crop or pad portrait photos to fit 512x512 canvas without losing subject
  • Adjust WebP quality from 90 to 30 to achieve desired file size

More from Friday 30 October →