From c5be14919797bb54f51092048797f5780ec77908 Mon Sep 17 00:00:00 2001 From: The Magician Date: Thu, 7 Mar 2024 13:20:24 +0000 Subject: [PATCH] Get dimensions of input image --- griddle | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/griddle b/griddle index aef416d..5658899 100755 --- a/griddle +++ b/griddle @@ -2,6 +2,17 @@ set -e +WIDTH=1 +HEIGHT=2 + +get_image_dimension() { + inputfile="$1" + dimension="$2" + + height="$(identify $inputfile | cut -d ' ' -f 3 | cut -d 'x' -f $dimension)" + printf "%s" "$height" +} + main() { if test "$#" -ne 2; then printf "Usage: griddle \n" @@ -26,7 +37,10 @@ main() { fi fi - echo "$inputfile" "$outputfile" + width="$(get_image_dimension $inputfile $WIDTH)" + height="$(get_image_dimension $inputfile $HEIGHT)" + + echo "$inputfile" "$outputfile" "Dimensions: $width x $height" } main "$@"