From 5baad57240373706a1f19b5b5515b7e1c7033b37 Mon Sep 17 00:00:00 2001 From: eshrh Date: Tue, 16 Mar 2021 16:47:22 -0400 Subject: [PATCH] Add image resizing with defaults. --- ames.sh | 10 ++++++++-- config | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ames.sh b/ames.sh index 6f64cd9..21cee74 100755 --- a/ames.sh +++ b/ames.sh @@ -22,6 +22,9 @@ OUTPUT_MONITOR="" AUDIO_BITRATE="64k" AUDIO_FORMAT="opus" IMAGE_FORMAT="webp" +# -2 to calculate dimension while preserving aspect ratio. +IMAGE_WIDTH="-2" +IMAGE_HEIGHT="300" CONFIG_FILE_PATH="$HOME/.config/ames/config" @@ -167,6 +170,7 @@ screenshot() { -hide_banner \ -loglevel error \ -i "$path" \ + -vf scale="$IMAGE_WIDTH:$IMAGE_HEIGHT" \ "$converted_path" rm "$path" @@ -186,6 +190,7 @@ again() { -hide_banner \ -loglevel error \ -i "$path" \ + -vf scale="$IMAGE_WIDTH:$IMAGE_HEIGHT" \ "$converted_path" rm "$path" @@ -206,10 +211,11 @@ screenshot_window() { ffmpeg -nostdin \ -hide_banner \ -loglevel error \ - -i "$path" "/tmp/$(basename -- "$path" | cut -d "." -f-2).$IMAGE_FORMAT" + -i "$path" \ + -vf scale="$IMAGE_WIDTH:$IMAGE_HEIGHT" \ + "$converted_path" rm "$path" - store_file "$converted_path" update_img "$(basename -- "$converted_path")" notify_screenshot_add diff --git a/config b/config index 5364e69..6674543 100644 --- a/config +++ b/config @@ -5,3 +5,6 @@ OUTPUT_MONITOR="" AUDIO_BITRATE="64k" AUDIO_FORMAT="opus" IMAGE_FORMAT="webp" +# -2 to calculate dimension while preserving aspect ratio. +IMAGE_WIDTH="-2" +IMAGE_HEIGHT="300"