View Full Version : Resolved Capturing ImageGIF Output

09-21-2009, 08:29 PM
Alright, so I am working on a little update for Mr. Thumb, everything was easy to do in my head, however when I got the code out, I got an interesting error that is leading me to think my approach won't work.

Keep in mind that the script functions just fine. The error is generated from the imagegif() line. Also, the ob_start() is initiated before the switch() function.

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/amerikan/public_html/mr_thumb/mrthumb.class.php on line 217

Warning: Cannot modify header information - headers already sent by (output started at /home/amerikan/public_html/mr_thumb/mrthumb.class.php:217) in /home/amerikan/public_html/mr_thumb/mrthumb.class.php on line 282

It must be an issue with the ob method. Can I use ob inside a class? I would assume you could.

case 'gif';
imagegif( $this->image['composite'], null, $quality );\
$this->image['buffer'] = ob_get_contents();
$this->image['virtual_size'] = strlen( $this->image['buffer'] );
header( 'Content-type: application/force-download' );
header( 'Content-Disposition: inline; filename="' . $filename . '.' . $this->image['extension'] . '"' );
header( 'Content-Transfer-Encoding: Binary' );
header( 'Content-length: ' . $this->image['virtual_size'] );
header( 'Content-Type: application/octet-stream' );
header( 'Content-Disposition: attachment; filename="' . $filename . '.' . $this->image['extension'] . '"' );
print $this->image['buffer'];

09-21-2009, 08:50 PM
which line is 217 ...

...and the "header already sent" error is a result of the server sending the first error.
When you fix the first error, you won't have the 2nd error.

09-21-2009, 09:40 PM
Like I said, the error, is generated on the imagegif() function within the provided code.

The header error is a result of the error above it...

09-22-2009, 05:48 AM
In regards to you're output buffering question, you bet you can. I would recommend keeping the flush/clean on the same 'level' as the ob_start just for clarity:

switch ($something)
case 'something':
$var = ob_get_contents();

for example. Though it shouldn't be a problem otherwise, I can see some ob stack problems happening if you should forget to end the clean in just one of the cases. Kind of like freeing a * in C when its null. Doesn't like that.

The only thing I can think of from that error is that it appears an addslashes was added to the 'composite'. But it sounds like this covers other types (jpeg, png etc), so that shouldn't be the case (I'm thinking magic_quotes_runtime at this one). So I'm a little stumped by just this.
Can you post this full class, I'll walk it.

I just noticed you've marked this as resolved, my bad.
Is it supposed to be, and if so can you post what the solution was?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum