Skip to content

The fastest image resizing library on the planet. Resize 1,000 images in 2 seconds.

License

Notifications You must be signed in to change notification settings

tranhuucanh/fast_resize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

21 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

FastResize

The fastest image resizing library on the planet. ๐Ÿš€

Resize 1,000 images in 2 seconds. Up to 2.9x faster than libvips, 3.1x faster than imageflow. Uses 3-4x less RAM than alternatives.

GitHub Stars GitHub Forks

Installation โ€ข Quick Start โ€ข Documentation โ€ข Benchmarks


๐Ÿ› ๏ธ Tech Stack & Stats

C++ C Ruby CMake Shell License

๐Ÿ’Ž Ruby: Gem Gem Downloads

๐Ÿ“ฆ CLI: GitHub Downloads


๐Ÿ“‘ Table of Contents


๐Ÿ† Why Fastest on the Planet?

FastResize has defeated the two most legendary image processing libraries in the world:

Library Description FastResize Advantage
libvips The gold standard for high-performance image processing. Used by Sharp (Node.js), Shopify, and Wikipedia. Widely recognized as one of the fastest image processing libraries available. FastResize is 1.7x - 2.9x faster
imageflow A Rust-based image manipulation engine designed for high throughput and accuracy. Known for powering modern large-scale image resizing pipelines. FastResize is 1.1x - 3.1x faster

๐Ÿ’ก Want to dive deeper? Explore full details about FastResize โ†’ Ask DeepWiki


๐Ÿ”ฅ Performance Benchmarks

Resize 1,000 images to 800px width

Tested on MacBook Pro M2, macOS Sonoma

Format FastResize libvips (parallel) imageflow ๐Ÿš€ vs libvips ๐Ÿš€ vs imageflow
JPG 2.10s โšก 5.24s 6.60s 2.5x faster 3.1x faster ๐Ÿ†
PNG 3.43s โšก 6.18s 8.41s 1.8x faster 2.5x faster
BMP 1.65s โšก 4.72s โŒ N/A 2.9x faster -
WEBP 14.03s โšก 23.52s 15.69s 1.7x faster 1.1x faster

FastResize wins in ALL formats! ๐ŸŽฏ

๐Ÿ“Š Speed Comparison Details

JPG Performance (1179ร—1409, 3 channels)

Tool Run 1 Run 2 Avg Time Throughput
FastResize 2.02s 2.17s 2.10s ~477 img/s โšก
libvips (parallel) 5.20s 5.28s 5.24s ~191 img/s
libvips (sequential) 16.32s 15.91s 16.11s ~62 img/s
imageflow 6.62s 6.58s 6.60s ~151 img/s

PNG Performance (2104ร—1160, 4 channels)

Tool Run 1 Run 2 Avg Time Throughput
FastResize 3.55s 3.32s 3.43s ~292 img/s โšก
libvips (parallel) 6.18s 6.18s 6.18s ~162 img/s
libvips (sequential) 31.95s 31.46s 31.71s ~32 img/s
imageflow 8.45s 8.37s 8.41s ~119 img/s

BMP Performance (1045ร—1045, 3 channels)

Tool Run 1 Run 2 Avg Time Throughput
FastResize 1.65s 1.64s 1.65s ~606 img/s โšก
libvips (parallel) 4.75s 4.70s 4.72s ~212 img/s
imageflow โŒ โŒ Not supported -

WEBP Performance (4275ร—2451, 3 channels)

Tool Run 1 Run 2 Avg Time Throughput
FastResize 13.99s 14.07s 14.03s ~71 img/s โšก
libvips (parallel) 23.94s 23.10s 23.52s ~43 img/s
imageflow 15.64s 15.73s 15.69s ~64 img/s
๐Ÿ’พ RAM Usage Comparison

FastResize uses 3-4x less RAM than alternatives!

PNG (1000 images, 2104ร—1160)

Library Time Throughput RAM Peak Compared
FastResize 3.19s 313 img/s 138 MB โšก -
libvips 6.11s 164 img/s 439 MB 3.2x more
imageflow 8.39s 119 img/s 514 MB 3.7x more

JPG (1000 images, 1179ร—1409)

Library Time Throughput RAM Peak Compared
FastResize 2.03s 493 img/s 271 MB โšก -
libvips 5.07s 197 img/s 460 MB 1.7x more
imageflow 6.59s 152 img/s 541 MB 2.0x more

Full Benchmark Details โ†’


๐Ÿ’ช Key Features

โšก Performance

  • Up to 3.1x faster than libvips & imageflow
  • 3-4x less RAM usage
  • Optimized C++ core with SIMD
  • Multi-threaded batch processing

๐Ÿ–ผ๏ธ Format Support

  • JPEG (via libjpeg-turbo)
  • PNG (via libpng)
  • WebP (via libwebp)
  • BMP (via stb_image)

๐ŸŽฏ Resize Modes

  • Exact size - Fixed width & height
  • Fit width - Auto height
  • Fit height - Auto width
  • Scale percent - Proportional resize

๐Ÿ”ง Quality Filters

  • Mitchell - Balanced (default)
  • Catmull-Rom - Sharp edges
  • Box - Fast, lower quality
  • Triangle - Bilinear

๐Ÿ“ฆ Installation

๐Ÿ’Ž Ruby

gem install fast_resize

๐ŸŽ macOS (Homebrew)

brew tap tranhuucanh/fast_resize
brew install fast_resize

๐Ÿง Linux

