Image appearing as binary text in browser

images php coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 191
Joined: Wed Jan 29, 2003 7:11 am
Location: UK

Wed Jan 29, 2003 7:19 am

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%

User avatar
Posts: 826
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Fri Jan 31, 2003 1:13 am

you can also try using a header call before the output

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

Post Reply