Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.