Skip to content

Pemuda-Remek/WK

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

WK Image Format

WK Format Version License

A production-grade image format with Predictive Compression and Adaptive Block Quantization


โœจ Features

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

๐Ÿ“ฆ Installation

From Source

git clone https://github.com/cowoksoftspoken/WK.git
cd WK
cargo build --release

With Viewer (GUI)

cargo build --release --features viewer

๐Ÿš€ Usage

CLI Commands

# 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

GUI Viewer

./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

Rust Library

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());

๐Ÿ”ง Technical Details

File Structure

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ 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)             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Compression Pipeline

Lossless Mode:

Image โ†’ Predictive Filter (optimal per-row) โ†’ Huffman Encoding โ†’ Output

Lossy Mode:

Image โ†’ 8x8 Blocks โ†’ DCT โ†’ Quantization โ†’ Zigzag โ†’ RLE โ†’ Huffman โ†’ Output

Supported Color Types

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

๐Ÿ“Š Benchmarks

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%

๐Ÿ†š Comparison with Other Formats

Feature WK v2.0 WebP JPEG PNG
Lossy โœ… โœ… โœ… โŒ
Lossless โœ… โœ… โŒ โœ…
Alpha โœ… โœ… โŒ โœ…
Animation โœ… โœ… โŒ โŒ
EXIF โœ… โœ… โœ… โŒ
ICC Profile โœ… โœ… โœ… โœ…
XMP โœ… โœ… โœ… โœ…
Extensible โœ… โœ… โŒ โœ…
Open Source โœ… โœ… โœ… โœ…

๐Ÿ“ Project Structure

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

๐ŸŒ Web Viewer

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

๐Ÿ› ๏ธ Building

# Debug build
cargo build

# Release build
cargo build --release

# With viewer feature
cargo build --release --features viewer

# Run tests
cargo test

๐Ÿ“œ License

MIT License - see LICENSE for details

๐Ÿ‘จโ€๐Ÿ’ป Author

Inggrit Setya Budi (@cowoksoftspoken)

About

WK is an image extension that I created using Rust, the name of this extension is taken from the word "wkwkwkwk" which means laughing out loud in Indonesian.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 82.2%
  • JavaScript 12.6%
  • CSS 2.9%
  • HTML 2.3%