GDI+ PHP with existing image

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mmondragon
Forum Newbie
Posts: 9
Joined: Fri Mar 17, 2006 12:37 am

GDI+ PHP with existing image

Post by Mmondragon »

hi everyone, i have a project right now, it's some kind of approval system. i have scanned signatures already of our directors/ officers. my question is that i want to make it secure that it can't be download by others and also to have some kind of embedded randomly-generated alphanumeric strings on that image. meaning if someone copies the image for his own purpose i can verify that it is not system generated because it does not contain any randomly-generated alphanumeric strings. is this possible with GDI+ or any php function? i am thinking like CAPTCHA it has some kind of distorted images, right? but somehow it does have the same concept, the only diff. is i do have an existing image, what i want is to embed the randomly-generated alphanumeric strings into it...

thanks in advance!
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

I'll have to re-read your message tomorrow as I'm dead tired and just finished writing my life story :P

But...

GDI+ is a Windows only library (that I know of) and would require dealing with the Windows API more specifically .NET

Not exactly what PHP was made for...but I'll read this again tomorrow and see if I can offer a better solution...

Cheers :)
Mmondragon
Forum Newbie
Posts: 9
Joined: Fri Mar 17, 2006 12:37 am

Post by Mmondragon »

Hockey wrote:I'll have to re-read your message tomorrow as I'm dead tired and just finished writing my life story :P

But...

GDI+ is a Windows only library (that I know of) and would require dealing with the Windows API more specifically .NET

Not exactly what PHP was made for...but I'll read this again tomorrow and see if I can offer a better solution...

Cheers :)
i'm sorry, i think i have mistaken the term GDI+ and the GD library. it's GD library or what we called image function in php to manipulate images. thanks!
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

When you say you want to "embed the randomly-generated alphanumeric strings into" the image, do you mean drawing text on the image, or putting the string into the jpeg file?
Mmondragon
Forum Newbie
Posts: 9
Joined: Fri Mar 17, 2006 12:37 am

Post by Mmondragon »

onion2k wrote:When you say you want to "embed the randomly-generated alphanumeric strings into" the image, do you mean drawing text on the image, or putting the string into the jpeg file?
yes sir, that's correct! thanks!
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Umm.. that was an either or question. "Yes" isn't a valid answer. Do you want to:

1. Modify the image to add a string so that it can been seen when you view the image.

OR

2. Modify the file to add a string so you can check for the string by opening the file in a text editor.
Mmondragon
Forum Newbie
Posts: 9
Joined: Fri Mar 17, 2006 12:37 am

Post by Mmondragon »

onion2k wrote:Umm.. that was an either or question. "Yes" isn't a valid answer. Do you want to:

1. Modify the image to add a string so that it can been seen when you view the image.

OR

2. Modify the file to add a string so you can check for the string by opening the file in a text editor.
ok, here it is, what i want is to "probably modify the image" to populate my random-generated strings into it. like in CAPTCHA? somehow there's an image, but at the background there is some kind of pseudo-string, sort of....
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

Basically you want to use a specified background image and write text on top of that?
Mmondragon
Forum Newbie
Posts: 9
Joined: Fri Mar 17, 2006 12:37 am

Post by Mmondragon »

GeXus wrote:Basically you want to use a specified background image and write text on top of that?
yes! for example i have our boss signature saved in a directory, now the generated random-string "00007847484" will be at the background of it.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Pretty easy then. Just create an image using imagecreate() or imagecreatetruecolor(), draw the text on using imagestring(), and then use imagecopy() or imagecopymerge() to copy the signature image. You'll need to be make sure your signature image is good quality, and preferably a 32bit PNG file so you can have transparency, but it's a very straight forward thing to do.

I wrote an article for phpgd.com that details the major steps: http://www.phpgd.com/articles.php?article=5
Post Reply