
Need GD function
- sanis
- New member
- Posts: 21
- Joined: 26 Sep 2006, 17:00
- Location: Lithuania / Kaunas / Romaniai
Need GD function
I need GD function how to add image on image ;P because i am going to make a huge smile and sig generator site
any ideas how to add image on image? :money:

http://stotis.net my forum 

- igorw
- Past Contributor
- Posts: 1967
- Joined: 01 Jun 2006, 20:48
- Real name: Igor
This is a script i made once. I hope it helps you 
[php]<?php
// Set size
$sizex = '200';
$sizey = '30';
// Set positions
$posx = '10';
$posy = '29';
$text = $_SERVER['REMOTE_ADDR'];
$fonts_path = './fonts/'
// Replace path by your own font path
//$font = $counter_root . 'fonts/TRASHED.ttf';
$font = $fonts_path . 'UnrealT.ttf';
// Output
// Set the content-type
header('Content-type: image/png');
// Create the image
$im = imagecreatetruecolor($sizex, $sizey);
// Decrement sizes
$sizex--;
$sizey--;
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, $sizex, $sizey, $white);
// Add some shadow to the text
//imagettftext($im, 20, 0, $posx+1, $posy+1, $grey, $font, $text);
// Add the text
imagettftext($im, 20, 0, $posx, $posy, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>[/php]

[php]<?php
// Set size
$sizex = '200';
$sizey = '30';
// Set positions
$posx = '10';
$posy = '29';
$text = $_SERVER['REMOTE_ADDR'];
$fonts_path = './fonts/'
// Replace path by your own font path
//$font = $counter_root . 'fonts/TRASHED.ttf';
$font = $fonts_path . 'UnrealT.ttf';
// Output
// Set the content-type
header('Content-type: image/png');
// Create the image
$im = imagecreatetruecolor($sizex, $sizey);
// Decrement sizes
$sizex--;
$sizey--;
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, $sizex, $sizey, $white);
// Add some shadow to the text
//imagettftext($im, 20, 0, $posx+1, $posy+1, $grey, $font, $text);
// Add the text
imagettftext($im, 20, 0, $posx, $posy, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>[/php]
- sanis
- New member
- Posts: 21
- Joined: 26 Sep 2006, 17:00
- Location: Lithuania / Kaunas / Romaniai
Return to “General Discussion”
Who is online
Users browsing this forum: CommonCrawl [Bot] and 17 guests