Skip to content

n4zen-dev-studio/PixelBench

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

18 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ธ PixelBench โ€” Mobile Image Compression Benchmark Suite

Project Overview

PixelBench is a demo app for the rn-image-compressor TurboModule, focused on repeatable image compression benchmarks and UI performance reporting.

A reusable high-performance React Native TurboModule (rn-image-compressor) paired with a visual benchmarking tool (PixelBench) to evaluate, compare, and optimize image compression strategies on real devices.


React Native TurboModule JSI Platform Performance License Status


๐Ÿ“š Table of Contents


๐ŸŽฌ Demo Videos

See PixelBench in action across its two core flows: benchmarking image compression and real-world single/batch compression.


๐Ÿ–ผ Image Compression Flow

Compression Flow Demo

End-to-end image compression workflow optimized for mobile performance.

Highlights

  • Image selection + preview
  • Compression configuration
  • Optimized output generation
  • Real-world validation flow

โšก Benchmarking & Results Demo

Benchmarking Demo

Run compression benchmarks, compare outputs, and analyze performance metrics in a single flow.

Highlights

  • Compression benchmark execution
  • Before/after comparison
  • Size reduction + timing metrics
  • Exportable performance insights

โฌ†๏ธ Back to top


๐Ÿš€ Executive Summary

Mobile applications increasingly depend on image-heavy workflowsโ€”document capture, uploads, OCR pipelines, and media sharing. However, image compression is often:

  • Slow (JS-bound processing)
  • Inconsistent across platforms
  • Hard to measure and optimize

๐Ÿ”ง Solution

PixelBench addresses this through a two-part system:

1. RNImageCompressor (Reusable TurboModule)

  • High-performance native compression engine
  • Designed as a drop-in library for any React Native app
  • Built on JSI for near-zero bridge overhead

2. PixelBench (Benchmarking Tool)

  • Visual interface to compare compression strategies

  • Enables developers to optimize for their specific use case

    • Latency (speed)
    • Storage savings
    • Compression ratio
    • Throughput

๐Ÿ‘‰ Together, this forms a developer-facing performance toolkit, not just an implementation.

โฌ†๏ธ Back to top


๐Ÿงฉ System Overview

RNImageCompressor (Reusable Native Module)
                +
PixelBench (Benchmark + Visualization App)
                =
Full Performance Evaluation Platform

๐ŸŽฏ Key Positioning

  • Library โ†’ Use RNImageCompressor in production apps
  • Tool โ†’ Use PixelBench to decide how to use it

๐Ÿ— Architecture & Pipeline

Image Input (Camera / Gallery)
        โ†“
Preprocessing (optional resize, normalization)
        โ†“
RNImageCompressor (TurboModule - Native Layer)
        โ†“
Compression Execution (JPEG/WebP)
        โ†“
Metrics Collection
        โ†“
PixelBench Aggregation Layer
        โ†“
UI Visualization + JSON Export

System Architecture Diagram


โš™๏ธ Technical Deep Dive

๐Ÿงฑ Core Stack

Mobile

  • React Native 0.74+
  • TypeScript
  • Ignite CLI

Native Layer

  • iOS: Swift / Objective-C++
  • Android: Kotlin / C++
  • JSI bindings

๐Ÿง  RNImageCompressor (Reusable Module)

Designed as a production-ready, reusable TurboModule:

Capabilities

  • Compress images with adjustable quality
  • Support for multiple formats (JPEG, WebP)
  • Batch processing support
  • Deterministic output

Why Native Layer?

  • Access to platform-optimized encoders
  • Avoid JS thread bottlenecks
  • Utilize hardware acceleration where available

โšก Why TurboModules (JSI)?

Traditional bridge:

  • JSON serialization overhead
  • Async bottlenecks

TurboModules:

  • Direct native calls
  • Lower latency
  • Higher throughput

๐Ÿ‘‰ Critical for high-frequency operations like image processing


๐Ÿ“ˆ Benchmarking & Metrics

PixelBench is a developer-facing decision tool, not just a demo.

๐Ÿ“Š What You Can Measure

  • Compression time (latency)
  • Output size reduction
  • Compression ratio
  • Throughput
  • Failure rates

๐Ÿงช Use Case

What compression quality gives me the best tradeoff between speed and file size for my app? How much will the UI stressor/animations affect the compression speeds Which compression might be better for cetain plaforms, devices, or situations.

PixelBench is visual playground for testing.


๐Ÿ“Š Example Output

{
  "originalSizeKB": 4200,
  "compressedSizeKB": 820,
  "compressionRatio": 0.195,
  "durationMs": 47,
  "quality": 0.7
}

๐Ÿ’ก Real Impact

  • Optimize uploads dynamically
  • Reduce backend costs
  • Improve UX (faster interactions)
  • Tune pipelines for OCR/ML workloads

โฌ†๏ธ Back to top


๐Ÿงช Demo & Visuals

๐Ÿ“ฑ Benchmark UI


๐Ÿ›  Developer Setup

๐Ÿ“ฆ Install

git clone <repo>
cd pixelbench
pnpm install

โ–ถ๏ธ Run

pnpm ios
pnpm android

๐Ÿ“ฒ Latest Release

Download APK from the latest Release


๐Ÿ”Œ Using RNImageCompressor in Your App

import { compressImage } from "react-native-image-compressor"

const result = await compressImage(uri, {
  quality: 0.7,
  format: "jpeg",
})

๐Ÿ”Œ Using PixelBench for compression benchmarking

How to reproduce benchmarks

  1. Open the PixelBench screen.
  2. Pick 10 images.
  3. Preset: social, Concurrency: 2, Repeat runs: 5, Stress: ON.
  4. Run benchmark.
  5. Copy Markdown โ€œPixelBench Resultsโ€.

Benchmark windows include baseline (3s before), during (iteration), and recovery (3s after).

Running Benchmarks in Release

  • iOS: run a Release scheme (or use your Ignite/Expo release build flow) and disable remote debugging.
  • Android: run a release variant (e.g., assembleRelease + install) or your release build flow.
  • Debug builds can distort timings; always compare like-for-like release runs.

PixelBench Results Example

Results are generated from the in-app exporter and pasted here.

Results example will be added soon!

โฌ†๏ธ Back to top


๐Ÿง  Design Decisions

Why Split Module + Tool?

  • Keeps core module lightweight and reusable
  • Enables experimentation without polluting production code

Why Real Device Benchmarking?

  • Performance varies by device
  • Simulators are misleading
  • Provides ground-truth metrics

Why Focus on Metrics?

  • Compression is a tradeoff problem
  • Developers need visibility, not guesses

๐Ÿš€ What Makes This Unique

  • Reusable TurboModule library + benchmarking platform
  • Real-world performance testing (not synthetic)
  • Developer-centric tooling
  • Cross-platform native optimization
  • Data-driven compression tuning

โฌ†๏ธ Back to top


๐Ÿ”ฎ Future Enhancements

  • Adaptive compression (network-aware)
  • GPU acceleration
  • Integration with Optical Character Recognition and Optical Object Detection pipelines

๐Ÿ“„ License

MIT License โ€” feel free to use and adapt.

โฌ†๏ธ Back to top

About

A reusable high-performance **React Native TurboModule (`rn-image-compressor`)** paired with a **visual benchmarking tool (`PixelBench`)** to evaluate, compare, and optimize image compression strategies on real devices.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors