100KB Extension v1.1.1: Compress & resize files in 0ms directly in Google Chrome

Add to Chrome
KB
100kb
Organize PDF
Merge PDF
Split PDF
Unlock PDF
Optimize PDF
Compress PDFFAST
Convert PDF
JPG to PDF
PDF to Word
Crop & Scale
Passport Photo MakerICAO
Compress Image
Compress Signature
HEIC to JPG
Increase Image Size
Resize & Crop Image
PNG to JPG
JPG to PNG
Backdrop & Stamps
Remove BackgroundAI
Stamp & Date Cleaner
Combine Images
Photo & Signature Joiner
Visa & Passport SpecsSPECS
🇺🇸US Visa & Passport🇮🇳India Exams (UPSC, NEET)🌐Schengen, UK & Canada
Browse All Guidelines
🌐 Browse All Countries🇮🇳India (Exams)🇺🇸United States🇬🇧United Kingdom🇨🇦Canada🇦🇺Australia🇮🇪Ireland🇳🇿New Zealand
Guides
Developer Platform & SDK
Developer OverviewWASM Architecture & Self-Serve Licensing
Developer SDK Technical SpecsWASM Methods & Parameters
Commercial Licensing & PricingSelf-Serve B2B Licensing
WordPress & WooCommerceAuto Media Library WASM Hook
Shopify App & StorefrontZero-Upload Image Optimization
Integrations & PluginsPre-built Framework Components
KB
100kb

Fast, secure resizers. Statically compiled and running purely in JavaScript to keep Aadhaar, marksheets, and applicant credentials confidential.

Support & Contact:

Email: info@100kb.in

Developer SDK & API Overview
  • • Developer SDK Technical Specs
  • • Commercial Licensing & Pricing
  • • WordPress Plugin & Widget
  • • Shopify Liquid Custom Uploads
  • • Multi-Framework SDK Hub

Image Tools

  • Compress Image
  • Passport Photo Maker
  • Compress Signature
  • Photo & Signature Joiner
  • Remove Background
  • HEIC to JPG
  • JPG to PNG
  • PNG to JPG
  • Stamp & Date Cleaner
  • Increase Image Size
  • Resize & Crop Image

PDF Tools

  • Compress PDF
  • JPG to PDF
  • Merge PDF
  • PDF to Word
  • Split PDF
  • PDF to JPG
  • Unlock PDF

Guides

  • → All Technical Guides Hub
  • Signature & 20KB Guide
  • Real Estate Photo Guide
  • Document Guidelines Hub

Visa & Passport Specs

→ Exam Guidelines Hub

✓ UPSC Exam Rules (50KB caps)

✓ SSC Exam Rules (20KB caps)

✓ Banking IBPS / SBI Caps

✓ NSDL PAN Portal Sizes

US (USCIS, DS-260) UK (UKVI, Passport) Canada (IRCC, PR)

Disclaimer: 100kb.in is a private, independent utility website and is not affiliated with, authorized, or endorsed by any government entity or official exam conducting authority, including UPSC, SSC, IBPS, SBI, or NSDL. All product names, logos, and brands are property of their respective owners, and are used for identification and reference purposes only.

EnglishEspañolPortuguêsFrançaisDeutsch日本語Русский中文한국어ItalianoSvenskaNorskRomânăBahasa Indonesia

© 2026 100kb.in. All rights reserved.

About UsPrivacy PolicyTerms of ServiceContact SupportGuidesSuggest a ToolAll Tools
Back to Guides

Engineering Guide to Image Compression Algorithms: Lossy vs. Lossless & DCT Mathematics

Published August 14, 2026·11 min read

Client-Side Image Compressor

Compress images to exact KB limits in your browser with zero server uploads.

Use Tool — Free

In modern systems engineering, computer vision, and web architecture, image optimization is far more complex than simple geometric downscaling. Whether you are engineering high-throughput image ingest pipelines for e-commerce, formatting biometric passport photographs for consular visa servers, or optimizing Core Web Vitals to achieve 100 PageSpeed scores, mastering the algorithmic foundations of digital image compression is essential. In this technical masterclass, we explore the mathematical principles distinguishing lossless and lossy codecs, break down the 5-stage JPEG compression pipeline from spatial domain to frequency domain, analyze modern next-generation formats (WebP, AVIF, HEIC), and examine how client-side WebAssembly achieves deterministic target byte sizes in sub-millisecond execution loops.

