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.

A computer sees any white space as a character, the same as any alphanumeric character. So outputting a white space is the same as outputting any other letter or number and it will cause the file to be damaged and unreadable.

hello there and thank you for your info – I have definitely
picked up something new from right here. I did however expertise a few technical issues using this web site, since I experienced to reload the site lots of times previous to I could get it to load correctly.
I had been wondering if your web host is OK? Not that I’m complaining, but sluggish loading instances times will sometimes affect your placement in google and can damage your high-quality score if advertising and marketing with Adwords. Anyway I’m adding this RSS to my
e-mail and could look out for a lot more of your respective intriguing content.
Ensure that you update this again very soon.