Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Capturing ImageGIF Output

    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.

    Code:
    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.

    PHP Code:
                        case 'gif';
                            
    imagegif$this->image['composite'], null$quality );
                            
    $this->image['buffer'] = ob_get_contents();
                            
    ob_end_clean();
                            
    $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'];
                        break; 
    Last edited by Element; 09-21-2009 at 11:56 PM.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    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.

  • #3
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts
    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...

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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:
    PHP Code:
    ob_start();
    ...
    switch (
    $something)
    {
        case 
    'something':
            
    $var ob_get_contents();
            break;
    }
    ob_end_clean(); 
    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.

    Edit:
    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?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •