Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Dynamic Gd Image
Normano
post May 9 2008, 08:32 PM
Post #1


Member [ Level 1 ]
Group Icon

Group: [HOSTED]
Posts: 36
Joined: 28-August 07
Member No.: 24,433



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
CODE
<?php

and end with
CODE
?>

to make a image you need a image type, I choos .png because its much cleaner then .jpg
CODE
header("Content-type: image/png");

for the background for the image we need this code
CODE
$image = imagecreatefrompng("http://www.imagefilez.com/out.php/i252132_Userbar.png");

if we wont a text in the image we need a font color, we get our font color from HEX values
CODE
$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
CODE
$string = $_GET["text"];

then
CODE
imagestring($image, 2, 12, 3, "Ice Fury", $font_white);
imagestring($image, 2, 84, 3, $string, $font_white);

to save space we use this code
CODE
imagepng($image);
imagedestroy($image);

when we finnish the code should look like this
CODE
<?php
header("Content-type: image/png");

$image = imagecreatefrompng("http://www.imagefilez.com/out.php/i252132_Userbar.png");

$font_white = imagecolorallocate($image, 255, 255, 255);

$string = $_GET["text"];

//($image, fontsize, rightindent, downindent, data, txtcolour)
imagestring($image, 2, 12, 3, "GD", $font_white);
imagestring($image, 2, 84, 3, $string, $font_white);  

imagepng($image);
imagedestroy($image);

?>

path to file "../image.php?text=hello" now is hello writed on the image

Hope you like it biggrin.gif

This post has been edited by Normano: May 9 2008, 08:33 PM
Go to the top of the page
 
+Quote Post
TavoxPeru
post May 11 2008, 11:00 AM
Post #2


Super Member
Group Icon

Group: [HOSTED]
Posts: 763
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579



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,

This post has been edited by TavoxPeru: May 11 2008, 11:35 AM
Go to the top of the page
 
+Quote Post
Normano
post May 13 2008, 07:05 PM
Post #3


Member [ Level 1 ]
Group Icon

Group: [HOSTED]
Posts: 36
Joined: 28-August 07
Member No.: 24,433



QUOTE(TavoxPeru @ May 11 2008, 01:00 PM) *
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
CODE
RewriteEngine On
RewriteRule ^([^/]*)\.png$ /path to file/gd.php?text=$1 [L]

now the you can come to ur generated image with this url .../yourtext.png
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Php: Write Random Text As Image(3)
  2. Is It Possible To Create A String Image In Chinese(0)
  3. Saving A Php Generated Image To The Server(5)
  4. How Do I Make PHP Based Image Gallery Like This?(20)
  5. Uploading Image Via Admin Menu?(2)
  6. Dynamic Site Design - Where Do I Start ?(7)
  7. How Do I Resize An Image On The Fly?(8)
  8. Script For Viewing A Random Image Needed(3)
  9. Php :: Adding Image Over Image(5)
  10. Image Works With Php And Gd(3)
  11. Php :: Image Pixel Per Inch And Conversion(1)
  12. Need Help With Background Image...(12)
  13. Image Popup On Mouseover(23)
  14. Dynamic Php Image And Better Php Code Question(10)


 



- Lo-Fi Version Time is now: 13th October 2008 - 01:14 AM