projects
/
anondcim.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
71f4133
)
add option for jpeg quality
master
author
Felix Kästner
<git-ncbhw@fpunktk.de>
Thu, 11 Nov 2021 20:35:48 +0000
(21:35 +0100)
committer
Felix Kästner
<git-ncbhw@fpunktk.de>
Thu, 11 Nov 2021 20:35:48 +0000
(21:35 +0100)
anondcim
patch
|
blob
|
history
diff --git
a/anondcim
b/anondcim
index 8fbbccebd49548dac455f810cf6c1745e6da51b5..3396810999a59e6fd921d3f0c00d2b5948106512 100755
(executable)
--- a/
anondcim
+++ b/
anondcim
@@
-33,8
+33,6
@@
rand() {
echo $(( $1$(tr -dc "0-9" < /dev/urandom | head -c $((${#1} + 2))) % $1 ))
}
echo $(( $1$(tr -dc "0-9" < /dev/urandom | head -c $((${#1} + 2))) % $1 ))
}
-[ $# -gt 0 ] || die "Usage: $0 [-p image_prefix] [-s destination_size (absolute or percentage)] [-d destination_directory] imagefile(s)"
-
type convert >/dev/null 2>&1 || die "ImageMagick (convert, identify) is not installed"
type jhead 1>/dev/null 2>&1 || type exiftool 1>/dev/null 2>&1 || die "jhead or exiftool has to be installed"
type convert >/dev/null 2>&1 || die "ImageMagick (convert, identify) is not installed"
type jhead 1>/dev/null 2>&1 || type exiftool 1>/dev/null 2>&1 || die "jhead or exiftool has to be installed"
@@
-42,8
+40,11
@@
type jhead 1>/dev/null 2>&1 || type exiftool 1>/dev/null 2>&1 || die "jhead or e
file_prefix=""
dst_size="1920"
dst_dir="--same--"
file_prefix=""
dst_size="1920"
dst_dir="--same--"
+jpg_quality="75"
+
+[ $# -gt 0 ] || die "Usage: $0 [-p image_file_prefix] [-s destination_size (absolute or percentage, default: $dst_size)] [-d destination_directory] [-q destination_jpg_quality (default: $jpg_quality)] imagefile(s)"
-while getopts ':p:s:d:' OPTION
+while getopts ':p:s:d:
q:
' OPTION
do
case $OPTION in
"p")
do
case $OPTION in
"p")
@@
-56,6
+57,9
@@
do
dst_dir="${OPTARG%/}/" # enforce a trailing "/"
[ -d "$dst_dir" ] || die "destination directory \"$dst_dir\" does not exist"
;;
dst_dir="${OPTARG%/}/" # enforce a trailing "/"
[ -d "$dst_dir" ] || die "destination directory \"$dst_dir\" does not exist"
;;
+ "q")
+ jpg_quality="$OPTARG"
+ ;;
*)
err "not recognised: OPTION=$OPTION, OPTARG=$OPTARG"
;;
*)
err "not recognised: OPTION=$OPTION, OPTARG=$OPTARG"
;;
@@
-110,6
+114,7
@@
EOF
-attenuate 2 +noise Uniform \
-resize "$dst_size" \
-colorspace sRGB \
-attenuate 2 +noise Uniform \
-resize "$dst_size" \
-colorspace sRGB \
+ -quality "$jpg_quality" \
"$dst_jpg"
else
err "image is too small to be distorted and will just be filtered and resized"
"$dst_jpg"
else
err "image is too small to be distorted and will just be filtered and resized"
@@
-119,6
+124,7
@@
EOF
-attenuate 2 +noise Uniform \
-resize "$dst_size" \
-colorspace sRGB \
-attenuate 2 +noise Uniform \
-resize "$dst_size" \
-colorspace sRGB \
+ -quality "$jpg_quality" \
"$dst_jpg"
fi
#
"$dst_jpg"
fi
#