Wrapper around webp cli tools to allow easier batch processing.
- cwebp
- gif2webp
For easier development a json schema is used as base for validation and paramter passing.
To use the tools with a binary you will also need to install the webp cli tools yourself.
Just make sure they are placed inside your PATH or add them accordingly.
More information about installation can be found on developers.google.com.
If you already have go setup you can simply run a go get
:
go get -u github.com/timo-reymann/webp-utils
Navigate to the latest release and download the binary for your platform.
If you want to use docker:
e. g. for cwebp
docker run --user $(id -u):$(id -g) -v $PWD:/workspace --rm -it timoreymann/webp-utils \
cwebp --config /etc/webp-utils/default.json --file-glob '*.png'
- OPTIONAL: Setup schema for your IDE, for available schemas look into pkg/schema
- Create a file named
config.json
, containing all parameters for the command you want to execute, you can also create a file named differently and use the--config
-Flag - Run the command and specify a file glob for the files to be processed, like this:
webp-utils cwebp --file-glob '*.png'
Each json key value pair represents an argument and its value, that can be templated using go templates. You can also use the template functions from sprig as documented here.
You can use any other key or the following builtins:
Name | Content |
---|---|
source_file | Source file path with extension |
source_file_name | Source file name without extension |
You can find all schemas inside pkg/schema, you can also set up your ide/editor to give you autocomplete based on the json schema.
Feel free to browse around at examples