Skip to content

Commit

Permalink
Merge pull request #36015 from nextcloud/techdebt/36014/fix-image-opt…
Browse files Browse the repository at this point in the history
…imization

fix(CI): Check for the image-optimization binaries we want to use
  • Loading branch information
nickvergessen authored Jan 5, 2023
2 parents 2171e37 + e035c65 commit adef2b8
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions build/image-optimization.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
#!/usr/bin/env bash

set -e

OPTIPNG=$(which optipng)
if ! [ -x "$OPTIPNG" ]; then
echo "optipng executable not found, please install" >&2
exit 1
fi
JPEGOPTIM=$(which jpegoptim)
if ! [ -x "$JPEGOPTIM" ]; then
echo "jpegoptim executable not found, please install" >&2
exit 2
fi
SCOUR=$(which scour)
if ! [ -x "$SCOUR" ]; then
echo "scour executable not found, please install" >&2
exit 3
fi

set +e

CHECK_DIR='../'
if [[ -d "$1" ]]; then
CHECK_DIR=$1
Expand All @@ -20,15 +40,15 @@ function recursive_optimize_images() {
do
[[ -e "$png" ]] || break

optipng -o6 -strip all "$png"
$OPTIPNG -o6 -strip all "$png"
done

# Optimize all JPGs
for jpg in *.jpg
do
[[ -e "$jpg" ]] || break

jpegoptim --strip-all "$jpg"
$JPEGOPTIM --strip-all "$jpg"
done

# Optimize all SVGs
Expand All @@ -37,7 +57,7 @@ function recursive_optimize_images() {
[[ -e "$svg" ]] || break

mv $svg $svg.opttmp
scour --create-groups \
$SCOUR --create-groups \
--enable-id-stripping \
--enable-comment-stripping \
--shorten-ids \
Expand Down

0 comments on commit adef2b8

Please sign in to comment.