header + thumbnail class

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tarja311
Forum Commoner
Posts: 73
Joined: Fri Oct 20, 2006 10:57 pm

header + thumbnail class

Post by tarja311 »

Hi All.

I am using the Thumbnail Generator Class from http://www.phpgd.com/scripts.php?script=1 This class works great for my needs, unfortunately, implementing it is not a walk in the park.

About my site :
My site is already is full of content and images (mostly thumbnails) that are resized by html (width = ). I have an index page that is the outside frame (hyperlinks, search bar) and a "main" that is in the middle of the outside frame and displays the thumbnails.

Problem :
When i invoke the thumbnail class ... i receive the good ol' "Warning: Cannot modify header information - headers already sent by" warning message, and i guess that's because

Code: Select all

header("Content-type: image/jpeg;");
is being called after stuff has already been sent to the browser. Is there a way to make it so i don't have to send a header? I've noticed that most or all classes that manipulate images have to send a header to the browser so it knows what type of data it is. Or is there a way i can call this header before the data is sent and not mess up my site. If so then where?

Thanks

-- tarja
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

I'm guessing here, but I imagine you're trying to resize the image and send the output along with your HTML. That doesn't work*. You need to create a seperate script for your images and call it using the HTML image tag.

For example:

Code: Select all

<img src="/resize.php?image=myimage.jpg">
resize.php would be a script that just resizes your image and outputs it ... no HTML or anything.

* Ok, it does work in IE, but it's still wrong.
Post Reply