I’m trying to use imagejpeg with PHP to turn a text string into a jpeg. When I run the code on my server in a regular PHP file (outside of EE) it works perfectly. But when I try to render the code in an EE template I get a whole bunch of weird characters (see attachment). For reference, this is the code:
<?php
// Create a blank image and add some text
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
// Set the content type header - in this case image/jpeg
header('Content-Type: image/jpeg');
// Output the image
imagejpeg($im);
// Free up memory
imagedestroy($im);
?>I have PHP enabled for the template and I’ve tried both input and output with the same results. Using EE 2.4.0.
Hello adro,
Thank you for posting your question on the forums.
I was able to reproduce that this does not work. But it’s a bit outside of support as we do not support custom PHP. I would like to move this to development and programming to see if the community can help you with this.
Thanks again for asking your question!
Cheers,
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.