Jump to content


Photo

Help With Dynamic Sig


  • Please log in to reply
18 replies to this topic

#1 Mr. Jay

Mr. Jay

    Young Padawan

  • Members
  • Pip
  • 81 posts

Posted 26 September 2006 - 07:51 PM

Im trying to figure out on how to add extra images onto a dynamic si

i tried this but itll show up as
/blank.gifName: Text
ff.gifName: Text
ie.gifName: Text

This is the current code
<?php

$image = $_GET['image'];

$name1 = $_GET['name1'];

$text1 = $_GET['text1'];

$imgf = "./bg.png";

switch($image){
case 'ff':
$image2 = './ff.gif';
break;
case 'ie':
$image2 = './ie.gif';
break;
default:
$image2 = './none.gif';
}

$font = "./arial.TTF";

$im_size = getimagesize($imgf);

$image_width = $im_size[0];

$image_height = $im_size[1];

$im = imagecreatetruecolor($image_width, $image_height);

$blue = imagecolorallocate($im, 0, 6, 255);

$black = imagecolorallocate($im, 0, 0, 0);

$im2 = imagecreatefrompng($imgf);

imagecopy($im, $im2, 0, 0, 0, 0, $image_width, $image_height);

imagedestroy($im2);

imagettftext($im, 12, 0, 23, 29, $black, $font, $image2.' '.$name1.': '.$text1);

header("Content-type: image/png");

imagepng($im);

imagedestroy($im);

?>

Edited by Jonpopnycorn, 11 October 2006 - 12:14 PM.


#2 Illinifan91

Illinifan91

    P2L Jedi

  • Members
  • PipPipPip
  • 845 posts
  • Gender:Male
  • Location:Flower Mound, Texas

Posted 26 September 2006 - 07:57 PM

um well i dont know any sites that oyu cna pout php in your sig. but what is the problem wiht it?

#3 Mr. Jay

Mr. Jay

    Young Padawan

  • Members
  • Pip
  • 81 posts

Posted 26 September 2006 - 07:59 PM

um well i dont know any sites that oyu cna pout php in your sig. but what is the problem wiht it?


the text wont sow in the sig ^_^

#4 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 26 September 2006 - 08:32 PM

um well i dont know any sites that oyu cna pout php in your sig. but what is the problem wiht it?

Even though that is insanely hard to read, i think i get the general direction it's goin. And no, you can't put php in your sigs, but you can put images in your sig (just not here).

the text wont sow in the sig ^_^

If that's the case, then i would check to make sure these things are working right.
$im_size = getimagesize($imgf);

$image_width = $im_size[0];

$image_height = $im_size[1];

/****************/

imagettftext($im, 12, 0, 23, 29, $black, $font, $name1.': ', $blue, $font, $text1);
Check the variables, cordinates, color, font (make sure it loaded some how, try using regular text just for testings sake), etc...

#5 Mr. Jay

Mr. Jay

    Young Padawan

  • Members
  • Pip
  • 81 posts

Posted 26 September 2006 - 08:38 PM

It works when I do this
imagettftext($im, 12, 0, 23, 29, $black, $font, $name1)

but not this
imagettftext($im, 12, 0, 23, 29, $black, $font, $name1.': ', $blue, $font, $text1);

#6 Av-

Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,972 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 27 September 2006 - 12:21 PM

replace the comma before $blue with a dot

#7 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 27 September 2006 - 03:24 PM

Lets think about this one for a second...
[quote name='http://php.net/manual/en/function.imagettftext.php']array imagettftext ( resource image, float size, float angle, int x, int y, int color, string fontfile, string text )[/quote]
There's the imagettftext() function and the parameters it accepts. You'll notice, after the text parameter, it doesn't accept anything else. So, if you which to add additional parameters, you can't do it freely, you would have to either define a custom function, or call the function twice use the different sets of parameters.

Avalance, heres the line that defines $blue.
$blue = imagecolorallocate($im, 0, 6, 255);
Notice, it's not a string. So replacing any number of the commas in that call to imagettftext() won't do anything but write a seriously messed up string.

To do what you want, it would be easiest to call imagettftext() twice, and for the x-coordinate in the second one use imagefontwidth() in combination with a plus sign to position the blue text properly.

#8 Mr. Jay

Mr. Jay

    Young Padawan

  • Members
  • Pip
  • 81 posts