1. Lossless vs. Lossy Compression: Fundamental Information Theory

Digital compression operates under Claude Shannon’s information theory, categorizing algorithms into two distinct computational paradigms based on whether data reconstruction is bit-exact or perceptually approximate.

Lossless Compression (Bit-Exact Entropy Encoding)

Lossless compression algorithms reduce file size by eliminating statistical redundancy in the underlying data stream without modifying a single pixel value. When a lossless file is decompressed into memory, the output array is mathematically identical to the original input. Common lossless algorithms include Lempel-Ziv-Welch (LZW), Deflate (combining LZ77 and Huffman coding), and Run-Length Encoding (RLE). Formats relying on lossless architectures include PNG (Portable Network Graphics), GIF, TIFF, and Lossless WebP. Lossless compression is mandatory for high-contrast line art, text documents, legal signatures, and medical radiography where any pixel degradation introduces unacceptable diagnosis or legal risk.

Lossy Compression (Psychovisual Quantization)

Lossy compression algorithms permanently discard high-frequency visual data that the Human Visual System (HVS) cannot readily discern under typical viewing conditions. Human perception is biologically optimized to detect luminance (brightness) contrast and spatial edges rather than microscopic chrominance (color) shifts. By transforming spatial pixel arrays into frequency spectra and applying psychoacoustic/psychovisual quantization matrices, lossy algorithms achieve compression ratios between 10:1 and 50:1 without apparent visual degradation. Formats built on lossy foundations include JPEG, WebP, AVIF, and HEIC.

2. Codec Comparison Matrix: Modern Image Compression Standards

The table below details the algorithmic structures, color space capabilities, and operational characteristics of contemporary web image formats.

Codec / FormatPrimary AlgorithmCompression TypeTransparency (Alpha)Typical Compression Ratio
JPEG (.jpg)Discrete Cosine Transform (DCT) + HuffmanLossyNo10:1 to 25:1
PNG (.png)Deflate (LZ77 + Huffman) with Delta FiltersLosslessYes (8-bit alpha)2:1 to 4:1
WebP (.webp)VP8 intra-frame predictive coding / LZ77Lossy & LosslessYes15:1 to 35:1
AVIF (.avif)AV1 transform blocks + directional intra-predictionLossy & LosslessYes (10/12-bit HDR)25:1 to 50:1
HEIC (.heic)HEVC / H.265 discrete transform gridLossy & LosslessYes20:1 to 40:1

3. Deep Dive: The 5-Stage Mathematical Pipeline of JPEG Compression

To understand how a 10MB digital camera photo is compressed to under 100KB, we trace its execution through the five core stages of the standard ISO/IEC 10918-1 JPEG pipeline.

  • Stage 1: Color Space Transformation (RGB to YCbCr): The input image is converted from Red-Green-Blue (RGB) color space to YCbCr space, where Y represents Luminance (achromatic brightness), Cb represents Blue-difference Chroma, and Cr represents Red-difference Chroma. Because human photoreceptors contain far more rods (luminance) than cones (chrominance), isolating color data allows aggressive optimization without perceived loss.
  • Stage 2: Chroma Subsampling (4:2:0): In 4:2:0 subsampling, for every 2x2 block of four pixels, all four luminance samples (Y) are retained, but only one Cb and one Cr chroma sample are sampled. This biological optimization immediately eliminates 50% of the raw color data payload before mathematical transforms begin.
  • Stage 3: Discrete Cosine Transform (DCT): The image is segmented into non-overlapping 8x8 pixel blocks. Each 8x8 spatial block is transformed into an 8x8 matrix of frequency coefficients using the 2D Discrete Cosine Transform formula: F(u,v) = 1/4 C(u) C(v) sum[x=0..7] sum[y=0..7] f(x,y) cos[(2x+1)u pi / 16] cos[(2y+1)v pi / 16]. The top-left value F(0,0) represents the DC coefficient (average block brightness), while the remaining 63 values represent AC coefficients (higher-frequency textures and edge details).
  • Stage 4: Quantization (The True Lossy Step): Each DCT coefficient is divided by a corresponding value from a psycho-visual Quantization Table and rounded to the nearest integer: Q(u,v) = round(F(u,v) / Table(u,v)). Because human eyes cannot detect high-frequency noise, quantization tables use large divisors for high frequencies, causing dozens of AC coefficients to collapse to zero.
  • Stage 5: Entropy Encoding (Zig-Zag, RLE & Huffman): The quantized 8x8 matrix is scanned in a diagonal zig-zag pattern, grouping long runs of zeros together. Run-Length Encoding (RLE) compresses these zero sequences, and Huffman coding assigns shorter binary bit codes to the most frequently occurring symbol patterns.

