phpmady Posted August 31, 2010 Share Posted August 31, 2010 Hi, I have a project, where i want to place a text over the image dynamically, just like if it is sold, i want to make it as SOLD text over the image Looking for idea to implement this, Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/212219-placing-a-text-over-on-image/ Share on other sites More sharing options...
RussellReal Posted September 1, 2010 Share Posted September 1, 2010 imagecopymerge just make 1 sold image.. when it gets sold.. create the image and display that image instead of the first one.. unless you want to add the "sold" like ontop of the image (in html - layered) in which case.. you can just set a div with the image as it's backgound.. and with javascript display "SOLD" Quote Link to comment https://forums.phpfreaks.com/topic/212219-placing-a-text-over-on-image/#findComment-1105880 Share on other sites More sharing options...
Onloac Posted September 1, 2010 Share Posted September 1, 2010 If you want to place text dynamically over a image you could use the below code I found through google. <?php //PHP's GD class functions can create a variety of output image //types, this example creates a jpeg header("Content-Type: image/jpeg"); //open up the image you want to put text over $im = ImageCreateFromGif("template.gif"); //The numbers are the RGB values of the color you want to use $black = ImageColorAllocate($im, 255, 255, 255); //The canvas's (0,0) position is the upper left corner //So this is how far down and to the right the text should start $start_x = 10; $start_y = 20; //This writes your text on the image in 12 point using verdana.ttf //For the type of effects you quoted, you'll want to use a truetype font //And not one of GD's built in fonts. Just upload the ttf file from your //c: windows fonts directory to your web server to use it. Imagettftext($im, 12, 0, $start_x, $start_y, $black, 'verdana.ttf', "text to write"); //Creates the jpeg image and sends it to the browser //100 is the jpeg quality percentage Imagejpeg($im, '', 100); ImageDestroy($im); ?> All you gotta do is provide the image, upload your font of choice, and change the text variable. Quote Link to comment https://forums.phpfreaks.com/topic/212219-placing-a-text-over-on-image/#findComment-1106010 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.