From efcb1a40d386bf88fe9ba581e804a5d8b129f020 Mon Sep 17 00:00:00 2001 From: "Dita Aji Pratama (Home Server)" Date: Sat, 2 Nov 2024 11:58:45 +0700 Subject: [PATCH] Image file size pressure --- shell/pressure.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 shell/pressure.sh diff --git a/shell/pressure.sh b/shell/pressure.sh new file mode 100644 index 0000000..0eeb142 --- /dev/null +++ b/shell/pressure.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Check if both directory and quality are provided +if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Set the directory and quality from arguments +directory="$1" +quality="$2" + +# Loop through each image in the directory and reduce quality +for file in "$directory"/*.{jpg,jpeg,png}; do + if [ -f "$file" ]; then + convert "$file" -quality "$quality" "$file" + echo "Compressed $file to $quality% quality." + fi +done + +echo "Compression completed for all images in $directory with $quality% quality."