#!/usr/bin/env bash # 26.03.04 :: klevstul resize() { test_integer() { if ! [[ $1 =~ ^[1-9][0-9]*$ ]]; then echo "error: variable (image width) must be an integer" exit 1 fi } filename=$1 # ~/syncDir/0_downloads/frodeKlevstul.jpg extension="${filename##*.}" # jpg basename_without_ext="${filename%.*}" # ~/syncDir/0_downloads/frodeKlevstul basename_only="${basename_without_ext##*/}" # frodeKlevstul width=$2 width=${width:=1000} # default: 1000 test_integer ${width} # make sure the input (if given from the user) is valid # scale=1000:-1: resizes the image to a width of 1000 pixels, automatically calculating the height to preserve the original aspect ratio. # -q:v 90: sets the jpeg quality to 90 (lower values mean higher quality; 90 is a high quality setting for jpeg). ffmpeg -i ${filename} -vf "scale=${width}:-1" -q:v 90 ${basename_without_ext}_rzd.jpg } this_file_name=`basename "$0"` if [ $# -lt 1 ]; then echo "error: path to file is missing." echo "usage: '$this_file_name [path_to_file] ([width (1000)])'" exit 1 fi resize $1 $2