Jump to content

Move text in signature generator.


digi duck

Recommended Posts

Hi everyone, i have a signature generator site called http://gamesigs.co.uk and have been trying to come up with a way let users move the text around so it doesn't just have to be in the middle. If you have any suggestions please help me as i'm a php novice. Here is the source that i think needs altering.


[code]<?
$name = stripslashes($_GET['name']);
$size = stripslashes($_GET['size']);
$font = 'images/sig_maker/fonts/'.stripslashes($_GET['font']).'.ttf';
$fontcolor['r'] = stripslashes($_GET['color_r']); // font color - RED
$fontcolor['g'] = stripslashes($_GET['color_g']); // font color - GREEN
$fontcolor['b'] = stripslashes($_GET['color_b']); // font color - BLUE
$shadow = stripslashes($_GET['shadow']);
$lines = stripslashes($_GET['lines']);
function arrow($im, $x1, $y1, $x2, $y2, $alength, $awidth, $color){
///
}
switch ($_GET['color']) {
case '1':
$bgpic = 'images/sig_maker/1.jpeg';
break;
case '2':
$bgpic = 'images/sig_maker/2.jpeg';
[color=red]carries on for ages[/color]
break;
}
$im = imagecreatefromjpeg($bgpic);
//Calculate, the centre:
for(;;){
list($image_width, $image_height) = getimagesize($bgpic);
list($left_x, , $right_x) = imagettfbbox($size, 0, $font, $name);
$text_width = $right_x - $left_x;
if($image_width > $text_width+5){
break;
}
$size = $size - .5;
if($size == 1){
die('Script not responding to decreasing font size, in other words: try using less letters.');
}
}
$padding = ($image_width - $text_width)/2;
$textcolor = imagecolorresolve($im, $fontcolor['r'], $fontcolor['g'], $fontcolor['b']);
$grey = imagecolorallocate($im, 128, 128, 128);
if($shadow == 'y'){
imagettftext($im, $size, 0, $padding+1, 77, $grey, $font, $name);
}
if($lines == 'y'){
//imagettftext($im, $size, 0, $padding+1, 77, $grey, $font, $name);
}
imagettftext($im, $size, 0, $padding, 75, $textcolor, $font, $name);
if($_GET['dl']){
header('Content-Disposition: attachment; filename="sig.jpeg"');
}
header("Content-type: image/jpeg");
imagegif($im);
?>[/code]

PLEASE HELP.
Link to comment
Share on other sites

To do this with PHP, I think would be tedious for the user. I'd personally suggest doing it with JavaScript, there's a cool script [url=http://www.walterzorn.com/dragdrop/dragdrop_e.htm]HERE[/url] that you could use to drag a layer around on top of an image, and on creation of the image, grab the coords of the text so you know where to generate it.
Link to comment
Share on other sites

  • 2 weeks later...
ok i've managed to do it. If anyone's interested you change the

[code]//imagettftext($im, $size, 0, $padding+1, 77, $grey, $font, $name);
[/code]

//imagettftext($im, $size, angle, horizontal, height, $grey, $font, $name);

if you still don't get it contact me. (info found on site http://gamesigs.co.uk)


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.