Get dimensions of input image

This commit is contained in:
The Magician 2024-03-07 13:20:24 +00:00
parent e05ad2c262
commit c5be149197
1 changed files with 15 additions and 1 deletions

16
griddle
View File

@ -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 <inputfile> <outputfile>\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 "$@"