Get dimensions of input image
This commit is contained in:
parent
e05ad2c262
commit
c5be149197
16
griddle
16
griddle
|
@ -2,6 +2,17 @@
|
||||||
|
|
||||||
set -e
|
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() {
|
main() {
|
||||||
if test "$#" -ne 2; then
|
if test "$#" -ne 2; then
|
||||||
printf "Usage: griddle <inputfile> <outputfile>\n"
|
printf "Usage: griddle <inputfile> <outputfile>\n"
|
||||||
|
@ -26,7 +37,10 @@ main() {
|
||||||
fi
|
fi
|
||||||
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 "$@"
|
main "$@"
|
||||||
|
|
Loading…
Reference in New Issue