Post: [Tut] Dynamic Php Image [Tut][Code Commented]
10-07-2011, 09:44 PM #1
ColdPatch
Nom!Nom!Nom!
(adsbygoogle = window.adsbygoogle || []).push({});
As Alot of you know, i posted a image which was a .php file, those are called Dynamic Php images.
I decided To Show You, Step by step how to do a simple one!


Step 1:
Intailaizing The Variables
    
//The Canvas for our dynamic image!
//It is set 250x60
$img = imagecreate( 250, 60 );
//The color's are in rgb converted to hex.
$background = imagecolorallocate( $img, 102, 102, 102 );
$textcolour = imagecolorallocate( $img, 85, 238, 170 );
$linecolour = imagecolorallocate( $img, 128, 255, 0 );


Step 2:
Drawing Basic Text
     
//Prints The Text ColdPatch Says:
imagestring( $img, 4, 4, 4, "ColdPatch Says:",
$text_colour );
//Prints The Text Hello NGU
imagestring( $img, 4, 30, 25, "Hello NGU",
$textcolour );


Step 3:
Drawing the Line
    
//Sets The Thickness Of the Line
imagesetthickness ( $img, 5 );
//Draws the Line
imageline( $img, 30, 45, 220, 45, $linecolour );


Step 4:
The Finishing Touch
    
//Sets The header to by the image.
header( "Content-type: image/png" );
//Draws The image
imagepng( $img );
//Locates The Colors.
imagecolordeallocate( $linecolor );
imagecolordeallocate( $textcolor );
imagecolordeallocate( $background );
//Makes Sure Image Gets Deleted to prevents vps/host crashs(rarely).
imagedestroy( $my_img );


If This Is To Be Used, Please be kind, and give me credit, Also, This can be treated as auto-updating because [img] tags support dynamic images you can auto update code, therefore update image, Here is a example: You must login or register to view this content.

Inb4 Anyone trashs the thread, theat isnt the dynamic image i coded that logs ips.

(adsbygoogle = window.adsbygoogle || []).push({});

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo