Created
December 1, 2016 16:22
-
-
Save orotemo/63fd432be804b80469a80d2ee37362a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
read base_name <<< $( echo $1 | awk -F "\." '{print $1}' ) | |
size=$(convert "$1" -print "%wx%h\n" /dev/null) | |
read width height <<< $( echo $size | awk -F'[x]' '{print $1" "$2}' ) | |
export IFS="," | |
prev_label="" | |
cat "$base_name.csv" | while read label x0 y0 x1 y1; do | |
read fx0 <<< $(echo "$x0*$width" | bc) | |
ix0=$(printf '%.*f\n' 0 $fx0) | |
read fy0 <<< $(echo "$y0*$height" | bc) | |
iy0=$(printf '%.*f\n' 0 $fy0) | |
read fx1 <<< $(echo "$x1*$width" | bc) | |
ix1=$(printf '%.*f\n' 0 $fx1) | |
read fy1 <<< $(echo "$y1*$height" | bc) | |
iy1=$(printf '%.*f\n' 0 $fy1) | |
echo "these are the coords: ($ix0,$iy0) ($ix1,$iy1)" | |
convert $1 -fill none -stroke black -draw "rectangle $ix0,$iy0 $ix1,$iy1" $1 | |
if [ "$prev_label" != "$label" ] ; then | |
convert $1 -fill none -stroke black -annotate +$ix0+$iy0 "$label" $1 | |
prev_label=$label | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can transform using :
then
./draw_conv.sh FNx5c3sc2qrg5amtN20y.jpg