Documentação

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 convert

Options

FlagDescriptionDefault
--allEnqueue all images, including already-optimized ones (useful after switching presets)false
--format=<format>Output format: both, webp, or avifboth
--dry-runShow how many images would be enqueued without actually doing itfalse

--format values

ValueBehaviorQuota
bothGenerate WebP and AVIF siblings (default)Deducted
webpGenerate WebP only — skip AVIFDeducted
avifGenerate AVIF only — skip WebPFree

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-run

Output

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 status

Example 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-avif

Options

FlagDescription
--dry-runShow 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-avif

Output

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 --stats

Options

FlagDescription
--queueRemove all pending and failed jobs from the queue
--statsInvalidate 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