Shortcode content filter?

you can use regex to find your the src and use that to append your “files/myimagescript?” to it:

function append_myimagescript($attr, $content){ 
    $pattern = '/src="https://wordpress.stackexchange.com/questions/11618/([^"]*)"/i';
    $replacement="files/myimagescript?${1}";
    return preg_replace($pattern, $replacement, $content);
}