I’m playing around with the gd library, and I have this code:
<?php header ('Content-type: image/png'); $im = @imagecreatetruecolor(120, 20) or die('Cannot Initialize new GD image stream'); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); imagepng($im); imagedestroy($im); ?>
now, if I run this independently, just like a simple script, it outputs the right image with the proper string, which is exactly what I want. However, I’m interested in rendering this output alongside other html content, as part of my view. So, I have something like this:
... <?php $this->renderPartial('_layoutImage'); ?> ...
…and I put the ‘image’ code inside the _layoutImage file. When I load the page, I get this error:
The image “http://path/to/webapp/index.php?r=layout/add” cannot be displayed, because it contains errors.
I suspect that it probably has something to do with this line of code:
header ('Content-type: image/png');
but I thought that renderPartial renders a view file without any layouts, ie there shouldn’t be any problems with header declarations, etc.
Any help would be appreciated…