Redirect to generated image file instead use php function for opening files.