# Download latest release
VERSION="1.0.0"
wget https://github.com/tranhuucanh/fast_resize/releases/download/v${VERSION}/fast_resize-${VERSION}-linux-x86_64.tar.gz
tar -xzf fast_resize-${VERSION}-linux-x86_64.tar.gz
sudo cp fast_resize /usr/local/bin/
sudo chmod +x /usr/local/bin/fast_resize

# Verify installation
fast_resize --version

๐ŸŽฏ Quick Start

CLI

# Resize to width 800 (auto height)
fast_resize input.jpg output.jpg 800

# Resize to exact 800x600
fast_resize input.jpg output.jpg 800 600

# Batch resize all images in directory
fast_resize batch input_dir/ output_dir/ --width 800

# Batch resize specific files (from stdin, NULL-separated)
printf 'photo1.jpg\0photo2.jpg\0photo3.jpg' | fast_resize batch --stdin output_dir/ -w 800

# Convert format (JPG โ†’ PNG)
fast_resize input.jpg output.png 800

๐Ÿ’Ž Ruby

require 'fast_resize'

# Simple resize (width 800, auto height)
FastResize.resize('input.jpg', 'output.jpg', width: 800)

# Exact dimensions
FastResize.resize('input.jpg', 'output.jpg', width: 800, height: 600)

# With quality and filter options
FastResize.resize('input.jpg', 'output.jpg',
  width: 800,
  quality: 90,
  filter: :catmull_rom
)

# Batch resize - all images in directory
result = FastResize.batch_resize('images/', 'output/', width: 800)
puts "Processed: #{result[:success]}/#{result[:total]}"

# Batch resize - specific files only
files = ['photo1.jpg', 'photo2.jpg', 'photo3.jpg']
result = FastResize.batch_resize(files, 'output/', width: 800)
puts "Processed: #{result[:success]}/#{result[:total]}"

# Maximum speed mode (uses more RAM)
FastResize.batch_resize('images/', 'output/',
  width: 800,
  max_speed: true
)

Full Ruby Guide โ†’ โ€ข Full CLI Guide โ†’


๐Ÿ“– API Reference

Resize Options

Option Type Default Description
width int - Target width in pixels
height int - Target height in pixels
scale float - Scale factor (0.5 = 50%)
quality int 85 JPEG/WebP quality (1-100)
keep_aspect_ratio bool true Maintain aspect ratio
filter symbol :mitchell Resize filter algorithm

Resize Modes

Mode When Example
Fit Width Only width specified width: 800 โ†’ height auto
Fit Height Only height specified height: 600 โ†’ width auto
Exact Size Both specified width: 800, height: 600
Scale scale specified scale: 0.5 โ†’ 50% size

Filter Options

Filter Quality Speed Best For
:mitchell โ˜…โ˜…โ˜…โ˜…โ˜† โ˜…โ˜…โ˜…โ˜†โ˜† General use (default)
:catmull_rom โ˜…โ˜…โ˜…โ˜…โ˜… โ˜…โ˜…โ˜†โ˜†โ˜† Sharp edges, text
:triangle โ˜…โ˜…โ˜…โ˜†โ˜† โ˜…โ˜…โ˜…โ˜…โ˜† Smooth gradients
:box โ˜…โ˜…โ˜†โ˜†โ˜† โ˜…โ˜…โ˜…โ˜…โ˜… Maximum speed

Batch Options

Option Type Default Description
threads int auto Number of threads (0 = auto)
stop_on_error bool false Stop on first error
max_speed bool false Enable pipeline mode (faster, uses more RAM)

๐Ÿ“š Documentation

Complete usage guides:


๐Ÿ—๏ธ Architecture

FastResize is built on industry-standard, high-performance libraries:

Library License Purpose
libjpeg-turbo BSD-3-Clause JPEG decode/encode with SIMD
libpng libpng license PNG decode/encode
libwebp BSD-3-Clause WebP decode/encode
stb_image Public Domain BMP and fallback decode
stb_image_resize2 Public Domain High-quality resize with SIMD

Why So Fast?

  • โšก SIMD Optimization - SSE2/AVX (x86) and NEON (ARM) acceleration
  • ๐Ÿš€ Zero-copy Pipeline - Minimal memory allocation
  • ๐Ÿ’ช Multi-threaded - Parallel batch processing
  • ๐Ÿ”ฅ Memory-mapped I/O - Efficient file reading

๐Ÿ“„ License

FastResize is licensed under the BSD-3-Clause License.

See LICENSE for full details.


๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ› Bug Reports

Found a bug? Please open an issue with:

  • Your OS and version
  • FastResize version
  • Steps to reproduce
  • Expected vs actual behavior

๐Ÿ’– Support This Project

If FastResize helps you save time and money:

  • โญ Star this repository
  • ๐Ÿ› Report bugs and suggest features
  • ๐Ÿ“– Improve documentation
  • ๐Ÿ’ฌ Share FastResize with others

๐Ÿ“ฎ Contact & Support

GitHub: @tranhuucanh โ€ข Issues โ€ข Discussions


๐Ÿ™ Acknowledgments

Built with: libjpeg-turbo โ€ข libpng โ€ข libwebp โ€ข stb by Sean Barrett


Made with โค๏ธ by FastResize Project

If FastResize saves you time, give us a star! โญ

Star History Chart

โฌ† Back to top

About

The fastest image resizing library on the planet. Resize 1,000 images in 2 seconds.

Resources

License

Stars

Watchers

Forks

Packages

No packages published