Add quinq-size. - various - Various utilities developed at bitreich.
(HTM) git clone git://bitreich.org/various/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/various/
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
---
(DIR) commit c3f3b526c18fbeaf53985f3a5c6d11211b3fb1f7
(DIR) parent 260988ae866ce99cead30846c3f0bb51dfa12e5c
(HTM) Author: Christoph Lohmann <20h@r-36.net>
Date: Fri, 26 Feb 2021 19:14:48 +0100
Add quinq-size.
Diffstat:
A quinq-size | 36 +++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+), 0 deletions(-)
---
(DIR) 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' ' -f 2-)"
+ 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
+