The code you supply appears to generate a new image (albeit from an existing file) and return it with an image MIME type.
If you want to change the URL target, you need to put this sort of code in your HTML document instead, so that it outputs one of three code blocks that look something like this:
if ($number == 3) {
echo '<a href="destination3.html"><img src="file3.jpg" /></a>';
}
This will work fine unless you need to generate a unique image each time. If you're just using one of three static images randomly, this is the way forward.