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

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axil@gitlab.com>2019-06-24 12:16:43 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2019-06-24 12:25:20 +0300
commit69690954a4ba52af68ee7a40b61a75746160d466 (patch)
tree5d347320bfe8b655e740f67d34b12254fc3c3e52 /scripts
parent4f41ac3febf2dd47852842604787339a0bfd1d31 (diff)
Compress PNG images during build
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/compress_images.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/compress_images.sh b/scripts/compress_images.sh
new file mode 100755
index 00000000..87993268
--- /dev/null
+++ b/scripts/compress_images.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+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
+for image in $(find ${TARGET}/${VER}/ -name "*.png")
+ do $PNG $image
+ echo "Compressing $image"
+done