Jump to content


Photo

Move text in signature generator.


  • Please log in to reply
4 replies to this topic

#1 digi duck

digi duck
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 04 September 2006 - 09:41 AM

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.


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

PLEASE HELP.

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 04 September 2006 - 10:58 AM

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 HERE 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.

#3 digi duck

digi duck
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 04 September 2006 - 02:49 PM

that looks pretty cool but i cant see how to make the layers into one image after the user has positioned it or grab the coordinates as you say and enter them in the code. any ideas?

#4 digi duck

digi duck
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 05 September 2006 - 10:41 AM

*BUMP*

#5 digi duck

digi duck
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 16 September 2006 - 09:19 AM

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

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

//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)







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users