Jump to content
xisto Community
Normano

Dynamic Gd Image

Recommended Posts

I dont know if someone already made a topic like this, however it's not hard to understand if you can php,

as many know we need to start a php script with

<?php
and end with

?>
to make a image you need a image type, I choos .png because its much cleaner then .jpg

header("Content-type: image/png");
for the background for the image we need this code

$image = imagecreatefrompng("http://forums.xisto.com/no_longer_exists/404.png
if we wont a text in the image we need a font color, we get our font color from HEX values

$font_white = imagecolorallocate($image, 255, 255, 255);
if u wont a text that can bee changes when the file is created and dont wont to open the file use this

$string = $_GET["text"];
then

imagestring($image, 2, 12, 3, "Ice Fury", $font_white);imagestring($image, 2, 84, 3, $string, $font_white);
to save space we use this code

imagepng($image);imagedestroy($image);
when we finnish the code should look like this

<?phpheader("Content-type: image/png");$image = imagecreatefrompng("http://forums.xisto.com/no_longer_exists/404.png
path to file "../image.php?text=hello" now is hello writed on the image

 

Hope you like it :(

Edited by Normano (see edit history)

Share this post


Link to post
Share on other sites

Thanks for this simple and easy to follow code, i'm sure it would help to someone, i just test it and works fine (EDIT: It works fine only when i use an image located on my domain instead of yours.)Is it possible that the generated image includes hyperlinks with the text??? If it is true how you can do it???What kind of security problems we can get???Best regards,

Edited by TavoxPeru (see edit history)

Share this post


Link to post
Share on other sites

Thanks for this simple and easy to follow code, i'm sure it would help to someone, i just test it and works fine (EDIT: It works fine only when i use an image located on my domain instead of yours.)
Is it possible that the generated image includes hyperlinks with the text??? If it is true how you can do it???

What kind of security problems we can get???

Best regards,

You can't hyperlink generated images because its a png file, in some forums it not allowable to ahve .php generated images files, put a ".htaccess" file in the directory with this code
RewriteEngine OnRewriteRule ^([^/]*)\.png$ /path to file/gd.php?text=$1 [L]
now the you can come to ur generated image with this url .../yourtext.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.