php code Sig
#1
Posted 24 July 2006 - 03:56 AM
#2
Posted 24 July 2006 - 04:41 AM
#3
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
Posted 27 July 2006 - 06:22 PM
Can any one help me plzzzzzzzzzzzz|?
#5
Posted 28 July 2006 - 06:03 AM
#6
Posted 17 August 2006 - 05:39 AM
[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
Posted 17 August 2006 - 12:17 PM
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
Posted 17 August 2006 - 04:34 PM
#9
Posted 17 August 2006 - 05:24 PM
You should really learn how to edit and read code, as well as read errors, its just so much easier...
Quote
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
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
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
Posted 17 August 2006 - 06:22 PM
#12
Posted 17 August 2006 - 06:25 PM
$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
Posted 17 August 2006 - 07:36 PM
Demonslay, on Aug 18 2006, 12:25 AM, said:
$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!
#14
Posted 18 August 2006 - 05:05 AM
#15
Posted 25 August 2006 - 04:08 PM
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
Posted 25 August 2006 - 04:24 PM
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
Posted 27 August 2006 - 05:30 AM
#18
Posted 29 August 2006 - 02:18 PM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
