npm package: @lxgicstudios/imgbatch
Description: Batch image processing. Resize, convert, optimize, watermark, and rename images. CLI tool for bulk operations.
Author: LXGIC Studios
Latest version: 1.0.0

# imgbatch

Batch image processing. Resize, convert, optimize, watermark, and rename images. CLI tool for bulk operations.

## Installation

```bash
npm install -g @lxgicstudios/imgbatch
```

Or use directly:

```bash
npx @lxgicstudios/imgbatch resize "images/*.jpg" 800x600
```

## Commands

### Resize images

```bash
imgbatch resize "photos/*.jpg" 1920x1080
imgbatch resize "uploads/*.png" 800x600 --fit contain
```

**Fit options:** cover (default), contain, fill, inside, outside

### Convert format

```bash
imgbatch convert "images/*.png" webp
imgbatch convert "photos/*.jpg" avif -q 85
```

**Formats:** jpg, png, webp, avif, gif, tiff

### Optimize file size

```bash
imgbatch optimize "uploads/*.jpg"
imgbatch optimize "gallery/**/*.png" -q 75
```

### Generate thumbnails

```bash
imgbatch thumbnail "products/*.jpg" 200
imgbatch thumbnail "gallery/*.png" 150 -o thumbs/
```

### Add watermark

```bash
imgbatch watermark "photos/*.jpg" logo.png
imgbatch watermark "*.jpg" watermark.png --position southeast
```

**Positions:** center, north, south, east, west, northeast, northwest, southeast, southwest

### Other commands

```bash
imgbatch rotate "scans/*.jpg" 90
imgbatch grayscale "photos/*.jpg"
imgbatch blur "backgrounds/*.png" 10
imgbatch info photo.jpg
```

## Options

| 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

```javascript
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

```bash
# 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

```bash
# 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](https://lxgicstudios.com)**

🔗 [GitHub](https://github.com/lxgicstudios/imgbatch) · [Twitter](https://x.com/lxgicstudios)