Honesty Rocks! truth rules.

Dynamic Gd Image

HOME      >>       Programming

Normano

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 :(


TavoxPeru

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,


Normano

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