Jump to content

Help with a simple script


MaxEvans

Recommended Posts

I'm pretty much a beginner here. But I've gotten the hang of some things. I just need some pointers. http://www.maximum-voltage.com/Userbar%20Generator/heart.php  Something I'm working on for my site.  I got it all the way I want it.. but I want to know if it's possible to keep the text completely centered in the image. Depending on how many characters are put in, it moves off to the side. I want to make it completely centered, if it's possible. And is it possible to create a stroke on the text. Or would I have to edit the font file?

Link to comment
Share on other sites

<?php
error_reporting(E_ALL ^ E_NOTICE);
session_start();
header("Content-type: image/png");
if ($_SESSION["message"]){
$message = $_SESSION["message"];
}else{
$message = $_GET['message'];}
$im = imagecreatefrompng("Heart1.png");
$message_width = imagettfbbox(10, 0, "visitor.ttf", $message);
$message_start = (350 - ($message_width[2] + 123));
$color = imagecolorallocate($im, 0, 0, 0);
imagettftext($im, 10, 0, $message_start, 14, $color, "visitor.ttf", $message);
imagepng($im);
imagedestroy($im);
?>

 

That's the code.

Link to comment
Share on other sites

check this

 


<?php
error_reporting(E_ALL ^ E_NOTICE);
session_start();
header("Content-type: image/png");
if ($_SESSION["message"]){
$message = $_SESSION["message"];
}else{
$message = $_GET['message'];}
$im = imagecreatefrompng("Heart1.png");
//$message_width = imagettfbbox(10, 0, "visitor.ttf", $message);
//$message_start = (350 - ($message_width[2] + 123));
//$color = imagecolorallocate($im, 0, 0, 0);
//imagettftext($im, 10, 0, $message_start, 14, $color, "visitor.ttf", $message);

$text_color = imagecolorallocate($im, 20, 211, 123);
$imgx     = (imagesx($im) - 7.5 * strlen($message)) / 2;
$imgy     = (imagesy($im)/4) ;
imagestring($im, 3, $imgx, $imgy, $message, $text_color);

imagepng($im);
imagedestroy($im);
?>

 

 

Link to comment
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.