You'd need it in the script that acts as the image:

<img src="script.asp?x=7&y=23" ...>

Then put the code in script.asp, if you're using ASP. What this does it tell the browser to get the script for the image - but the script does its thing and tells the browser the image is actually in another location (the real image).

(Or you could possibly have the script open the image as a binary file and start sending the data directly to the browser, but that's a little more complicated.)