I am displaying image using below code
header('Expires: ' . date('r',time() + 864000));
header("Content-Length: " . strlen($contents));
where $contents is getting from fread functions. Some days later the images are not displaying and i am getting the below errors
“The image <Route to imagescript.php> cannot be displayed, because it contains errors”
And after a long Google search, i found the solutions, May be this might be very helpful to others who have same issues.
If you have this problem. try to delete any space character between the begin of the script and the php tag <?php.
I spent several hours before realize this. And now it works OK. This happens because any character on the file alter the png format.