Image appearing as binary text in browser

A

Anonymous

Guest
Even though a small site will not drain too many resources by dynamically creating images at page load, I would strongly advise against doing such. It is better if you can create a file on the server and target that (either at image upload time, or through an admin backend).
Imagine you had 10 images of 100KB and 5000 hits per day. That would effect 10x100x5000 KB or processing per day (5 gig[ish]). Also note: until GD2.0.7 Thomas Boutel had some issues with server memory allocation and cleanup, so if you are using an older build, you should try to reduce the amount of times your scripts run.

All the GD image output functions have parameters for saving a local copy (second parameter on all save jpeg, which also has a compression parameter)

ImageJPEG($img_ref, 'path/filename.jpg', 80);
would save a copy of the output $img_ref as path/filename.jpg with a quality of 80%
 
you can also try using a header call before the output

Header("Content-Type: image/png");
 
Back
Top