SlimCodec is a 100% client-side image, video, and audio compression workbench built on browser Canvas 2D, OfflineAudioContext, CompressionStream, and MediaRecorder, executing all encoding in local memory while uploading 0 bytes to any server.
SlimCodec combines PNG 256-color Median-Cut quantization with Deflate repackaging, WebP/JPEG rate-distortion encoding, 4-bit IMA ADPCM 4:1 audio compression, and VP9/MP4 video transcoding with live PSNR (dB) and SSIM telemetry across 4 languages and localStorage state.
01 · PNG Median-Cut Palette Quantization & Floyd-Steinberg Dithering
Module 01 · PNG-8 Median-Cut & Deflate
SlimCodec scans 32-bit RGBA pixel buffers in browser memory and applies 3D Median-Cut color space partitioning to quantize true-color images into 16 to 256 indexed palette entries with Floyd-Steinberg dithering and CompressionStream Deflate, cutting PNG byte size by 55%–80% with 0 bytes uploaded.
Palette Split = argmax_{R,G,B} (MaxChannel - MinChannel) at Median Pixel Count
Dither Error (x,y) = [7/16 → (x+1,y), 3/16 → (x-1,y+1), 5/16 → (x,y+1), 1/16 → (x+1,y+1)]
02 · Perceptual WebP / JPEG Encoding & 100% EXIF Metadata Stripping
Module 02 · Perceptual WebP & JPEG
SlimCodec reconstructs clean pixel buffers inside an offscreen HTML5 Canvas, automatically stripping 100% of camera EXIF, GPS coordinates, and embedded thumbnails while applying 1%–100% quality quantization and 4K/1080p/720p downscaling in under 1 second.
Output Bytes = Canvas2D.toBlob(mime="image/webp"|"image/jpeg", quality ∈ [0.01, 1.00])
Privacy Guarantee = 100% EXIF / GPS / IPTC / XMP Metadata Stripped (0 bytes leaked)
03 · Real-Time Peak Signal-to-Noise Ratio (PSNR) & SSIM Verification
Module 03 · PSNR & SSIM Telemetry
SlimCodec decodes every compressed image buffer in 10 ms and compares it pixel-by-pixel against the original RGBA array (0 bytes uploaded) to compute Mean Squared Error (MSE), Peak Signal-to-Noise Ratio (PSNR in dB), and Structural Similarity (SSIM, 0–1) for transparent quality auditing.
MSE = (1 / (3·W·H)) · Σ [(R₁-R₂)² + (G₁-G₂)² + (B₁-B₂)²]
PSNR (dB) = 10 · log₁₀(255² / MSE) | SSIM = [(2μₓμᵧ+C₁)(2σₓᵧ+C₂)] / [(μₓ²+μᵧ²+C₁)(σₓ²+σᵧ²+C₂)]
04 · Audio Polyphase Downsampling & 4-Bit IMA ADPCM (0x0011) Encoding
Module 04 · 4-Bit IMA ADPCM Audio
SlimCodec resamples 48 kHz stereo audio down to 44.1 kHz, 22.05 kHz, or 16 kHz via OfflineAudioContext and encodes PCM frames into standard 4-bit IMA ADPCM WAV (RIFF format 0x0011), achieving 75%–88% audio byte reduction with 0 bytes uploaded.
ADPCM Step Index = clamp(Index + IndexTable[Nibble & 0x07], 0, 88)
Compression Ratio = 16-bit PCM (176.4 KB/s) → 4-bit Mono 22.05kHz ADPCM (11.1 KB/s, -93.7% bytes)
05 · Video Resolution Scaling, FPS Capping & VP9 / MP4 Bitrate Control
Module 05 · Video Bitrate & FPS Transcoder
SlimCodec pairs HTMLCanvasElement.captureStream with hardware-accelerated MediaRecorder MP4 and WebM codecs to downscale 4K/1080p video to 720p/480p, cap frame rates at 30 fps or 24 fps, and lock target bitrates between 300 kbps and 2.5 Mbps with 0 bytes uploaded.
Target Bitrate = VideoBitsPerSecond ∈ {2500k, 1200k, 600k, 300k} + AudioBitsPerSecond (64k)
Estimated Size(MB) = (TargetBitrate_kbps × Duration_seconds) / 8192
06 · Zero-Upload Memory Sandbox & Strict SHA-256 CSP Baseline
Module 06 · Zero-Upload Sandbox
SlimCodec enforces a strict default-src 'none' Content-Security-Policy with SHA-256 JSON-LD hashes over HTTPS, processing all images, audio tracks, and video streams locally via ArrayBuffer and Blob URLs with 0 bytes transmitted and preferences saved in localStorage.
Network Upload = 0 bytes (100% Client-Side ArrayBuffer & Blob URL Processing)
Security Baseline = CSP default-src 'none'; script-src 'self' 'sha256-...'; X-Frame-Options: DENY