Jump to content


php code Sig


17 replies to this topic

#1 jatt

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 24 July 2006 - 03:56 AM

hi i was wonder if Some one Can share a tutorial with me or can Some one tell me how to do it. what i am looking for is A Sig that Have Some Words on like what ever i type it in Txt file and upload it my server it shows on my Sig. like this what ever i play in my Winamp it shows in my sig Posted Image

#2 Erik Bernskiold

    Jedi In Training

  • Members
  • PipPip
  • 422 posts
  • Gender:Male
  • Location:Gothenburg, Sweden
  • Interests:I love to do booth Web Design and Photography. Nothing beats a nice day out in the nature with the camera gear, getting loads of nice photos. I have been playing the flute for 6 years now and I love it, and I am playing the pipe organ as well. I also like to teach other people the in and outs of software such as the CS3 suite from Adobe.

Posted 24 July 2006 - 04:41 AM

There was a thread on how you make winamp songs display like that in a thread not so long ago, use the search feature. -_-

#3 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 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 24 July 2006 - 11:49 AM

<?php	
//create image
//use existing image as a canvas
$img = imagecreatefromjpeg(winamp.jpeg);

//allocate the color black
$black = imagecolorresolve($img, 0, 0, 0);

//set the text file to be used
$file = 'text.txt';
//open the text file
$fp = fopen($file, rt);
//read the text file and store to the $text variable
$text = fread($fp, 1024);
//close file
fclose($fp);

//set x coordinant of the string
$x = 70;
//set y coordinant of the string
$y = 20;

//write the string in the white space of the signature
imagestring($img, 5, $x, $y, $text, $black);

//output the image to the browser
header ("Content-type: image/jpeg");
imagejpeg($img);

//clean up after yourself
imagedestroy($img);
?>

That should give you a good idea with it. Just simply change the $file variable to the .txt file you intend to use, and you may have to change the x and y coordinants of the string (variables $x and $y), but that should be about it for you.
As for the Winamp, I'm not sure how to do that, but if you look up that topic I guess you could figure it out and easily modify this code.
:)
Also, in order for forums to allow it, you will have to save it as file.jpg (or whatever filename you want) and then make an .htaccess file like this in the same folder (be better if you put it in its own folder instead anyways, and don't overwrite your original .htaccessof your root directory!).
<Files file.jpg>
ForceType application/x-httpd-php
</Files>

Edited by Demonslay, 24 July 2006 - 11:51 AM.


#4 jatt

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 27 July 2006 - 06:22 PM

i Alredy have the Winamp one i am not asking for a winamp one all i want is a jpg or png file on forums sig and what ever i put on my hosting server in txt file displays on the sig. like if i i wire jjj in txt file and it displayas on the jpg or png file i hope u get me what i am saying.

Can any one help me plzzzzzzzzzzzz|?

#5 Erik Bernskiold

    Jedi In Training

  • Members
  • PipPip
  • 422 posts
  • Gender:Male
  • Location:Gothenburg, Sweden
  • Interests:I love to do booth Web Design and Photography. Nothing beats a nice day out in the nature with the camera gear, getting loads of nice photos. I have been playing the flute for 6 years now and I love it, and I am playing the pipe organ as well. I also like to teach other people the in and outs of software such as the CS3 suite from Adobe.

Posted 28 July 2006 - 06:03 AM

If you look closely at the code Demonslay gave you, I belive he gave you what you asked for? He at least didn't give you a Winamp one.

#6 jatt

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 17 August 2006 - 05:39 AM

sorry i was away for while i am back now back . the thing is i have no skills at reading the code and fixing it but i will give a more help be good so i can learn better. but any ways i made a Folder name Sig on my Hosting and then i saved this code in php file named it Sig.php and then uploaded text.txt file and then a jpg file and i try opening the jpg file i don't see any thing on itand i see this errors

[17-Aug-2006 05:55:18] PHP Warning:  imagecreatefromjpeg(winampjpeg): failed to open stream: No such file or directory in /home/punjabi/public_html/sig/index.php on line 4
[17-Aug-2006 05:55:18] PHP Warning:  imagecolorresolve(): supplied argument is not a valid Image resource in /home/punjabi/public_html/sig/index.php on line 7
[17-Aug-2006 05:55:18] PHP Warning:  imagestring(): supplied argument is not a valid Image resource in /home/punjabi/public_html/sig/index.php on line 24
[17-Aug-2006 05:55:18] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/punjabi/public_html/sig/index.php:4) in /home/punjabi/public_html/sig/index.php on line 27
[17-Aug-2006 05:55:18] PHP Warning:  imagejpeg(): supplied argument is not a valid Image resource in /home/punjabi/public_html/sig/index.php on line 28
[17-Aug-2006 05:55:18] PHP Warning:  imagedestroy(): supplied argument is not a valid Image resource in /home/punjabi/public_html/sig/index.php on line 31

Edited by jatt, 17 August 2006 - 05:56 AM.


#7 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 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 17 August 2006 - 12:17 PM

They are all results of an invalid image.
You have to put the image name, and extention in the imagecreatefromjpeg() function.

If you fix that and still have errors, you'll have to show us your full code so we can help you more. ;)

#8 jatt

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 17 August 2006 - 04:34 PM

i have the image in there also i used the code u provided up there

#9 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 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 17 August 2006 - 05:24 PM