Posted 27 September 2006 - 03:26 PM

doesnt work :(

Edit: heres the new code

<?php

$name1 = $_GET['name1'];

$text1 = $_GET['text1'];

$Angle=0;

$FontSize=12.75;

$imgf = "./bg.png";

$font = "./arial.TTF";

$im_size = getimagesize($imgf);

$image_width = $im_size[0];

$image_height = $im_size[1];

$im = imagecreatetruecolor($image_width, $image_height);

$blue = imagecolorallocate($im, 0, 6, 255);

$black = imagecolorallocate($im, 0, 0, 0);

$im2 = imagecreatefrompng($imgf);

imagecopy($im, $im2, 0, 0, 0, 0, $image_width, $image_height);

imagedestroy($im2);

imagettftext($im, $FontSize, $Angle, 300, 29, $black, $font, $name1, $blue, ' '.$text1);

header("Content-type: image/png");

imagepng($im);

imagedestroy($im);

?>

Edited by Jonpopnycorn, 27 September 2006 - 03:31 PM.


#9 Av-

Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,972 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 28 September 2006 - 12:55 PM

not what i ment rc :P, i ment to replace the comma where the variable blue was called in imagettftext();

imagettftext($im, 12, 0, 23, 29, $black, $font, $name1.': ', $blue, $font, $text1);

correct me if im wrong, but im pretty sure that should be a dot.

#10 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 28 September 2006 - 06:22 PM

Avalanche, i think you mis-read my post. That line you posted, if youreplace any comma with a dot, it will not fix anything (unless theres something about that function that i don't know about and isn't documented).

Jon, it didn't work because you didn't do anything i said, you just added a few variables...
<?php
$name1 = $_GET['name1'];
$text1 = $_GET['text1'];

$imgf = "./bg.png";
$font = "./arial.TTF";

$im_size = getimagesize($imgf);
$image_width = $im_size[0];
$image_height = $im_size[1];

$im = imagecreatetruecolor($image_width, $image_height);
$im2 = imagecreatefrompng($imgf);

$blue = imagecolorallocate($im, 0, 6, 255);
$black = imagecolorallocate($im, 0, 0, 0);

imagecopy($im, $im2, 0, 0, 0, 0, $image_width, $image_height);
imagedestroy($im2);

imagettftext($im, 12, 0, 23, 29, $black, $font, $name1.':')
imagettftext($im, 12, 0, 50, 29, $blue, $font, $text1);

header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
?>
That's by no means perfect (and not exactly what i said), but it will illustrate my point.

Edited by rc69, 28 September 2006 - 06:23 PM.


#11 Mr. Jay

Mr. Jay

    Young Padawan

  • Members
  • Pip
  • 81 posts

Posted 10 October 2006 - 02:32 AM

Im trying to figure out on howw to add extra images onto a dynamic si

i tried this but wornt work :)

<?php

$image = $_GET['image'];

$name1 = $_GET['name1'];

$text1 = $_GET['text1'];

$imgf = "./bg.png";

if ($image = ) {
$image2 = "./ff.gif";
} elseif ($image2 = ) {
$image2 = "./ie.gif";
} else {
$image2 = "./blank.gif";
}


$font = "./arial.TTF";

$im_size = getimagesize($imgf);

$image_width = $im_size[0];

$image_height = $im_size[1];

$im = imagecreatetruecolor($image_width, $image_height);

$blue = imagecolorallocate($im, 0, 6, 255);

$black = imagecolorallocate($im, 0, 0, 0);

$im2 = imagecreatefrompng($imgf);

imagecopy($im, $im2, 0, 0, 0, 0, $image_width, $image_height);

imagedestroy($im2);

imagettftext($im, 12, 0, 23, 29, $black, $font, $image2.' '.$name1.': '.$text1);

header("Content-type: image/png");

imagepng($im);

imagedestroy($im);

?>

Edited by Jonpopnycorn, 10 October 2006 - 12:21 PM.


#12 Demonslay

Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 973 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 10 October 2006 - 05:58 PM

1. What kind of error do you get.
2. Please put code in the '[code=auto:0]' BB tag, it makes it soo much easier to read...

#13 Mr. Jay

Mr. Jay

    Young Padawan

  • Members
  • Pip
  • 81 posts

Posted 10 October 2006 - 06:19 PM

i get an error on this

