RED_BOUNDARY="50" # less than GREEN_BOUNDARY="250" # greater than BLUE_BOUNDARY="20" # less than # Usage: check_for_green_bar x-coord y-coord gravity # Returns: 0 if pixel is bright green, 1 if pixel is not function check_for_green_bar { color=$(convert thumbnail-gbc.jpg -crop "1x1+${1}+${2}" -gravity "${3}" txt:- | grep -oE 'srgb\(.+\)' | grep -oE '[0-9,]+') found_red=$(echo $color | grep -oE '^[0-9]+') found_green=$(echo $color | sed -E s/[0-9]+,// | grep -oE '^[0-9]+') found_blue=$(echo $color | sed -E s/[0-9]+,[0-9]+,// | grep -oE '^[0-9]+') if [[ ($found_red -le $RED_BOUNDARY ) && ($found_green -ge $GREEN_BOUNDARY) && ($found_blue -le $BLUE_BOUNDARY) ]]; then echo 0 else echo 1 fi }