A production-grade image format with Predictive Compression and Adaptive Block Quantization
| Feature | Description |
|---|---|
| ๐ฏ Lossy & Lossless | Both compression modes with quality control (1-100) |
| ๐ฎ Predictive Compression | 5 filters (None, Sub, Up, Average, Paeth) with auto-selection |
| ๐ฆ 8x8 DCT Transform | JPEG-compatible discrete cosine transform |
| โก Adaptive Quantization | Quality-dependent compression with perceptual weighting |
| ๐ CRC32 Integrity | Per-chunk data verification |
| ๐ธ EXIF Metadata | Camera info, GPS, ISO, aperture, focal length |
| ๐จ ICC Color Profiles | sRGB, Adobe RGB, Display P3, ProPhoto RGB, Rec.2020 |
| ๐ XMP Metadata | Title, description, creators, ratings, subjects |
| ๐ฌ Animation Support | Frame delay, blend modes, dispose modes |
| ๐ Extensible | Chunk-based format for future additions |
git clone https://github.com/cowoksoftspoken/WK.git
cd WK
cargo build --releasecargo build --release --features viewer# Encode image to WK (lossy)
wkconverter encode input.jpg output.wk 85
# Encode lossless
wkconverter lossless input.png output.wk
# Decode WK to image
wkconverter decode input.wk output.png
# View file information
wkconverter info input.wk
# Run benchmark
wkconverter benchmark input.jpg ./output_dir./target/release/wkviewer- Drag & drop any image (PNG, JPEG, WebP, BMP, GIF, TIFF)
- Convert to WK format with quality slider
- View file metadata and compression info
use wk_format::{WkEncoder, WkDecoder, WkMetadata};
use wk_format::metadata::exif::ExifBuilder;
use wk_format::metadata::icc::IccProfile;
// Encode with metadata
let exif = ExifBuilder::new()
.make("Canon")
.model("EOS R5")
.iso(800)
.build();
let metadata = WkMetadata::new()
.with_exif(exif)
.with_icc(IccProfile::srgb());
let encoder = WkEncoder::lossy(85).with_metadata(metadata);
let encoded = encoder.encode_to_vec(&image)?;
// Decode
let decoder = WkDecoder::new();
let decoded = decoder.decode(&encoded[..])?;
println!("{}x{}", decoded.image.width(), decoded.image.height());โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Magic Number: "WK2.0\x00\x00\x00" โ 8 bytes
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ IHDR Chunk (Image Header) โ
โ โโ Width, Height โ
โ โโ Color Type, Compression Mode โ
โ โโ Quality, Flags, Bit Depth โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ICCP Chunk (ICC Profile) [optional] โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ EXIF Chunk (EXIF Data) [optional] โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ XMP Chunk (XMP Data) [optional] โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ IDAT/IDLS Chunk (Image Data) โ
โ โโ Quantization Tables (lossy) โ
โ โโ Compressed Coefficients โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ IEND Chunk (End Marker) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Lossless Mode:
Image โ Predictive Filter (optimal per-row) โ Huffman Encoding โ Output
Lossy Mode:
Image โ 8x8 Blocks โ DCT โ Quantization โ Zigzag โ RLE โ Huffman โ Output
| Type | Channels | Description |
|---|---|---|
Grayscale |
1 | Single channel |
GrayscaleAlpha |
2 | Grayscale + Alpha |
Rgb |
3 | Red, Green, Blue |
Rgba |
4 | RGB + Alpha |
Yuv420 |
3 | YUV with 4:2:0 subsampling |
Yuv444 |
3 | YUV without subsampling |
Quality vs File Size (217x233 test image):
| Quality | Mode | File Size | Ratio |
|---|---|---|---|
| 100 | Lossless | 86 KB | 57% |
| 95 | Lossy | 46 KB | 31% |
| 85 | Lossy | 26 KB | 17% |
| 50 | Lossy | 15 KB | 10% |
| 25 | Lossy | 8 KB | 5% |
| Feature | WK v2.0 | WebP | JPEG | PNG |
|---|---|---|---|---|
| Lossy | โ | โ | โ | โ |
| Lossless | โ | โ | โ | โ |
| Alpha | โ | โ | โ | โ |
| Animation | โ | โ | โ | โ |
| EXIF | โ | โ | โ | โ |
| ICC Profile | โ | โ | โ | โ |
| XMP | โ | โ | โ | โ |
| Extensible | โ | โ | โ | โ |
| Open Source | โ | โ | โ | โ |
WK/
โโโ src/
โ โโโ lib.rs # Library exports
โ โโโ main.rs # CLI (wkconverter)
โ โโโ encoder.rs # WK encoder
โ โโโ decoder.rs # WK decoder
โ โโโ converter.rs # High-level converter
โ โโโ error.rs # Error types
โ โโโ format/
โ โ โโโ chunk.rs # Chunk container
โ โ โโโ header.rs # File header
โ โโโ compression/
โ โ โโโ dct.rs # DCT/IDCT transform
โ โ โโโ quantizer.rs # Adaptive quantization
โ โ โโโ predictor.rs # Predictive filters
โ โ โโโ entropy.rs # Huffman coding
โ โ โโโ engine.rs # Compression engine
โ โโโ metadata/
โ โ โโโ exif.rs # EXIF support
โ โ โโโ icc.rs # ICC profiles
โ โ โโโ xmp.rs # XMP metadata
โ โ โโโ custom.rs # Custom fields
โ โโโ animation/
โ โ โโโ frame.rs # Animation frames
โ โโโ bin/
โ โโโ viewer.rs # GUI viewer (egui)
โ โโโ debug.rs # Debug tool
โโโ viewer/
โโโ index.html # Web viewer
โโโ main.js # JavaScript decoder
โโโ styles.css # Viewer styles
Open viewer/index.html in a browser to view WK files without installing anything.
Features:
- Drag & drop WK files
- View image info and metadata
- Download as PNG
- Supports WK v2.0 format
# Debug build
cargo build
# Release build
cargo build --release
# With viewer feature
cargo build --release --features viewer
# Run tests
cargo testMIT License - see LICENSE for details
Inggrit Setya Budi (@cowoksoftspoken)