Some workaround. You'll need gnome-screenshot and imagemagick packages as well as a few standard commands.
We'll simply define a random file name (in the temporary directory /tmp), take a screenshot and write it to said name, then analyse the image's dimensions (picking the pixel size only) and finally remove the image.
#!/bin/bash
imed=$(mktemp -u).png &&\
#-a allows area specification and
#-f defines the screenshot file's location and name
gnome-screenshot -a -f "$imed" &>/dev/null &&\
#now draw the rectangle
#extract pixel dimensions form file
identify "$imed" | awk -F' ' '{print $3}' &&\
#and remove it
rm -f "$imed"
Obviously this means creating a dummy file. One might specify a tmpfs for the image's location to have it in RAM only - speeds the process up and is better for the HD's health.