Get dimensions of input image
This commit is contained in:
parent
e05ad2c262
commit
c5be149197
16
griddle
16
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 <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 "$@"
|
||||
|
|
Loading…
Reference in New Issue