4. Smush API Docs
WPMU DEV is dedicated to supporting advanced users in every possible way. Our Smush API Documentation is an ongoing project. Information about new commands will be added here as it becomes available.
4.1 WP-CLICopy chapter anchor to clipboard
WP-CLI is the command-line interface for WordPress. You can update plugins, configure multisite installations and much more, without using a web browser. Smush has an integration module with WP CLI, which will allow you to simplify a few common tasks.
Allows optimizing single images, batch optimization, as well as bulk optimization of the whole media library.
wp smush compress [–type=] [–image=]
Smush all images.
wp smush compress
Smush single image with ID = 10.
wp smush compress --type=single --image=10
Smush first 5 images.
wp smush compress --type=batch --image=5
Note that the wp smush compress command will respect all current settings in the Smush plugin on the site where the command is run. In other words, if the Super-Smush option is enabled on the site, running this command will super-smush the images.
List unoptimized images
wp smush list 
Get all unoptimized images.
wp smush list
Get the first 100 images that are not optimized.
wp smush list 100
Allows restoring images that have backups (backups need to be enabled via the “Store a copy of my full size images” option in Smush).
wp smush restore [–id=]
Restore all images that have backups.
wp smush restore
Restore single image with ID = 10.
wp smush restore --id=10
Restore all images on a site with slug blog on a WordPress multisite instance using subdomains.
wp smush restore --url=blog.example.com