donovan-duplessis/cakephp-captcha — pull request #8 by yanosh-kunsh (2014-07-22 12:23:35+00:00)
Title: fix outputing image to the browser before the content type header is sen...

# The problem
The captcha image was sometimes sent with a `text/html` header and sometimes with its appropriate `image/jpeg` header.

# The explanation
The imagejpg() function actually returns a boolen value and the image itself is sent to the output buffer. So when passed as a parameter to `$this->response->body(imagejpeg($image));` the image is not set as the body of the response.

# The fix
Capture the output buffer content into a variable which then is passed as the body of the response.