thecase Posted November 19, 2010 Share Posted November 19, 2010 Hi, Im trying to create text over an image and ive tried this on alot of other GD functions, all GD is doing is stopping the rest of the site from running and converting the sites url to a gd image which the script is not telling it to do, anyone know why Thanks Quote Link to comment https://forums.phpfreaks.com/topic/219248-gd-help/ Share on other sites More sharing options...
.josh Posted November 19, 2010 Share Posted November 19, 2010 can't tell you what's wrong with your code if you don't show it. But it sounds like you are outputting the raw image instead of saving it to a file. Anyways, there is a tut on the main site about adding text to images. Quote Link to comment https://forums.phpfreaks.com/topic/219248-gd-help/#findComment-1136960 Share on other sites More sharing options...
thecase Posted November 19, 2010 Author Share Posted November 19, 2010 Code I found around the web header("Content-Type: image/jpeg"); $im = ImageCreateFromGif("images/crimbo.gif"); $black = ImageColorAllocate($im, 255, 255, 255); $start_x = 10; $start_y = 20; Imagettftext($im, 12, 0, $start_x, $start_y, $black, 'verdana.ttf', "test text"); Imagejpeg($im, '', 100); ImageDestroy($im); Quote Link to comment https://forums.phpfreaks.com/topic/219248-gd-help/#findComment-1136971 Share on other sites More sharing options...
.josh Posted November 19, 2010 Share Posted November 19, 2010 soo...did you actually look at your code and research what it is actually doing? Just as I suspected, you are outputting a raw image as a response (making a call with header() to tell the browser the data is raw image data) and then in Imagejpeg() you are outputting the raw image data instead of saving it to a file. So what happens is when you make a request to the server for that script, it will respond with a raw image. So how are you trying to call this script for the rest of your site? Because as it stands now, you can do something like <img src='path/to/your/script.php' width='100' height='100' /> and your script will generate and return the image to be used in a normal html tag. Quote Link to comment https://forums.phpfreaks.com/topic/219248-gd-help/#findComment-1136979 Share on other sites More sharing options...
thecase Posted November 19, 2010 Author Share Posted November 19, 2010 Im new to GD so not really sure what it all means Quote Link to comment https://forums.phpfreaks.com/topic/219248-gd-help/#findComment-1136985 Share on other sites More sharing options...
thecase Posted November 19, 2010 Author Share Posted November 19, 2010 Got it working now. Had a blank value in the Imagejpeg function to define the name. Thanks for your help in pointing out the direction of the problem Quote Link to comment https://forums.phpfreaks.com/topic/219248-gd-help/#findComment-1136993 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.