1

I am trying to get it to show text1 and text2 on the same image only Text1 is showing up

 $rImg = ImageCreateFromJPEG("test.jpg");
 $cor = imagecolorallocate($rImg, 0, 0, 0);
 imagestring($rImg,5,126,22,"Text1",$cor);
 imagestring($rImg,5,500,34,"Text2",$cor);
 header('Content-type: image/jpeg');
 imagejpeg($rImg,NULL,100);

Thank you

Rickstar
  • 6,057
  • 21
  • 55
  • 74

2 Answers2

4

(500,34) seems like a co-ord that is too far right. Unless the jpg is at least that wide, you won't see it.

Joy Dutta
  • 3,416
  • 1
  • 19
  • 19
1

You code works when I test it. The second argument to imagestring is a font identifier (I originally thought it was x-coord). Is your test image > 500 pixels wide?

This works great:

 $rImg = ImageCreateFromJPEG("test.jpg");
 $cor = imagecolorallocate($rImg, 0, 0, 0);
 imagestring($rImg,5,0,0,"Text1",$cor);
 imagestring($rImg,5,0,30,"Text2",$cor);
 header('Content-type: image/jpeg');
 imagejpeg($rImg,NULL,100);
leepowers
  • 37,828
  • 23
  • 98
  • 129