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
https://forums.phpfreaks.com/topic/88843-help-with-a-simple-script/
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.

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);
?>

 

 

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.