WP-CLI Commands
Automate GetWebP batch conversion, AVIF backfill, and queue management from the command line using WP-CLI.
WP-CLI Commands
GetWebP registers a wp getwebp command group for automating conversion, checking status, and managing the background queue from the command line.
Table of Contents#
Requirements#
- WP-CLI 2.0 or later
- GetWebP plugin installed and activated
- PHP 7.4+ in the CLI environment
Command Reference#
wp getwebp convert#
Enqueue all unconverted images into the background optimization queue.
wp getwebp convertOptions
| Flag | Description | Default |
|---|---|---|
--all | Enqueue all images, including already-optimized ones (useful after switching presets) | false |
--format=<format> | Output format: both, webp, or avif | both |
--dry-run | Show how many images would be enqueued without actually doing it | false |
--format values
| Value | Behavior | Quota |
|---|---|---|
both | Generate WebP and AVIF siblings (default) | Deducted |
webp | Generate WebP only — skip AVIF | Deducted |
avif | Generate AVIF only — skip WebP | Free |
Examples
# Enqueue all unconverted images (WebP + AVIF)
wp getwebp convert
# Re-enqueue everything after changing preset
wp getwebp convert --all
# WebP only (faster, skip AVIF generation)
wp getwebp convert --format=webp
# AVIF only — useful if you already ran WebP conversion and want to add AVIF
wp getwebp convert --format=avif
# Preview what would be enqueued (no files written)
wp getwebp convert --dry-run
wp getwebp convert --format=webp --dry-runOutput
The command enqueues images into the background queue and returns immediately:
Success: Enqueued 843 image(s) in batch a1b2c3d4. Queue processing has started.
The queue is processed in the background by WP-Cron (or a real cron job if configured). Use wp getwebp status to monitor progress.
wp getwebp status#
Show the current optimization statistics and queue state.
wp getwebp statusExample output
=== GetWebP Status ===
CLI binary: /usr/local/bin/getwebp (v1.3.0)
License: pro
--- Library ---
Total images: 5,120
Optimized: 5,086 (99.3%)
Unoptimized: 34
Bytes saved: 412.50 MB
--- Queue ---
Pending: 34
Processing: 0
Failed: 2
wp getwebp backfill-avif#
Generate AVIF siblings for images that already have WebP but are missing AVIF. Free for all users — AVIF backfill never deducts quota.
wp getwebp backfill-avifOptions
| Flag | Description |
|---|---|
--dry-run | Show how many images need AVIF generation without queuing them |
Examples
# Check how many images need AVIF
wp getwebp backfill-avif --dry-run
# Queue AVIF generation for all eligible images
wp getwebp backfill-avifOutput
Success: Enqueued 312 image(s) for AVIF backfill in batch e5f6g7h8. Queue processing has started.
wp getwebp reset#
Clear pending/failed queue jobs and/or invalidate the stats cache.
wp getwebp reset --queue
wp getwebp reset --stats
wp getwebp reset --queue --statsOptions
| Flag | Description |
|---|---|
--queue | Remove all pending and failed jobs from the queue |
--stats | Invalidate the stats cache so it is recalculated on next request |
At least one flag is required.
Examples
# Clear stuck or failed queue jobs
wp getwebp reset --queue
# Force stats to recalculate
wp getwebp reset --stats
# Full reset
wp getwebp reset --queue --stats