@lxgicstudios/imgbatch
v1.0.0
Published
Batch image processing. Resize, convert, optimize, watermark, and rename images. CLI tool for bulk operations.
Downloads
8
Maintainers
Readme
imgbatch
Batch image processing. Resize, convert, optimize, watermark, and rename images. CLI tool for bulk operations.
Installation
npm install -g @lxgicstudios/imgbatchOr use directly:
npx @lxgicstudios/imgbatch resize "images/*.jpg" 800x600Commands
Resize images
imgbatch resize "photos/*.jpg" 1920x1080
imgbatch resize "uploads/*.png" 800x600 --fit containFit options: cover (default), contain, fill, inside, outside
Convert format
imgbatch convert "images/*.png" webp
imgbatch convert "photos/*.jpg" avif -q 85Formats: jpg, png, webp, avif, gif, tiff
Optimize file size
imgbatch optimize "uploads/*.jpg"
imgbatch optimize "gallery/**/*.png" -q 75Generate thumbnails
imgbatch thumbnail "products/*.jpg" 200
imgbatch thumbnail "gallery/*.png" 150 -o thumbs/Add watermark
imgbatch watermark "photos/*.jpg" logo.png
imgbatch watermark "*.jpg" watermark.png --position southeastPositions: center, north, south, east, west, northeast, northwest, southeast, southwest
Other commands
imgbatch rotate "scans/*.jpg" 90
imgbatch grayscale "photos/*.jpg"
imgbatch blur "backgrounds/*.png" 10
imgbatch info photo.jpgOptions
| Option | Description |
|--------|-------------|
| -o, --output <dir> | Output directory (default: ./output) |
| -q, --quality <n> | Quality 1-100 (default: 80) |
| -p, --prefix <str> | Output filename prefix |
| -s, --suffix <str> | Output filename suffix |
| --fit <mode> | Resize fit mode |
| --position <pos> | Watermark position |
| --keep | Keep originals (don't overwrite) |
Programmatic Usage
const { resize, convert, optimize, thumbnail } = require('@lxgicstudios/imgbatch');
// Resize
await resize('photo.jpg', 'photo-small.jpg', { width: 800, height: 600 });
// Convert to WebP
await convert('photo.jpg', 'photo.webp', { quality: 85 });
// Optimize
await optimize('photo.jpg', 'photo.jpg', { quality: 80 });
// Thumbnail
await thumbnail('photo.jpg', 'photo-thumb.jpg', { size: 200 });Examples
Prepare images for web
# Convert all PNGs to WebP
imgbatch convert "images/*.png" webp -q 85 -o web/
# Create responsive sizes
imgbatch resize "images/*.jpg" 1920x1080 -o large/
imgbatch resize "images/*.jpg" 800x600 -o medium/
imgbatch resize "images/*.jpg" 400x300 -o small/Product photos workflow
# Optimize originals
imgbatch optimize "products/*.jpg"
# Generate thumbnails
imgbatch thumbnail "products/*.jpg" 200 -o thumbs/
# Add watermark for sharing
imgbatch watermark "products/*.jpg" logo.png -o protected/Why imgbatch?
- Fast - Powered by sharp (libvips)
- Simple - Intuitive CLI commands
- Flexible - Works with glob patterns
- Modern formats - WebP, AVIF support
Built by LXGIC Studios
