zah: add pjotoprep
This commit is contained in:
parent
8911716cc3
commit
ad9ca238b6
|
@ -0,0 +1,32 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
# prepare photos for sharing them online
|
||||||
|
|
||||||
|
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
||||||
|
|
||||||
|
zmodload zsh/zutil
|
||||||
|
local -a o_quality=(-q 90)
|
||||||
|
local -a o_size=(-s 1500x1500)
|
||||||
|
local -a o_format=(-s webp)
|
||||||
|
local -a o_help=()
|
||||||
|
zparseopts -D -K -- q:=o_quality s:=o_size f:=o_format h=o_help
|
||||||
|
if [[ ${#o_help} -ne 0 || ! -v 1 ]]; then
|
||||||
|
local ret=$(( ${#o_help} ^ 1 ))
|
||||||
|
print -u $(( 1 + ${ret} )) "usage: ${0} [-h]" \
|
||||||
|
"[-q QUALITY (=${o_quality[2]})]" \
|
||||||
|
"[-s SIZE (=${o_size[2]})]" \
|
||||||
|
"[-f FORMAT (=${o_format[2]})]" \
|
||||||
|
"<FILE> …"
|
||||||
|
return ${ret}
|
||||||
|
fi
|
||||||
|
local quality=${o_quality[2]}
|
||||||
|
local size=${o_size[2]}
|
||||||
|
local format=${o_format[2]}
|
||||||
|
|
||||||
|
mkdir -p photoprep
|
||||||
|
for file in ${@}; do
|
||||||
|
newfile=photoprep/${file##*/}
|
||||||
|
newfile=${newfile%.*}.${format}
|
||||||
|
magick -quality ${quality} ${file} -strip -resize ${size} ${newfile}
|
||||||
|
print -n '.'
|
||||||
|
done
|
||||||
|
print
|
Loading…
Reference in New Issue