| Crates.io | moosicbox_image |
| lib.rs | moosicbox_image |
| version | 0.1.4 |
| created_at | 2024-10-04 04:08:46.627073+00 |
| updated_at | 2025-07-21 19:20:00.080475+00 |
| description | MoosicBox image package |
| homepage | |
| repository | https://github.com/MoosicBox/MoosicBox |
| max_upload_size | |
| id | 1396083 |
| size | 60,164 |
A command-line image processing tool for resizing, converting, and optimizing images with support for multiple formats.
The Image Helper (image_helper) is a utility for image processing operations including:
cargo install --path packages/image --features "build-binary,image,libvips"
System dependencies for optimal performance:
sudo apt-get install libvips-devbrew install vipsResize an image to specific dimensions:
image_helper input.jpg output.jpg --width 800 --height 600
Resize by width only (height calculated automatically):
image_helper input.png output.png --width 1024
Resize by height only (width calculated automatically):
image_helper large.jpg thumbnail.jpg --height 200
Convert between formats:
image_helper photo.png photo.jpg --encoding JPEG --quality 85
Set compression quality (0-100):
image_helper input.jpg output.jpg --width 800 --quality 95
image_helper \
/path/to/input.png \
/path/to/output.webp \
--width 1200 \
--height 800 \
--encoding WEBP \
--quality 90
| Option | Short | Description | Default |
|---|---|---|---|
--width |
-w |
Target width in pixels | Auto-calculated |
--height |
-h |
Target height in pixels | Auto-calculated |
--encoding |
-e |
Output format (JPEG, PNG, WEBP) | Auto-detect from extension |
--output |
-o |
Output file path | Required |
--quality |
-q |
Compression quality (0-100) | 80 |
The tool intelligently handles aspect ratios:
# Resize to exact dimensions (may distort image)
image_helper input.jpg output.jpg --width 800 --height 600
# Height calculated to maintain aspect ratio
image_helper input.jpg output.jpg --width 800
# Width calculated to maintain aspect ratio
image_helper input.jpg output.jpg --height 600
# Original dimensions preserved, format/quality change only
image_helper input.png output.jpg --encoding JPEG --quality 85
# Create small thumbnail
image_helper photo.jpg thumb.jpg --width 150 --quality 75
# Create medium preview
image_helper photo.jpg preview.jpg --width 400 --quality 80
# Convert PNG to WebP for better compression
image_helper large.png optimized.webp --quality 85
# Convert old JPEG to high-quality WebP
image_helper old-photo.jpg new-photo.webp --quality 90
#!/bin/bash
mkdir -p thumbnails
for img in *.jpg; do
image_helper "$img" "thumbnails/${img%.jpg}_thumb.jpg" --width 200 --quality 80
done
# Standard album cover size
image_helper cover.png cover.jpg --width 1000 --height 1000 --quality 90
# High-res album cover
image_helper cover.png cover_hd.jpg --width 1400 --height 1400 --quality 95
Common errors and solutions:
The image helper is used by other MoosicBox components: