Guide · Developers

Convert PNG to WebP

Convert a PNG asset to WebP locally while keeping the source intact and making quality explicit.

WebP is often a useful delivery format for a PNG asset, but the right choice depends on whether the image needs lossless pixels or transparency. Inspect the result rather than assuming that a smaller file is always better.

Convert one file

Terminal window
rastry logo.png --to webp --quality 82 --dry-run

The shorthand creates a conversion followed by metadata removal. Review the derived output path, then execute:

Terminal window
rastry logo.png --to webp --quality 82 --execute

The PNG remains untouched and the generated file uses a -rastry.webp suffix when no output directory is provided.

Convert a folder

Use the web preset when the folder also needs a dimension limit:

Terminal window
rastry run ./public --preset web --output ./optimized --dry-run

For logos and illustrations, confirm that transparency and fine edges still look correct. Read PNG, WebP, and the safety model before automating the workflow.

More from Rastry

Open the related documentation