Welcome Guest, Not a member yet? Register   Sign In
Dynamic PNG creation using the output class - not working
#1

[eluser]ohall[/eluser]
Hi,

I'm creating an image dynamically using GD and trying to return the resulting image using the output class.

Following the documentation, I have this code:

Code:
class Img extends CI_Controller {

  function _remap( $id, $params = array())
  {
    //
    // Controller code to create the image
    //
    imagepng( $img, 'cache/tmp.png' );
    imagedestroy( $img );
        
    $this->output
        ->set_content_type( 'image/png' )
        ->set_output( file_get_contents( 'cache/tmp.png' ));
  }
}

The image is created no problem, so I'm happy that everything's fine up to the final output, but my browser returns the png data as plain text... not very useful.

I checked the data coming back from Apache, and can see the header is actually setting "Content-Type: text/html" - so no wonder I'm getting text rather than an image!

Can anyone tell me what I'm doing wrong?

Many thanks,
Oliver
#2

[eluser]ohall[/eluser]
I'm really sorry - this should have been posted to the Reactor forum. Please ignore




Theme © iAndrew 2016 - Forum software by © MyBB