if ($image = ) {
$image2 = "./ff.gif";
} elseif ($image2 = ) {
$image2 = "./ie.gif";
} else {
$image2 = "./blank.gif";
}


#14 Demonslay

Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 973 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 10 October 2006 - 09:05 PM

Ah I just happened to look at that and my face made one of those 'WTF' faces. :mellow:

This line.
if ($image = ) {

Lol, what are you trying to accomplish there?
Having it equal to absolutely nothing on the other side will not do anything, and I can only imagine the ugly error you are getting (would really have helped in the first time if you actually show us the error...).

I don't really get what you are trying to do with this little block of ifs, but I'm guessing it should look like this.

if($image){
$image2 = "./ff.gif";
}
elseif($image2){
$image2 = "./ie.gif";
}
else{
$image2 = "./blank.gif";
}

Really makes no sense whatsoever what you are trying to do here, since $image2 is undefined. And some other bits of it doesn't make sense to me at all...

#15 Mr. Jay

Mr. Jay

    Young Padawan

  • Members
  • Pip
  • 81 posts

Posted 10 October 2006 - 09:47 PM

Im trying to add an extra images without addiding it to bg.png

for example

sig.php?image=ie&name1=something&text1=something
sig.php?image=ff&name1=something&text1=something
sig.php?image=none&name1=something&text1=something

$image = $_GET['image'];

if($image = ff){
$image2 = "./ff.gif";
}
elseif($image = ie){
$image2 = "./ie.gif";
}
elseif($image = none){
$image2 = "./blank.gif";
}
else{
$image2 = "./blank.gif";
}
This is suppose to define what image will $image2 will be

imagettftext($im, 12, 0, 23, 29, $black, $font, $image2.' '.$name1.': '.$text1);
this is where trhe image and text is supposed to go

#16 Demonslay

Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 973 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 10 October 2006 - 11:45 PM

Ah, now I see. Would have helped if that was explained earlier on.

You are still not using it right though, lol. First of all, when trying to compare two things, you don't use a single equal sign '=', you have to use two '=='. Using one actually set the variable, so no matter what you'll get the first if to hit true.
Second, you aren't defining a string. PHP and any other coding language (other than HTML) has to have strings dignified by quotes of some sort, otherwise it will attempt to parse it as a function, a method, or a constant.
Here is what that section should look like.
I'll use a switch statement since it's easier and you are only comparing a single variable
switch($image){
case 'ff':
$image2 = './ff.gif';
break;
case 'ie':
$image2 = './ie.gif';
break;
default:
$image2 = './none.gif';
}

If you need help with how switch statements, look here.
:)

#17 Mr. Jay

Mr. Jay

    Young Padawan

  • Members
  • Pip
  • 81 posts

Posted 11 October 2006 - 12:14 PM

i tried this but itll show up as
/blank.gifName: Text
ff.gifName: Text
ie.gifName: Text

This is the current code
<?php

$image = $_GET['image'];

$name1 = $_GET['name1'];

$text1 = $_GET['text1'];

$imgf = "./bg.png";

switch($image){
case 'ff':
$image2 = './ff.gif';
break;
case 'ie':
$image2 = './ie.gif';
break;
default:
$image2 = './none.gif';
}

$font = "./arial.TTF";

$im_size = getimagesize($imgf);

$image_width = $im_size[0];

$image_height = $im_size[1];

$im = imagecreatetruecolor($image_width, $image_height);

$blue = imagecolorallocate($im, 0, 6, 255);

$black = imagecolorallocate($im, 0, 0, 0);

$im2 = imagecreatefrompng($imgf);

imagecopy($im, $im2, 0, 0, 0, 0, $image_width, $image_height);

imagedestroy($im2);

imagettftext($im, 12, 0, 23, 29, $black, $font, $image2.' '.$name1.': '.$text1);

header("Content-type: image/png");

imagepng($im);

imagedestroy($im);

?>


#18 Demonslay

Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 973 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 11 October 2006 - 08:47 PM

I already replied to your PM regarding this...
You get it fixed?

#19 Mr. Jay

Mr. Jay

    Young Padawan

  • Members
  • Pip
  • 81 posts

Posted 12 October 2006 - 12:31 PM

nope i didnt get it :S

imagecopymerge()

bool imagecopymerge ( resource dst_im, resource src_im, int dst_x, int dst_y, int src_x, int src_y, int src_w, int src_h, int pct )




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users