Add quinq-size. - various - Various utilities developed at bitreich. | |
git clone git://bitreich.org/various/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinw… | |
Log | |
Files | |
Refs | |
Tags | |
--- | |
commit c3f3b526c18fbeaf53985f3a5c6d11211b3fb1f7 | |
parent 260988ae866ce99cead30846c3f0bb51dfa12e5c | |
Author: Christoph Lohmann <[email protected]> | |
Date: Fri, 26 Feb 2021 19:14:48 +0100 | |
Add quinq-size. | |
Diffstat: | |
A quinq-size | 36 +++++++++++++++++++++++++++++… | |
1 file changed, 36 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/quinq-size b/quinq-size | |
@@ -0,0 +1,36 @@ | |
+#!/bin/bash | |
+ | |
+if [ $# -lt 1 ]; | |
+then | |
+ printf "usage: %s -|img|vid [img|vid ...]\n" "$(basename "$0")" >&2 | |
+ exit 1 | |
+fi | |
+ | |
+function toquinqsize { | |
+ filename="$1" | |
+ mimetype="$(file --mime-type "${filename}" | cut -d':' -f 2 | cut -d' … | |
+ output="${filename%.*}_quinqsize.${filename##*.}" | |
+ case "${mimetype}" in | |
+ image/*) | |
+ convert "$filename" -resize 1024 "${output}"; | |
+ ;; | |
+ video/*) | |
+ ffmpeg -i "${filename}" -vf scale=800:-1 "${output}"; | |
+ ;; | |
+ esac | |
+ printf "%s -> %s\n" "${filename}" "${output}"; | |
+} | |
+ | |
+if [ "$1" = "-" ]; | |
+then | |
+ while read -r file; | |
+ do | |
+ toquinqsize "$file" | |
+ done | |
+else | |
+ for i in "$@"; | |
+ do | |
+ toquinqsize "${i}" | |
+ done | |
+fi | |
+ |