Welcome and enjoy!
Intro:
Since I don't have enough Posts to update my signature, I've decided to show you how to create dynamic signature with PHP
Requirements:
Functions:
Let us start writing our PHP file.
I've named mine image.php, you can name yours different.
We start first with defining the width and height of the image.
I've set my image width to 450 pixel and height to 70 pixel.
Now we use the function imagecreate() to create our image.
imagecreate() accepts 2 parameters
1st = width of the image, 2nd = height of the image.
Next we will define Background color for the image.
imagecolorallocate() accept 4 parameters
1st = image resource that was create with the imagecreate() function.
2nd/3rd/4th are the RGB color value paramter
Now that we have the basic of our image let us add some text to it.
$text_color is defined by the imagecolorallocate() function.
The function imagestring() accept 6 parameters.
1st = image resource that was create with imagecreate()
2nd = the font size
3rd = Left - distance from the left side of the image wich I've set to 10 pixel
4th = Top - distance from the top side of the image wich is also 10 pixel
5th = Text to add
6th = text color
And the last step is to define our content as image.
With header() we define Content-type as PNG image.
imagepng() is then used to output given resource.
imagepng() accept 4 parameters
1st = image resource that was created with imagecreate()
2nd = This one is optional and is used to set the path and file name of the image - value must be string
3rd = Is also optional and it is used to define image compression quality from 0 = none - to 9 = Best
4th = filters - allows reducing the image size
Read More:
GD Docs
imagedestroy()
imagecreatetruecolor()
imagegif()
imageellipse()
Thank you for reading!
Intro:
Since I don't have enough Posts to update my signature, I've decided to show you how to create dynamic signature with PHP
Demo Wrote:
The day number is updated on every load.
Try refreshing the page and look at the time in the right bottom corner
Requirements:
- Basic understanding of PHP and it's Syntax.
- GD Library enabled Server
- And time to read the more...
Functions:
Let us start writing our PHP file.
I've named mine image.php, you can name yours different.
We start first with defining the width and height of the image.
PHP Code:
$width = 450;
$height = 70;
Now we use the function imagecreate() to create our image.
PHP Code:
$image = imagecreate($width, $height);
1st = width of the image, 2nd = height of the image.
Next we will define Background color for the image.
PHP Code:
$background = imagecolorallocate($image, 87, 87, 87);
1st = image resource that was create with the imagecreate() function.
2nd/3rd/4th are the RGB color value paramter
Now that we have the basic of our image let us add some text to it.
PHP Code:
$text = "I hope this will not get new Hackforums";
$text_color = imagecolorallocate($image, 176, 176, 176);
imagestring($image, 10, '10', '10', $text, $text_color);
The function imagestring() accept 6 parameters.
1st = image resource that was create with imagecreate()
2nd = the font size
3rd = Left - distance from the left side of the image wich I've set to 10 pixel
4th = Top - distance from the top side of the image wich is also 10 pixel
5th = Text to add
6th = text color
And the last step is to define our content as image.
PHP Code:
header ("Content-type: image/png");
imagepng($image);
imagepng() is then used to output given resource.
imagepng() accept 4 parameters
1st = image resource that was created with imagecreate()
2nd = This one is optional and is used to set the path and file name of the image - value must be string
3rd = Is also optional and it is used to define image compression quality from 0 = none - to 9 = Best
4th = filters - allows reducing the image size
Read More:
GD Docs
imagedestroy()
imagecreatetruecolor()
imagegif()
imageellipse()
Source (Click to View)
Thank you for reading!