If you’re doing automation of the X selection there are pretty much two options: xsel and xclip.
I use xclip because it supports binary data. This allows you to do things like add a line to a screenshot script to copy the screenshot to the clipboard for insertion into gmail.
xclip -t image/png -selection c -i /tmp/foo.png