The pattern you posted...
... is a bit odd. That would be pretty tricky. You'd need a PHP handler to load the image and you'd need to tell the server (Apache, Nginx, IIS, Whatever) to parse that file ending as PHP. Something like this would be simpler:
You would still need to create a PHP handler script to read the URL, parse the
GET string, and display the image.
You could probably get something like this...
... working with an endpoint.
However, the easiest thing to do is use
wp_get_attachment_image_src to create the URL. I don't know if that is an option for you but there is an example in the Codex:
$attachment_id = 8; // attachment ID
$image_attributes = wp_get_attachment_image_src( $attachment_id ); // returns an array
<img src="<?php echo $image_attributes; ?>" width="<?php echo $image_attributes; ?>" height="<?php echo $image_attributes; ?>">