Sign inSign up

jysgro/webp

By jysgro

Updated over 2 years ago

cwebp and dwebp command to code and decode web images in PNG or JPG

Image
0

218

jysgro/webp repository overview

Recreated from information at https://hub.docker.com/r/elswork/cwebp/

Usage

Gleaned from original elswork and GitHub repository elswork/cwebp which contains a "data" directory with a few images for testing.

cwebp and dwebp

A Docker⁠ file to call cwebp⁠ and dwebp, and other functions⁠ from libwebp library.

You should read carefully the usage documentation of every tool!

Details from elswork

Docker PullsDocker StarsSize/Layers

Usage Example

More options detailed on original. Below are the docker commands that seem most useful.

NOTE: To share the current directory use -v ${PWD}:/data which is generic syntax that works for Mac/Windows/Linux

To use my version change elswork/cwebp to jysgro/webp:alpine3.20_cwebp_dwebp in docker commands below.

Open ash in container
docker run -it --rm -v /path-to-folder:/data --entrypoint "/bin/ash" elswork/cwebp 
Start a custom command in container
docker run -it --rm -v /path-to-folder:/data elswork/cwebp cwebp -lossless deftwork.png -o deftwork.webp
Start a container command
docker run -it --rm -v /path-to-folder:/data elswork/cwebp cwebp -lossless deftwork.png -o deftwork.webp
Convert all .png from folder and subfolders recursively
docker run -it --rm -v /path-to-folder:/data elswork/cwebp \
find ./ -type f -name '*.png' -exec sh -c 'cwebp -lossless $1 -o "${1%.png}.webp"' _ {} \;
Convert all .png concurrently

This is faster than previous operation because it raise concurrent threads.

docker run -it --rm -v /path-to-folder:/data elswork/cwebp \
find ./ -type f -name '*.png' | xargs -P 8 -I {} sh -c 'cwebp -lossless $1 -o "${1%.png}.webp"' _ {} \;

Dockerfile

Docker file from https://hub.docker.com/r/elswork/cwebp/Dockerfile

Used "as is" but since the :latest option makes Alpine as version 3.20.0 rather than 3.12 in the original.

ARG BASEIMAGE=alpine:latest
FROM ${BASEIMAGE}

ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL mantainer="Eloy Lopez <[email protected]>" \
    org.label-schema.build-date=$BUILD_DATE \
    org.label-schema.name="cwebp" \
    org.label-schema.description="libwebp codec distribution a reference implementation for the encoder and decoder applications" \
    org.label-schema.url="https://deft.work/cwebp" \
    org.label-schema.vcs-ref=$VCS_REF \
    org.label-schema.vcs-url="https://github.com/Eloy Lopez/cwebp" \
    org.label-schema.vendor="Deft Work" \
    org.label-schema.version=$VERSION \
    org.label-schema.schema-version="1.0"

RUN apk update && \
    apk upgrade -U && \
    apk add ca-certificates libwebp libwebp-tools && \
    rm -rf /var/cache/*
WORKDIR /data
# ENTRYPOINT ["/bin/ash"]

Built for amd64 as well as arm64 with:

docker buildx  build -t jysgro/webp:alpine3.20_cwebp_dwebp --push  --platform linux/amd64,linux/arm64 .

Tag summary

Content type

Image

Digest

sha256:f096fc475

Size

7.1 MB

Last updated

over 2 years ago

docker pull jysgro/webp:alpine3.20_cwebp_dwebp