You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document provides a comprehensive comparison of codebase sizes between pixo and other image compression libraries referenced in the benchmarks, including Rust, C/C++, and JavaScript/Node.js ecosystems.
Different libraries support different image formats, which affects their codebase size:
Library
PNG
JPEG
GIF
WebP
AVIF
TIFF
BMP
Other
Encode
Decode
Total Formats
pixo
✓
✓
-
-
-
-
-
-
✓
✓
2
jpeg-encoder
-
✓
-
-
-
-
-
-
✓
-
1
image-png
✓
-
-
-
-
-
-
-
✓
✓
1
image
✓
✓
✓
✓
✓
✓
✓
ICO, PNM, HDR, etc.
✓
✓
15+
oxipng
✓
-
-
-
-
-
-
-
✓
✓
1
sharp
✓
✓
✓
✓
✓
✓
-
SVG (read-only)
✓
✓
6+
squoosh
✓
✓
-
✓
✓
-
-
QOI, JXL
✓
✓
6
Format-Adjusted Size Comparison
When comparing libraries that support PNG+JPEG (with encode + decode):
Library
Core LOC
Formats
Operations
LOC per Format
pixo
17,706
2
Encode+Decode
8,853
image
21,571
15+
Encode+Decode
~1,438
sharp (excl libvips)
4,196
6+
Encode+Decode
~700
Note: image and sharp have lower LOC-per-format because they delegate to specialized codecs. pixo implements everything from scratch, including decoders for PNG (with INFLATE) and JPEG (baseline DCT).
Detailed Analysis
pixo (This Project)
=== PIXO ===
Rust files: 49
Total Rust code: 37,780 LOC
Component Breakdown:
├── PNG encoding: 3,485 LOC (src/png/mod.rs)
├── PNG filters: 1,155 LOC (src/png/filter.rs)
├── PNG decoding: 1,000 LOC (src/decode/png.rs)
├── JPEG encoding: 2,154 LOC (src/jpeg/mod.rs)
├── JPEG DCT: 1,277 LOC (src/jpeg/dct.rs)
├── JPEG progressive: 948 LOC (src/jpeg/progressive.rs)
├── JPEG Huffman: 817 LOC (src/jpeg/huffman.rs)
├── JPEG decoding: 1,102 LOC (src/decode/jpeg.rs)
├── DEFLATE: 2,626 LOC (src/compress/deflate.rs)
├── LZ77: 2,491 LOC (src/compress/lz77.rs)
├── Inflate decoder: 664 LOC (src/decode/inflate.rs)
├── SIMD (x86): 2,255 LOC (src/simd/x86_64.rs)
├── SIMD (ARM): 577 LOC (src/simd/aarch64.rs)
├── Image resizing: 1,237 LOC (src/resize.rs)
├── CLI: 1,127 LOC (src/bin/pixo.rs)
└── Other utilities: 1,779 LOC
Test Code: 20,074 LOC (53.1%)
├── src/ colocated: 10,358 LOC
├── tests/: 4,957 LOC
└── benches/: 2,274 LOC
#[test] functions: 965
├── PNG tests: 161
├── JPEG tests: 150
├── Compression tests: 204
├── Decoding tests: 145
├── SIMD tests: 78
├── Resize tests: 30
├── Integration tests: 119
└── Other: 78
Playwright e2e tests: 22
Files with colocated tests: 28
mozjpeg (Industry Standard)
=== MOZJPEG ===
Total C/ASM code: ~112,000 LOC
Component Breakdown:
├── Core JPEG codec: 17,506 LOC (jc*.c, jd*.c files)
├── SIMD optimizations: 50,623 LOC (simd/ directory)
│ ├── Assembly: 30,704 LOC
│ ├── C intrinsics: 16,449 LOC
│ └── Headers: 2,600 LOC
├── Java bindings: 3,813 LOC
├── Build system: 2,761 LOC
└── Other: ~37,000 LOC
History: 30+ years of development
Original: IJG libjpeg (1991)
Mozilla fork: 2014
sharp (Node.js)
=== SHARP ===
Own code: 10,127 LOC
├── C++ bindings: 3,404 LOC
├── JavaScript: 3,197 LOC
├── TypeScript: 744 LOC
└── Other: 2,782 LOC
BUT depends on libvips:
└── libvips: 194,229 LOC (C/C++)
Effective total: ~204,000 LOC
squoosh (Google)
=== SQUOOSH ===
Own code: 31,662 LOC
├── TypeScript/JS: 28,268 LOC (web app)
├── C++: 942 LOC (custom codecs)
├── Rust: 405 LOC (resize)
└── Build scripts: 2,047 LOC
WASM codecs included:
├── mozjpeg (compiled to WASM)
├── oxipng (compiled to WASM)
├── libwebp
├── libjxl
└── libavif
Each WASM codec is 200KB-800KB
Core Codec Comparison
JPEG Encoding (Pure Codec Code Only)
Library
Language
Core LOC
SIMD LOC
Total
Compression Quality
pixo
Rust
2,989
500*
3,489
Good (4-5% vs mozjpeg)
jpeg-encoder
Rust
3,240
800*
4,040
Good
mozjpeg
C/ASM
17,506
50,623
68,129
Best (reference)
* Estimated SIMD lines shared with other codecs
PNG Encoding (Pure Codec Code Only)
Library
Language
PNG LOC
DEFLATE LOC
Total
Notes
pixo
Rust
2,691
2,910
5,601
All-in-one
image-png
Rust
8,890
-
8,890
Uses miniz_oxide
+ miniz_oxide
Rust
-
4,838
4,838
DEFLATE dep
Total
13,728
lodepng
C++
5,932
(included)
5,932
Single file
oxipng
Rust
4,534
-
4,534
Uses libdeflate
+ libdeflate
C
-
6,704
6,704
C dep
Total
11,238
pixo is 2.5× smaller than image-png+miniz_oxide and 2× smaller than oxipng+libdeflate
SIMD and Low-Level Optimization Analysis
The 4-5% compression gap between pixo and mozjpeg is explained by SIMD investment:
SIMD Code Size Comparison
Library
SIMD Code
% of Total
Architectures
pixo
3,356 LOC
19.9%
ARM64 NEON, x86 AVX2/SSE
jpeg-encoder
~3,230 LOC
77%
AVX2
mozjpeg
50,623 LOC
45%
SSE2, AVX2, NEON, MIPS, PowerPC
libdeflate
2,371 LOC
16%
SSE2, AVX2, NEON
What mozjpeg's 50K SIMD Lines Buy
mozjpeg SIMD directory:
├── x86_64/
│ ├── jsimd.c - SIMD dispatch
│ ├── jccolor-avx2.asm - Color conversion (AVX2)
│ ├── jccolor-sse2.asm - Color conversion (SSE2)
│ ├── jfdctint-avx2.asm - DCT forward (AVX2)
│ ├── jfdctint-sse2.asm - DCT forward (SSE2)
│ ├── jquanti-avx2.asm - Quantization (AVX2)
│ └── ... (90+ files)
├── arm64/
│ ├── jsimd_neon.S - NEON implementations
│ └── ... (30+ files)
└── ...
Each operation has multiple hand-tuned implementations
for different CPU features, painstakingly optimized
over 30+ years.
53.1% test coverage is exceptional for codec libraries (965 test functions)
The compression gap (4-5%) comes from missing 47K lines of hand-tuned assembly, not from code bloat
The AI-assisted approach traded decades of low-level optimization for:
Modern safety guarantees
High test coverage (53.1% test ratio, 85.5% line coverage)
Full encode/decode/resize support with zero dependencies
WASM compatibility
Maintainable codebase
JavaScript/Node.js Ecosystem
sharp (Most Popular Node.js Image Library)
sharp appears small:
├── Own code: 10,127 LOC
│ ├── C++: 3,404 LOC (libvips bindings)
│ ├── JavaScript: 3,197 LOC (API wrapper)
│ └── TypeScript: 744 LOC (type definitions)
BUT it depends on libvips:
└── libvips: 194,229 LOC
├── C: 161,227 LOC
├── C++: 9,984 LOC
└── Headers: 11,376 LOC
Effective total: ~204,000 LOC
pixo is a well-engineered, compact, well-tested image compression library that trades 30+ years of hand-tuned assembly optimization for modern Rust safety, WASM compatibility, and developer experience.
The library provides full encode/decode/resize support for both PNG and JPEG formats with zero external dependencies. With 965 test functions covering encoding, decoding, resizing, CLI, and edge cases, pixo maintains excellent test coverage while remaining compact.
The 4-5% compression gap is the cost of maintaining ~17.7K LOC instead of ~68K+ LOC (mozjpeg alone). For most web applications, this is an excellent tradeoff.
Appendix: Raw Data
pixo Component Breakdown
Component
File
LOC
PNG encoding
src/png/mod.rs
3,485
PNG decoding
src/decode/png.rs
1,000
PNG filters
src/png/filter.rs
1,155
DEFLATE
src/compress/deflate.rs
2,626
INFLATE (decoder)
src/decode/inflate.rs
664
JPEG encoding
src/jpeg/mod.rs
2,154
JPEG decoding
src/decode/jpeg.rs
1,102
JPEG DCT
src/jpeg/dct.rs
1,277
JPEG IDCT
src/decode/idct.rs
415
JPEG Huffman
src/jpeg/huffman.rs
817
Progressive JPEG
src/jpeg/progressive.rs
948
Image resizing
src/resize.rs
1,237
LZ77
src/compress/lz77.rs
2,491
x86 SIMD
src/simd/x86_64.rs
2,255
ARM SIMD
src/simd/aarch64.rs
577
Bit readers
src/decode/bit_reader.rs
500
CLI
src/bin/pixo.rs
1,127
Test Distribution
Location
LOC
Tests
src/ (colocated)
12,843
846
├── src/decode/
~1,900
145
├── src/bin/ (CLI)
~264
27
├── src/png/
~2,600
161
├── src/jpeg/
~2,355
150
├── src/compress/
~2,600
204
├── src/simd/
~1,090
78
├── src/resize.rs
~634
30
└── src/wasm.rs
~0
8
tests/
4,957
119
├── decode_conformance.rs
505
28
├── jpeg_conformance.rs
1,035
37
├── png_conformance.rs
786
25
└── simd_fallback.rs
542
24
benches/
2,274
-
web/e2e/ (Playwright)
320
22
Total
20,394
965
Note: Test counts include doctests, property-based tests, CLI unit tests, resize tests, and decode conformance tests.
Actual Code Coverage
Measured with cargo tarpaulin --all-features:
85.50% coverage, 5989/7002 lines covered
Component
Lines Covered
Total Lines
Coverage
DEFLATE (deflate.rs)
730
910
80.2%
PNG (mod.rs)
755
898
84.1%
JPEG (mod.rs)
664
758
87.6%
LZ77 (lz77.rs)
450
496
90.7%
Huffman (compress)
118
121
97.5%
JPEG Huffman
202
204
99.0%
JPEG progressive
158
178
88.8%
JPEG quantize
37
37
100.0%
JPEG trellis
121
122
99.2%
JPEG DCT
382
408
93.6%
PNG filters
237
269
88.1%
PNG bit_depth
86
94
91.5%
PNG chunk
10
10
100.0%
CRC32
44
44
100.0%
Adler32
12
13
92.3%
Bit writers
125
125
100.0%
Color module
35
35
100.0%
Error types
23
23
100.0%
Decoder modules:
decode/bit_reader.rs
89
96
92.7%
decode/idct.rs
123
123
100.0%
decode/inflate.rs
194
221
87.8%
decode/jpeg.rs
330
377
87.5%
decode/png.rs
251
308
81.5%
SIMD aarch64
212
212
100.0%*
SIMD fallback
65
66
98.5%
SIMD x86_64
0
87
0.0%*
* SIMD code coverage depends on test architecture. ARM NEON code is covered on aarch64; x86 AVX/SSE code is covered on x86_64.