CompressX Documentation

Everything you need to install, configure, and get the best performance from CompressX Free and Pro.

CompressX Docs
Document Notice

Help Improve the Documentation

If you notice something unclear, outdated, or incorrect, feel free to let us know.

Your feedback helps keep the documentation accurate and useful for everyone.

WPCLI Image Optimization

Jan 1, 2026 | Docs

CompressX Pro supports WP-CLI to streamline and automate your image optimization workflows. Through terminal-based commands, you can scan, convert, or delete optimized assets without using the WordPress dashboard, making it an essential tool for developers and server administrators managing high-volume media libraries.

Prerequisites

Before running any optimization commands, ensure your environment meets the following requirements:

  • 1. WP-CLI Installed
    Your server should have the WordPress Command Line Interface (WP-CLI) installed and properly configured to interact with your WordPress installation.
  • 2. SSH Access
    Or you should have valid SSH credentials and be able to connect to your server environment via a terminal application (e.g., Terminal, PuTTY, or iTerm2).
  • 3. Active License
    WP-CLI support is a premium feature exclusive to CompressX Pro. Before executing commands, ensure that your Pro license is active and the plugin is validated on the site.

How to Use CompressX via WP-CLI

Follow these steps to manage and automate your image optimization directly from the command line.

1. Connect and Navigate to Your Site

Log in to your website server via SSH and navigate to your WordPress root directory (where wp-config.php is located):

cd /var/www/html/yourdomain.com/public_html

2. Scan for Unconverted Images

Use the scan command below to analyze your Media Library to identify original images that do not yet have corresponding WebP or AVIF versions. This is a recommended first step to understand the scope of work:

wp compressx scan

3. Convert Images to WebP/AVIF

Trigger the optimization process for all images in your WordPress media library or target a specific file.

  • Bulk Conversion
    Processes all eligible images in the WordPress Media Library based on your optimization settings:
wp compressx convert
  • Single Image Conversion
    Optimizes a specific asset by targeting its unique attachment ID:
wp compressx convert --type single --image=ID
Tip
To find an Image ID, you can go to your WordPress Media Library (List View), hover over the image title. The ID is the number found after post= in the URL displayed at the bottom of your browser (e.g., …post=123… means the ID is 123).

4. Delete Converted Images

Use the delete command below to remove generated WebP/AVIF images if you need to free up disk space or reset your optimization status:

  • Bulk Delete
    To delete all WebP and AVIF images and database records generated by CompressX from your server:
wp compressx delete
  • Single Delete
    To delete converted WebP and AVIF images and database records for a specific image:
wp compressx delete --type single --image=ID
Note
The delete command only removes the generated WebP and AVIF files. Your original JPG or PNG source files remain untouched.