Functions min_jpg and min_png work on multiple files

main
Buddy Sandidge 2 years ago
parent 7c02ea153d
commit a6d113956c

@ -95,19 +95,25 @@ command_installed() (
min_jpg() ( min_jpg() (
set -ue set -ue
command_installed jpegtran command_installed jpegtran
file=$1 for FILE in "$@" ; do
out_file=$(mktemp) PERMISSIONS=$(stat --format '%a' "${FILE}")
jpegtran -optimize -perfect -outfile "$out_file" "$file" OUT_FILE=$(mktemp)
mv "$out_file" "$file" jpegtran -optimize -perfect -outfile "${OUT_FILE}" "${FILE}"
mv "${OUT_FILE}" "${FILE}"
chmod "${PERMISSIONS}" "${FILE}"
done
) )
min_png() ( min_png() (
set -ue set -ue
command_installed pngcrush command_installed pngcrush
out_file=$(mktemp) for FILE in "$@" ; do
file=$1 PERMISSIONS=$(stat --format '%a' "${FILE}")
pngcrush -rem alla -reduce -brute "$file" "$out_file" OUT_FILE=$(mktemp)
mv "$out_file" "$file" pngcrush -rem alla -reduce -brute "${FILE}" "${OUT_FILE}"
mv "${OUT_FILE}" "${FILE}"
chmod "${PERMISSIONS}" "${FILE}"
done
) )
get_create_date() ( get_create_date() (

Loading…
Cancel
Save