What WP-CLI commands does SlashImage have?
4 min read · Last updated August 2026
SlashImage adds five WP-CLI commands: wp slashimage status, wp slashimage optimize, wp slashimage restore, wp slashimage cancel, and wp slashimage migrate. Run them from your site's shell after connecting over SSH.
wp slashimage status
wp slashimage status [--format=<table|json|csv|yaml>]Prints a read-only snapshot and changes nothing. It reports four things: your connection (whether an API key is present and whether it is valid), the queue (how many images are waiting, in progress, done, and failed), the active run (whether an optimize or restore run is going, and how much is left), and your library counts (how many images are optimized, not optimized, excluded, or errored). The default table format is for reading; --format=json, csv, or yaml are there for scripting.
wp slashimage optimize
wp slashimage optimize [<id>...] [--all] [--force]Optimizes images in the foreground with a live progress bar. Pass one or more attachment IDs, or --all for the whole library - not both. Requires an API key. Because it runs in a single process, it is not bound by the request timeout that limits the browser bulk run.
If an optimize run is already going, the command refuses to start rather than clobber it. Clear a stuck run with wp slashimage cancel, then try again.
# Optimize two attachments
wp slashimage optimize 217 218
# Optimize the whole library
wp slashimage optimize --allwp slashimage restore
wp slashimage restore [<id>...] [--all] [--yes]Restores images from their backups. Pass attachment IDs, or --all to restore everything that has a backup. Add --yes to skip the confirmation prompt on --all. No API key is needed, because restore is local. Any image without a backup is skipped with a warning and the run continues.
Restore refuses to run while an optimize run is active. If you see An optimization run is in progress, pause or cancel it on the Bulk Optimize page (or with wp slashimage cancel), then run restore again.
wp slashimage cancel
wp slashimage cancelCancels the active optimize or restore run, drops the images still waiting in the queue, and returns to idle. It is non-destructive: it does not touch your files, your backups, work that already finished, or an image that is mid-process. If nothing is running, it says so and exits cleanly.
wp slashimage migrate
wp slashimage migrate <shortpixel|imagify> [--dry-run] [--batch-size=<n>]Imports another optimizer's data so its work counts as SlashImage's. Requires SlashImage 1.2.0 or later - the four commands above work from 1.1.0. The source is required: pass shortpixel or imagify. Needs no API key, because it makes no API calls.
--dry-run scans and reports what would be imported, writing nothing. --batch-size=<n> sets how many attachments are examined per batch, default 200. Unlike the Tools tab, the command works even if the other plugin has already been removed, because it reads the data left behind rather than the active plugin list.
The other plugin is only read: its tables, settings, files, and backups are never written, moved, or deleted. Re-running is safe - attachments already migrated, or already optimized by SlashImage, are skipped.
# See what would be imported, changing nothing
wp slashimage migrate imagify --dry-run
# Run the import
wp slashimage migrate imagifyA source with no data to import is a clean success, not an error. Migration is refused on multisite: Migration is not available on multisite networks yet, because optimization data is stored separately for each site.
For the browser version of this and its caveats, see How do I switch from ShortPixel or Imagify?.
Notes
- Exit codes.
0means success, or that the only remaining work was deferred for a later retry.1means the run had failures, or you passed no API key, an invalid key, or bad arguments. Failure counts are scoped to that run, not the whole queue. - Multisite. Target a specific site with WP-CLI's own
--url=<site-url>flag. Without it, commands run against the main site. - Per-command help. Run
wp help slashimage <command>for the full options of any command. - Language. Command output is English only, following WP-CLI's convention.