Jump to content

Text on image


stuffradio

Recommended Posts

Ok,

 

so I have a php file that creates the image. In that file, I have it calling a script that is supposed to write text on the image, but that script that is supposed to write text on the image doesn't work.

 

This is what gets outputted in the browser:

 

Here is the code:

<?php
  $imag = $_GET['file'];
  $path = $_SERVER['DOCUMENT_ROOT']."wp-2.7/wp-content/uploads/" . $imag;
  $im = imagecreatefromjpeg($path);
  $cor = imagecolorallocate($im, 0, 0, 0);
  $white = imagecolorallocate($im, 255, 255, 255);
  $text = $_GET['text'];
  header ('Content-type: image/jpeg');
  imagettftext($im, 18, 0, 10, 5, $cor, 'Arial', $text);
  imagejpeg($im);
?>

 

Any idea what I'm doing wrong? I want to have text on the top of the image and on the bottom. I just need to know how to do this correctly though and I will figure out the positioning part.

Link to comment
https://forums.phpfreaks.com/topic/163320-text-on-image/
Share on other sites

Thanks for the reply, but it still doesn't work:

 

<?php
header ('Content-type: image/jpeg');
  $imag = $_GET['file'];
  $path = $_SERVER['DOCUMENT_ROOT']."wp-2.7/wp-content/uploads/" . $imag;
  $im = imagecreatefromjpeg($path);
  $cor = imagecolorallocate($im, 0, 0, 0);
  $white = imagecolorallocate($im, 255, 255, 255);
  $text = $_GET['text'];
  $font = 'arial.ttf';
  imagettftext($im, 18, 0, 10, 5, $cor, $font, $text);
  imagejpeg($im);
?>

Link to comment
https://forums.phpfreaks.com/topic/163320-text-on-image/#findComment-861705
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.