-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgallery-dl_postprocessing_selector.sh
More file actions
executable file
·24 lines (23 loc) · 1.18 KB
/
gallery-dl_postprocessing_selector.sh
File metadata and controls
executable file
·24 lines (23 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
IFS=$'\n'
inputfile="${*:3}"
if [[ "$1" = png ]]; then
webpifier.sh "${inputfile}" >/dev/null
elif [[ "$1" = jpg ]] || [[ "$1" = jpeg ]]; then
if [[ "$2" = kemono ]]; then
# shellcheck disable=SC2312
identify -format "%G %i\n" "${inputfile}" 2>/dev/null | grep -Po '1200x630 \K.*' | while IFS= read -r file; do rm -f -- "${file}"; done
else
jpegoptim -p --strip-com --strip-iptc --strip-icc --strip-xmp "${inputfile}" >/dev/null
fi
elif [[ "$1" = zip ]] || [[ "$1" = rar ]] || [[ "$1" = 7z ]]; then
LC_CTYPE=ja_JP.UTF-8 7z x "${inputfile}" -o"${inputfile%.*}" || exit 1
rm "${inputfile}"
find "${inputfile%.*}" -iname "*.png" -exec webpifier.sh {} \;
find "${inputfile%.*}" -iname "*.jpg" -exec jpegoptim -p --strip-com --strip-iptc --strip-icc --strip-xmp {} +
find "${inputfile%.*}" -type d \( -name ".DS_Store" -o -name "__MACOSX" \) -exec rm -rf {} \;
find "${inputfile%.*}" -type f \( -name "Thumbs.db" -o -name ".DS_Store" -o -iname \*.clip -o -iname \*.psd -o -iname \*.psb -o -iname \*.twd -o -iname \*.sai -o -iname \*.blend -o -iname \*.sut \) -delete
find "${inputfile%.*}" -type d -empty -delete
else
exit 0
fi