quinq-size - various - Various utilities developed at bitreich. | |
git clone git://bitreich.org/various/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinw… | |
Log | |
Files | |
Refs | |
Tags | |
--- | |
quinq-size (652B) | |
--- | |
1 #!/bin/bash | |
2 | |
3 if [ $# -lt 1 ]; | |
4 then | |
5 printf "usage: %s -|img|vid [img|vid ...]\n" "$(basename "$0")" … | |
6 exit 1 | |
7 fi | |
8 | |
9 function toquinqsize { | |
10 filename="$1" | |
11 mimetype="$(file --mime-type -b "${filename}")" | |
12 output="${filename%.*}_quinqsize.${filename##*.}" | |
13 case "${mimetype}" in | |
14 image/*) | |
15 convert "$filename" -colorspace RGB -resize '1024>' -col… | |
16 ;; | |
17 video/*) | |
18 ffmpeg -i "${filename}" -vf 'scale=w=min(iw\,800):h=-2' … | |
19 ;; | |
20 esac | |
21 printf "%s -> %s\n" "${filename}" "${output}"; | |
22 } | |
23 | |
24 if [ "$1" = "-" ]; | |
25 then | |
26 while read -r file; | |
27 do | |
28 toquinqsize "$file" | |
29 done | |
30 else | |
31 for i in "$@"; | |
32 do | |
33 toquinqsize "${i}" | |
34 done | |
35 fi | |
36 |