Hi,
Your code works perfectly fine on my machine :
<?php
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
header('Content-type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
die;
?>
Are you sure you are not outputing anything before or after that code ? Even any kind of whitespace would be a source of troubles.
Or maybe your script is doing something else somewhere ?
If it still doesn't work, maybe trying with imagettftext
, to use a "better" / more complete font than the ones used by imagestring
might help ?
Using something like this, for instance :
$font = '/usr/share/fonts/truetype/msttcorefonts/arial.ttf';
imagettftext($im, 20, 0, 10, 20, $text_color, $font, 'A Simple éléphant String');
BTW, did you try without those line :
header('Content-type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
If there is an error/warning/notice, removing those lines might help you seeing those.
And, as a sidenote : using JPEG for images that contain some text generally doesn't give great results, as JPEG is a destructive compression mechanism. Using PNG, in that kind of situation, might get you better results ;-)