4. How 100kb.in Achieves Exact Target Byte Ceilings in Under 15ms

Government, consular, and job examination upload portals do not accept vague quality levels (e.g., "Medium" or "High"); they demand strict byte thresholds (such as strictly under 50KB or strictly under 100KB).

To hit exact target thresholds with zero server round-trips, 100kb.in executes a deterministic binary search optimization loop entirely inside your browser memory using HTML5 OffscreenCanvas and WebAssembly memory buffers.

The 7-Iteration Binary Search Optimization Loop

Given an uploaded file and a target ceiling of 100KB (102,400 bytes), our engine initializes bounding parameters: lowQuality = 0.05 and highQuality = 0.98. Within a 7-step iterative loop, it computes midQuality = (lowQuality + highQuality) / 2 and encodes the canvas frame to an in-memory blob. If blob.size exceeds 102,400 bytes, highQuality is constrained to midQuality; if below the ceiling, lowQuality is elevated to preserve maximum visual fidelity. Because 2^7 = 128 discrete subdivisions, the algorithm converges on the mathematically optimal quality factor in approximately 12ms to 16ms.

Adaptive Spatial Rescaling Fallback

When a user uploads an uncompressed 24MP ProRAW photo and requests an ultra-low threshold (such as under 20KB for a signature or thumb impression), JPEG quantization alone is insufficient to reach the byte limit without severe macro-blocking artifacts. In these boundary cases, our algorithm automatically activates adaptive spatial downscaling, calculating the exact proportional bicubic reduction required to hit the target size cleanly.

Client-Side Image Compressor

Compress images to exact KB limits in your browser with zero server uploads.

Use Tool — Free
Advertisement

Frequently Asked Questions

Why does converting a PNG to JPG reduce file size so dramatically?

PNG utilizes lossless Deflate compression, preserving every single pixel value across 24-bit or 32-bit color matrices. JPG utilizes lossy Discrete Cosine Transform (DCT) and quantization, discarding high-frequency imperceptible details and subsampling color channels (4:2:0). This mathematical difference routinely shrinks a 5MB PNG down to 300KB as a JPEG with virtually zero visible difference.

What is the difference between image quality and image resolution?

Resolution refers to the spatial dimensions of an image measured in pixels (such as 1920x1080 or 600x600 pixels). Quality refers to the compression compression fidelity and quantization aggressiveness used to encode those pixels. You can compress an image to under 100KB while keeping its full 1920x1080 pixel dimensions intact.

Why do government portals reject photos that were renamed from PNG to JPG?

Simply changing a file extension in your operating system from "photo.png" to "photo.jpg" does not modify the internal binary structure. The file still begins with the PNG magic byte header (89 50 4E 47). Consular and examination portal backends inspect binary mime-type signatures; when a mismatch is detected, the server automatically rejects the upload.

Does compressing an image multiple times ruin quality?

Yes. Re-compressing an already compressed JPEG (called "generation loss") applies quantization over previously quantized DCT blocks. This compounds high-frequency artifacts, creating visible checkerboard ringing and blurry edges. Always perform compression directly from the original high-resolution camera capture.

Why is 4:2:0 chroma subsampling invisible to the human eye?

Human retinas contain roughly 120 million rod cells (which perceive luminance and motion) but only 6 to 7 million cone cells (which perceive color). Because human visual acuity for color detail is significantly lower than for brightness, halving chrominance resolution in 4:2:0 subsampling is essentially imperceptible in natural photography.

Related Guides

How to Compress an Image to 50 KB — Free, Private, No Upload

Jul 11, 2026

The Ultimate Guide to Amazon Product Image Requirements (2026 Standards)

Jul 15, 2026

Why Was My Passport Photo Rejected? (2026 Guide for All Countries)

Jul 11, 2026

Client-Side WebAssembly vs. Cloud File Uploads: The Ultimate Privacy Guide

Aug 14, 2026