How about ImageMagick? Its not a library per se however if you can provide shell access to your environment its pretty easy to use.
You would most probably be interested in the compare command.
EDIT: ImageMagick does contain tools for sub-image search like subimage-search.