TheSky Posted April 19, 2011 Share Posted April 19, 2011 Hey i got one problem i want add background how i should make it any help will be welcome <?php //source file $file = "test.txt"; //images size $high = "200"; $wide = "400"; //generate image $data = file($file); $im = @ imagecreate($wide, $high) or die("Error"); $bc = imagecolorallocate($im, 255, 255, 255); $tc = imagecolorallocate($im, 0, 0, 0); $lines = (int) $high / 10; for ($t = 0; $t < $lines; $t++) { imagestring($im, 3, 4, 4, $data[$t], $tc); imagestring($im, 3, 4, 4 + ($t * 10), $data[$t], $tc); } //header("Content-type: image/png"); //imagepng($im); imagepng($im,"pildid/1.png"); imagedestroy($im); ?> Quote Link to comment https://forums.phpfreaks.com/topic/234165-how-to-add-background/ Share on other sites More sharing options...
drisate Posted April 19, 2011 Share Posted April 19, 2011 <?php $img = imagecreatetruecolor($x, $y); $bgColor = imagecolorallocate($img, 255,255,255); imagefilledrectangle($img, 0, 0, $x-1, $y-1, $bgColor); ?> Thats how i do it Quote Link to comment https://forums.phpfreaks.com/topic/234165-how-to-add-background/#findComment-1203572 Share on other sites More sharing options...
TheSky Posted April 20, 2011 Author Share Posted April 20, 2011 so 255 is color codex ? $bgColor = imagecolorallocate($img, 255,255,255); Quote Link to comment https://forums.phpfreaks.com/topic/234165-how-to-add-background/#findComment-1203860 Share on other sites More sharing options...
TheSky Posted April 20, 2011 Author Share Posted April 20, 2011 so basicaly i want add to image background + i dont know how i can explain better, any help will be welcome Quote Link to comment https://forums.phpfreaks.com/topic/234165-how-to-add-background/#findComment-1203881 Share on other sites More sharing options...
drisate Posted April 20, 2011 Share Posted April 20, 2011 For most web purposes, you can usually design the basic background of your image using a normal image editor like Photoshop and only add any additional text or graphical elements that need to be dynamically drawn using PHP. This allows you to speed up your scripts and reduce the resource consumption on your web server. It also lets you create your picture using professional picture designing tools. imagecreatefromgif ( $filename ); // Background is a gif imagecreatefromjpeg ( $filename ); // Background is a jpg imagecreatefrompng ( $filename ); // Background is a png Quote Link to comment https://forums.phpfreaks.com/topic/234165-how-to-add-background/#findComment-1203957 Share on other sites More sharing options...
kansasakki Posted April 20, 2011 Share Posted April 20, 2011 I used this tutorial to get an example of how to do something very similar to what you are asking. http://www.phpfreaks.com/tutorial/php-add-text-to-image This allowed me some basics I needed and i ran with it from there. Kansas Quote Link to comment https://forums.phpfreaks.com/topic/234165-how-to-add-background/#findComment-1204036 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.