Skip to content

Instantly share code, notes, and snippets.

@tabrindle
Last active April 16, 2025 15:25

Revisions

  1. tabrindle revised this gist Mar 9, 2016. 1 changed file with 4 additions and 7 deletions.
    11 changes: 4 additions & 7 deletions webp-convert-directory.sh
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,15 @@
    #!/bin/bash

    quality=75;
    PARAMS=('-m 6 -q 70 -mt -af -progress')

    if [ $# -ne 0 ]; then
    quality="$1";
    if ![[ "$quality" =~ "^[0-9]+$" ]]; then
    echo "Error: Quality parameter not a number" >&2; exit 1
    fi
    PARAMS=$@;
    fi

    cd $(pwd)

    shopt -s nullglob nocaseglob extglob

    for FILE in *.@(jpg|jpeg|tif|tiff|bmp|png); do
    cwebp -af -q "$quality" "$FILE" -o "${FILE%.*}".webp;
    for FILE in *.@(jpg|jpeg|tif|tiff|png); do
    cwebp $PARAMS "$FILE" -o "${FILE%.*}".webp;
    done
  2. tabrindle created this gist Mar 9, 2016.
    18 changes: 18 additions & 0 deletions webp-convert-directory.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/bin/bash

    quality=75;

    if [ $# -ne 0 ]; then
    quality="$1";
    if ![[ "$quality" =~ "^[0-9]+$" ]]; then
    echo "Error: Quality parameter not a number" >&2; exit 1
    fi
    fi

    cd $(pwd)

    shopt -s nullglob nocaseglob extglob

    for FILE in *.@(jpg|jpeg|tif|tiff|bmp|png); do
    cwebp -af -q "$quality" "$FILE" -o "${FILE%.*}".webp;
    done