[PHP] Dynamic image help |
Author: |
Message: |
Luigi
Full Member
It's-a me! Luigi!
Posts: 221 Reputation: 4
– / /
Joined: Sep 2005
|
O.P. [PHP] Dynamic image help
I've nevere scripted in php, but I always wanted to learn, now I decided to start doing something serious: the problem is that I think it's TOO serious for me
However, here's what I would like to do:
I would like a php dynamic signature and I searched for some tutorial with google, but I didn't find anything.
I would like to know how to get a text from a file (reading for example line 1 and write it at x,y; then read line 3 and write it at x2,y2) and drawing it over the image, possibly using a specific ttf font (uploaded on the web space, of course).
Thanks in advantege
Edit: got imagettftext, this is the command for writing thext, I think (Genius Inside )
This post was edited on 01-31-2006 at 06:55 PM by Luigi.
|
|
01-31-2006 06:48 PM |
|
|
L. Coyote
Senior Member
Captain Obvious
Posts: 981 Reputation: 49
39 / /
Joined: Aug 2004
Status: Away
|
RE: [PHP] Dynamic image help
You can read all about image functions at the PHP manual.
There are many tutorials out there that explain how to do this. A simple search for php "dynamic images" tutorial got me a lot of good articles.
However, I'd suggest you learn the language first. Going for a script like this without knowing the basic language structure is like trying to write a book in Chinese without having studied it.
Hack, hack, hack!
Finally became a Systems Analyst!
|
|
01-31-2006 07:42 PM |
|
|
Luigi
Full Member
It's-a me! Luigi!
Posts: 221 Reputation: 4
– / /
Joined: Sep 2005
|
O.P. RE: [PHP] Dynamic image help
Yes I know it will be very difficult, but I started like this when I decided to learn mIRC scripting, it will take some weeks, but I like the hard way
Thanks for the help
|
|
01-31-2006 07:46 PM |
|
|
hmaster
Senior Member
Posts: 716 Reputation: 24
33 / /
Joined: Nov 2004
|
RE: [PHP] Dynamic image help
To read specific lines from a file, you can use something like
code: $file = file('pathtoyourfile.txt');
$line1 = $fiile[0];
$line3 = $file[2];
Then use imagettftext to add the text in each position. You can specify the font, x and y positions in that tag.
Maybe not.
This post was edited on 02-01-2006 at 08:58 PM by hmaster.
|
|
01-31-2006 08:10 PM |
|
|
Luigi
Full Member
It's-a me! Luigi!
Posts: 221 Reputation: 4
– / /
Joined: Sep 2005
|
O.P. RE: RE: [PHP] Dynamic image help
Ok, I'm getting something now
It creates the empty blue image, and then loads the png I've made, but then it doesn't write any text.
Here's the code I used:
code: $white = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);
$green = imagecolorallocate($im, 0, 255, 0);
$black = imagecolorallocate($im, 0, 0, 0);
// Font
$font == "visitor.ttf";
$text == "Hello World";
// Drawing text
imagettftext($im, 12, 0, 10, 20, $white, $font, $text);
Any idea?
(Edit: Here's the image)
SOLVED: == instead of =, damn mIRC scripting
This post was edited on 01-31-2006 at 08:32 PM by Luigi.
|
|
01-31-2006 08:25 PM |
|
|
-dt-
Scripting Contest Winner
;o
Posts: 1819 Reputation: 74
36 / /
Joined: Mar 2004
|
RE: [PHP] Dynamic image help
quote: Originally posted by hmaster
To read specific lines from a file, you can use something like
code: $file = file('pathtoyourfile.txt');
$line1 = $fiile[0];
$line3 = $file[2];
Then use imagettftext to add the text in each position. You can specify the font, x and y positions in that tag.
You'll need fopen wrappers or whatever enabled.
why do you need fopen wrappers enabled to read from a localfile? .... fopen wrappers are what let you access urls like files. they dont disable local file reading.
Happy Birthday, WDZ
|
|
02-01-2006 02:00 AM |
|
|
Luigi
Full Member
It's-a me! Luigi!
Posts: 221 Reputation: 4
– / /
Joined: Sep 2005
|
O.P. RE: [PHP] Dynamic image help
Thanks to all for the help, I've done something good, but now I'm blocked here.
blah.org/gne.php?number=1.txt
my php read the first line of the file 1.txt (that is the name of an image) and it SHOULD load that image and put it on the file, here's the code I used:
code: $file = file($_GET[number]);
$ua = imagecreatefrompng($file[0]);
$uswidth = imagesx($ua);
$usheight = imagesy($ua);
imagecopy($im, $ua, 5, 2, 0, 0, $uswidth, $usheight);
(im is already defined)
but it doesn't return any image.
Is this because when it reads the first line, it gets image.png(return)?
And another problem I have, is that it doesn't show any text using the imagettftext, could it be because I'm loading 2 images ($im, and then $ua)?
code: $font = "/wp-content/visitor.ttf";
$white = imagecolorallocate($im, 255, 255, 255);
imagettftext($im, 10, 0, 55, 5, $white, $font, 'blah blah blah');
Thanks
|
|
02-01-2006 07:47 PM |
|
|
hmaster
Senior Member
Posts: 716 Reputation: 24
33 / /
Joined: Nov 2004
|
RE: [PHP] Dynamic image help
quote: Originally posted by -dt-
why do you need fopen wrappers enabled to read from a localfile? .... fopen wrappers are what let you access urls like files. they dont disable local file reading.
woops my bad!
quote: Originally posted by Luigi
Thanks to all for the help, I've done something good, but now I'm blocked here.
blah.org/gne.php?number=1.txt
my php read the first line of the file 1.txt (that is the name of an image) and it SHOULD load that image and put it on the file, here's the code I used:
code: $file = file($_GET[number]);
$ua = imagecreatefrompng($file[0]);
$uswidth = imagesx($ua);
$usheight = imagesy($ua);
imagecopy($im, $ua, 5, 2, 0, 0, $uswidth, $usheight);
(im is already defined)
but it doesn't return any image.
Is this because when it reads the first line, it gets image.png(return)?
And another problem I have, is that it doesn't show any text using the imagettftext, could it be because I'm loading 2 images ($im, and then $ua)?
code: $font = "/wp-content/visitor.ttf";
$white = imagecolorallocate($im, 255, 255, 255);
imagettftext($im, 10, 0, 55, 5, $white, $font, 'blah blah blah');
Thanks
Try with the apostrophes $_GET['number']
|
|
02-01-2006 08:57 PM |
|
|
Luigi
Full Member
It's-a me! Luigi!
Posts: 221 Reputation: 4
– / /
Joined: Sep 2005
|
O.P. RE: [PHP] Dynamic image help
Nothing changes
|
|
02-02-2006 07:53 PM |
|
|
|
|