GoAdmio

installwebp

Install the WebP command-line tools (cwebp, dwebp, and others) from the package manager, with a fallback to the official libwebp 1.2.2 binary release

On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also


Overview

/go/installwebp makes the WebP tools available on the server so GoAdmio can convert images to WebP with webp. It:

The tools it installs include cwebp (convert to WebP) and dwebp (convert from WebP). Depending on the source, you also get gif2webp, img2webp, webpinfo, and webpmux.

[!NOTE] This command installs the tools only. To convert the images in a site, use webp.


Quick start

# Install the WebP tools
/go/installwebp

Then check the result:

cwebp -version

Syntax

/go/installwebp

Run it as root. Most steps use sudo, but the Ubuntu install and the final rsync run without it.


Options

None. Any arguments you pass are written to the log file and otherwise ignored.


Output

The command prints Installing WEBP..., followed by the output of the package manager. Downloads run quietly, with one attempt and a 20-second timeout. There is no success message, and the command doesn't stop on errors: every step runs even if an earlier one failed. The exit status is that of the last command.

Every run adds a line to /var/log/go/installwebp.log:

[Nov 20 14:03:11]# installwebp

Security

[!WARNING] The fallback downloads are made with --no-check-certificate, so the server's TLS certificate isn't verified, and the file isn't checked against a hash. The fallback version, libwebp 1.2.2, is also older than 1.3.2, the release that fixed the widely reported libwebp heap overflow (CVE-2023-4863). Prefer the package from your distribution, which receives security updates, and update the fallback version if you rely on it. See Changing the version.


Examples

# Run the installer
/go/installwebp
# Check the installed version
cwebp -version
# Show which cwebp is used (and whether there is more than one)
which -a cwebp
# Convert an image to WebP
cwebp -q 80 photo.jpg -o photo.webp
# Convert a WebP image back to PNG
dwebp photo.webp -o photo.png
# Review past runs
tail /var/log/go/installwebp.log

Troubleshooting

Symptom Likely cause Fix
cwebp: command not found after the command The package install and both fallback downloads failed. Check the server's internet access and DNS, then run the command again.
dnf can't find libwebp-tools On some RHEL-family releases the package isn't in the default repositories. Nothing. The fallback downloads the official binaries. You can also enable the repository that provides it.
An empty libwebp-1.2.2-linux-x86-64.tar.gz and a .tar.gz.1 file in /usr/local/goadmio/tmp The mirror fallback saved the download under a different name. See Limitations. Delete both files, fix the network, and run the command again.
break: only meaningful in a 'for', 'while', or 'until' loop The script uses break outside a loop. Nothing. The message is harmless.
cwebp: cannot execute binary file: Exec format error The fallback binaries are x86-64 and the server isn't (for example, ARM). Remove /usr/bin/cwebp and install the package from your distribution.
cwebp -version shows an unexpected version A package version already exists, and the fallback never overwrites existing files. Run which -a cwebp and check which copy comes first.
Permission denied during apt on Ubuntu The Ubuntu install step runs without sudo. Run the command as root.
Nothing is installed, but the fallback runs The value in /usr/local/goadmio/linux/os.db isn't an exact match for a supported system. Check the file. It must contain exactly one of the names in Supported systems.

Details

Supported systems

The command reads the operating system name from /usr/local/goadmio/linux/os.db and requires an exact match for the package step.

Family Names matched Package manager Package
RHEL family AlmaLinux, Rocky, CentOS, Red Hat, Fedora dnf libwebp-tools
Debian Debian apt webp
Ubuntu Ubuntu apt (non-interactive) webp

The fallback doesn't depend on the operating system, so on any other value only the fallback runs. The command also reads /usr/local/goadmio/linux/version.db, but the value isn't used.

What it does

Step Action
1 Writes the command and a timestamp to /var/log/go/installwebp.log.
2 Installs the WebP tools with the package manager.
3 If /usr/bin/cwebp exists, stops here.
4 Otherwise changes to /usr/local/goadmio/tmp and downloads libwebp-1.2.2-linux-x86-64.tar.gz from storage.googleapis.com.
5 If that file is still missing, tries the mirror at script.goadmio.com.
6 Unpacks the archive in /usr/local/goadmio/tmp and deletes the archive.
7 Copies the programs from the archive's bin/ folder to /usr/bin/ with rsync, without overwriting any existing file.
flowchart TD
    A["installwebp"] --> B["Log the run"]
    B --> C{"OS in os.db"}
    C -- "RHEL family" --> D["dnf install libwebp-tools"]
    C -- "Debian or Ubuntu" --> E["apt install webp"]
    C -- "Other" --> F["Skip package step"]
    D --> G{"/usr/bin/cwebp exists?"}
    E --> G
    F --> G
    G -- "Yes" --> Z["Done"]
    G -- "No" --> H["Download libwebp 1.2.2 from Google"]
    H --> I{"Archive downloaded?"}
    I -- "No" --> J["Try the GoAdmio mirror"]
    I -- "Yes" --> K["Unpack to /usr/local/goadmio/tmp"]
    J --> K
    K --> L["Copy bin/* to /usr/bin without overwriting"]
    L --> Z

Changing the version

The fallback version is written into the script. To use another release, change 1.2.2 in every place it appears: both download URLs, the test -f check, the tar and rm lines, and the rsync source folder. Upload the new archive to the mirror too, or the mirror fallback won't find it. The release list is at https://storage.googleapis.com/downloads.webmproject.org/releases/webp/index.html.

Limitations

The fallback copies programs only

Only the files in the archive's bin/ folder go to /usr/bin. The libraries, headers, and docs stay in /usr/local/goadmio/tmp/libwebp-1.2.2-linux-x86-64, and the folder is never deleted. Programs that need the WebP library, such as PHP's image functions, are not affected by this command.

x86-64 only

The fallback archive is built for x86-64 Linux. It doesn't work on ARM servers.

The mirror download is likely broken

The mirror line redirects wget's output to the archive's path with >. The shell creates that empty file first, so wget most likely saves the real download as libwebp-1.2.2-linux-x86-64.tar.gz.1 instead, and the following tar step fails on the empty file. The mirror only helps if wget is told where to write (-O).

Stray break commands

Both wget lines end in && break, but the script has no loop, so break does nothing and bash may print a message. The script continues to the next step either way.

Folder and tool checks

The command doesn't check that cd /usr/local/goadmio/tmp worked, and it doesn't install wget or rsync.


See also

Command Description
webp Convert images to WebP format
img Shrink large images (over 512 KB) in place so they fit within 800×600 pixels
package Install all base packages required by GoAdmio
extension List, install, or remove a PHP extension across every installed PHP version
installphp Install a PHP version with its extensions and PHP-FPM service