You'll have to post your entire code still, because the code I posted wouldn't produce that error, as long as the file does exist.
You should really learn how to edit and read code, as well as read errors, its just so much easier...

Quote

[17-Aug-2006 05:55:18] PHP Warning: imagecreatefromjpeg(winampjpeg): failed to open stream: No such file or directory in /home/punjabi/public_html/sig/index.php on line 4

If that was produced by the code I provided, then you didn't copy/paste right. Ohterwise my code would have produced and error like this.

Quote

[17-Aug-2006 05:55:18] PHP Warning: imagecreatefromjpeg(winamp.jpeg): failed to open stream: No such file or directory in /home/punjabi/public_html/sig/index.php on line 4

Notice the period, meaning you screwed that up most probably.
Also, make sure its in the same directory since that is a relative path in the script...

I can't seem to find your 'sig.txt' file in that directory on your site...

Edited by Demonslay, 17 August 2006 - 05:24 PM.


#10 jatt

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 17 August 2006 - 06:03 PM

<?php	
//create image
//use existing image as a canvas
$img = imagecreatefromjpeg(winamp.jpeg);

//allocate the color black
$black = imagecolorresolve($img, 0, 0, 0);

//set the text file to be used
$file = 'text.txt';
//open the text file
$fp = fopen($file, rt);
//read the text file and store to the $text variable
$text = fread($fp, 1024);
//close file
fclose($fp);

//set x coordinant of the string
$x = 70;
//set y coordinant of the string
$y = 20;

//write the string in the white space of the signature
imagestring($img, 5, $x, $y, $text, $black);

//output the image to the browser
header ("Content-type: image/jpeg");
imagejpeg($img);

//clean up after yourself
imagedestroy($img);
?>
this is the code and i rename the file to index.php

#11 zetsumei

    Young Padawan

  • Publishing Betazoids
  • Pip
  • 269 posts
  • Gender:Male
  • Location:127.0.0.1

Posted 17 August 2006 - 06:22 PM

i do know this...i dont think it should be winamp.jpeg try making it winamp.jpg XD...

#12 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 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 17 August 2006 - 06:25 PM

Opps! Just realized the problem.

$img = imagecreatefromjpeg(winamp.jpeg);

I forgot to make it a string, haha. :heh:

Just replace that line with this line and it'll work (I already tested it with your image, and you might want to clear that white space where the text is for this, and take the vairble $y down to about 5 or so).
$img = imagecreatefromjpeg('winamp.jpeg');

Should really learn PHP yourself bub, or you could have easily noticed that one...

And .jpg wouldn't work zet, JPEG and JPG have the same MIME type, but are completely different files!

Edited by Demonslay, 17 August 2006 - 06:27 PM.


#13 jatt

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 17 August 2006 - 07:36 PM

View PostDemonslay, on Aug 18 2006, 12:25 AM, said:

Opps! Just realized the problem.

$img = imagecreatefromjpeg(winamp.jpeg);

I forgot to make it a string, haha. :heh:

Just replace that line with this line and it'll work (I already tested it with your image, and you might want to clear that white space where the text is for this, and take the vairble $y down to about 5 or so).
$img = imagecreatefromjpeg('winamp.jpeg');

Should really learn PHP yourself bub, or you could have easily noticed that one...

And .jpg wouldn't work zet, JPEG and JPG have the same MIME type, but are completely different files!
wow thx i was reading the code and i saw that part but did't wanted to say cuz i did't wante to get flamed by 200 pro users calling me noob :blink: but thx this relly work i will work on the image and if i need help i will come and ask u guys. thx again.

#14 Wybe

    Jedi In Training

  • Members
  • PipPip
  • 399 posts
  • Gender:Male
  • Location:the Netherlands
  • Interests:Graphic design, digital and traditional, street style, graffiti, guerilla drawing, typography, coding, sex

Posted 18 August 2006 - 05:05 AM

lol you could have tried to change it jatt and you would have seen you were right. but you didn't.

#15 jatt

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 25 August 2006 - 04:08 PM

ok i still need some help the codin works fine. here is the link to the Dir
http://www.desipeeps.com/sig/ and link of the image http://www.desipeeps...sig/winamp.jpeg the thing is i can't see anything on the image also how can i make the line 2 at the bottom of line 1

#16 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 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 25 August 2006 - 04:24 PM

Lol dude, that's because you are writing black text on a black background. Duh. :P
If you are using a black background and need white text, simply replace this line:
$black = imagecolorresolve($img, 0, 0, 0);
To this:
$white = imagecolorresolve($img, 255, 255, 255);
And this line:
imagestring($img, 5, $x, $y, $text, $black);
To this:
imagestring($img, 5, $x, $y, $text, $white);

As for making lines, unfortunetly I don't believe you can make a line break in an image. If you could, it would be with "\n" and such, but I doubt you can.
You'd need to align it right and make a new line like this.
//set x coordinant of the second string
$x2 = 70;
//set y coordinant of the second string
$y2 = 28;
imagestring($img, 5, $x2, $y2, $text, $white);

Of course you have to take into account the actual size of your font and how much space you want between your lines, but just keep adjusting the coordinants and you'll figure it out.

#17 jatt

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 27 August 2006 - 05:30 AM

i have't chaged any of the coding but u still can see it won't show up on the image i updated the image with White background. and click on the sig link and ull see it

#18 jatt

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 29 August 2006 - 02:18 PM

any 1??/





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users