1 stable release
| 1.0.0 | Jan 12, 2026 |
|---|
#381 in Images
15KB
93 lines
png-resizer
High-performance PNG image resizer built with Rust and the fast_image_resize library.
Features
- ⚡ Blazing Fast: Uses SIMD instructions (AVX2, SSE4.1, NEON) + multithreading via Rayon
- 🎨 High Quality: Proper sRGB ↔ linear RGB color space conversion for accurate resizing
- 📦 Zero Dependencies: No external C libraries required (unlike libvips-based tools)
- 🔧 Easy to Use: Simple CLI interface with automatic aspect ratio preservation
- 💾 Memory Efficient: Optimized for processing large images
Installation
From crates.io
cargo install png-resizer
From source
git clone https://github.com/cumulus13/png-resizer
cd png-resizer
cargo build --release
Binary will be at ./target/release/png-resizer
Usage
Basic Usage (maintains aspect ratio automatically)
png-resizer input.png --width 800 -o output.png
Specify both width and height
png-resizer input.png --width 800 --height 600 -o output.png
Choose resize algorithm
# Fastest (lower quality)
png-resizer input.png -w 800 -o output.png -a nearest
# High quality (default)
png-resizer input.png -w 800 -o output.png -a lanczos3
Disable multithreading
png-resizer input.png -w 800 -o output.png --no-threads
Command Line Arguments
Usage: png-resizer [OPTIONS] <INPUT> --output <OUTPUT> --width <WIDTH>
Arguments:
<INPUT> Input PNG file path
Options:
-o, --output <OUTPUT> Output PNG file path
-w, --width <WIDTH> Target width (pixels)
--height <HEIGHT> Target height (pixels). If not specified, maintains aspect ratio
-a, --algorithm <ALGORITHM> Resize algorithm [default: lanczos3] [possible values: nearest, bilinear, catmull, mitchell, lanczos3]
--no-threads Disable multithreading
-v, --version Show version information
-h, --help Print help
Resize Algorithms
| Algorithm | Speed | Quality | Best For |
|---|---|---|---|
nearest |
⚡⚡⚡⚡⚡ | ⭐ | Pixel art, extremely fast preview |
bilinear |
⚡⚡⚡⚡ | ⭐⭐⭐ | General use, good speed/quality balance |
catmull |
⚡⚡⚡ | ⭐⭐⭐⭐ | Smooth edges, natural looking |
mitchell |
⚡⚡⭐ | ⭐⭐⭐⭐ | Balanced sharpness and smoothness |
lanczos3 |
⚡⚡ | ⭐⭐⭐⭐⭐ | Best quality (default, recommended) |
Examples
Resize maintaining aspect ratio
png-resizer photo.png -w 1920 -o photo_resized.png
Create thumbnail
png-resizer large_image.png -w 300 -o thumbnail.png
Batch processing
# Bash/Linux
for file in *.png; do
png-resizer "$file" -w 800 -o "resized_$file"
done
# PowerShell
Get-ChildItem *.png | ForEach-Object {
png-resizer $_.Name -w 800 -o "resized_$($_.Name)"
}
Different quality levels
# Maximum quality (slower)
png-resizer input.png -w 1200 -o high_quality.png -a lanczos3
# Fast processing (lower quality)
png-resizer input.png -w 1200 -o fast.png -a bilinear
Performance
This tool uses fast_image_resize, which is one of the fastest image resizing libraries available:
- vs ImageMagick: ~3-5x faster
- vs Pillow (Python): ~4-6x faster
- vs Go standard library: ~2-3x faster
Performance comes from:
- SIMD vectorization (processes multiple pixels simultaneously)
- Multi-core utilization via Rayon
- Optimized memory access patterns
- Zero-copy operations where possible
Technical Details
Why fast_image_resize?
fast_image_resize provides:
- Proper color space handling (sRGB ↔ linear RGB conversion)
- Multiple high-quality resize algorithms
- SIMD support for x86-64 (AVX2, SSE4.1) and ARM (NEON)
- Thread-safe parallel processing
- No external C library dependencies
Aspect Ratio Preservation
When --height is not specified, the tool automatically calculates the height to maintain the original image's aspect ratio:
new_height = original_height × (new_width / original_width)
Alternative Tools
If you need additional features, consider:
- Rimage: Full-featured image optimization CLI (also uses
fast_image_resize) - ImageMagick: Feature-rich but slower
- libvips: Fast but requires C library installation
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
👤 Author
Acknowledgments
- Built with fast_image_resize by Kirill Kuzminykh
- Uses the excellent image crate for PNG encoding/decoding
- CLI powered by clap
See Also
Dependencies
~28–40MB
~699K SLoC