What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » [PHP] Dynamic image help

[PHP] Dynamic image help
Author: Message:
Luigi
Full Member
***

Avatar
It's-a me! Luigi!

Posts: 221
Reputation: 4
– / Male / Flag
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 :P
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 :O (Genius Inside :P )

This post was edited on 01-31-2006 at 06:55 PM by Luigi.
[Image: caffe.gif]
[Image: italia.jpg] StuffPlug-NG & A-Patch Official Italian Translator, Messenger Plus! Live Beta Tester.
www.barbagianni.net - http://www.messengeritalia.it
01-31-2006 06:48 PM
Profile PM Web Find Quote Report
L. Coyote
Senior Member
****

Avatar
Captain Obvious

Posts: 981
Reputation: 49
39 / Male / Flag
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! :spam:

01-31-2006 07:42 PM
Profile PM Find Quote Report
Luigi
Full Member
***

Avatar
It's-a me! Luigi!

Posts: 221
Reputation: 4
– / Male / Flag
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 :D
Thanks for the help ;)
[Image: caffe.gif]
[Image: italia.jpg] StuffPlug-NG & A-Patch Official Italian Translator, Messenger Plus! Live Beta Tester.
www.barbagianni.net - http://www.messengeritalia.it
01-31-2006 07:46 PM
Profile PM Web Find Quote Report
hmaster
Senior Member
****

Avatar

Posts: 716
Reputation: 24
33 / Male / Flag
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.
[Image: sig.png]
01-31-2006 08:10 PM
Profile PM Web Find Quote Report
Luigi
Full Member
***

Avatar
It's-a me! Luigi!

Posts: 221
Reputation: 4
– / Male / Flag
Joined: Sep 2005
O.P. RE: RE: [PHP] Dynamic image help
Ok, I'm getting something now :D
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 :D

This post was edited on 01-31-2006 at 08:32 PM by Luigi.
[Image: caffe.gif]
[Image: italia.jpg] StuffPlug-NG & A-Patch Official Italian Translator, Messenger Plus! Live Beta Tester.
www.barbagianni.net - http://www.messengeritalia.it
01-31-2006 08:25 PM
Profile PM Web Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
36 / Male / Flag
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.
[Image: dt2.0v2.png]      Happy Birthday, WDZ
02-01-2006 02:00 AM
Profile PM Web Find Quote Report
Luigi
Full Member
***

Avatar
It's-a me! Luigi!

Posts: 221
Reputation: 4
– / Male / Flag
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 :)
[Image: caffe.gif]
[Image: italia.jpg] StuffPlug-NG & A-Patch Official Italian Translator, Messenger Plus! Live Beta Tester.
www.barbagianni.net - http://www.messengeritalia.it
02-01-2006 07:47 PM
Profile PM Web Find Quote Report
hmaster
Senior Member
****

Avatar

Posts: 716
Reputation: 24
33 / Male / Flag
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']
[Image: sig.png]
02-01-2006 08:57 PM
Profile PM Web Find Quote Report
Luigi
Full Member
***

Avatar
It's-a me! Luigi!

Posts: 221
Reputation: 4
– / Male / Flag
Joined: Sep 2005
O.P. RE: [PHP] Dynamic image help
Nothing changes :(
[Image: caffe.gif]
[Image: italia.jpg] StuffPlug-NG & A-Patch Official Italian Translator, Messenger Plus! Live Beta Tester.
www.barbagianni.net - http://www.messengeritalia.it
02-02-2006 07:53 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On