I am trying to generate and return an image to the template using the Silverstripe 3.0 Framework and am getting some issues.
I return this to the browser in a variable like so:
public function make_image(){
$string = 'string';
$im = imagecreate(300,300);
$orange = imagecolorallocate($im, 220, 210, 60);
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, 9, $string, $orange);
imagepng($im);
imagedestroy($im);
}
The browser renders this as:
�PNG IHDR,,C�6PLTE��<��*�"IDATh���1 �Om ?�x-��{�IEND�B`�
The headers that are being returned are text/html and there is only one request that makes me think there is something strange going on there. Can anyone help me out with this.
Possibly a different way of achieving this is Silverstripe using the Image() class?