Welcome to mirror list, hosted at ThFree Co, Russian Federation.

compress_images.sh « scripts - gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dd839d79fdb77e1f7f6aca0d5899f44167928536 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash

TARGET="$1"
VER="$2"
PNGQUANT=$(which pngquant)
PNG="$PNGQUANT -f --skip-if-larger --ext .png --speed 1"

if [ -z "$TARGET" ]; then
  echo "Usage: $0 <target> <version>"
  echo "No target provided. Exiting."
  exit 1
fi

if [ -z "$VER" ]; then
  echo "Usage: $0 <target> <version>"
  echo "No version provided. Exiting."
  exit 1
fi

if ! [ -d "$TARGET/$VER" ]; then
  echo "Target directory $TARGET/$VER does not exist. Exiting."
  exit 1
fi

# Compress images
# shellcheck disable=SC2044
for image in $(find "${TARGET}/${VER}/" -name "*.png")
  do echo "Compressing $image"
  $PNG "$image"
done