How to count clicks made on an image
Look on how Advertisement module is doing it.

Simplified outline is:


Each image is linked to a page named like /count/someuniqueid
Module implements that page to increase counter and then sends 302 Found HTTP header to user's browser.
Browser is redirected to a desired page and user don't really see what happened at all.


Actual workflow is, due to performance issues, way more complicated and involves php files that does not bootstrap Drupal, caching and all that.