CanMan2004 Posted September 3, 2006 Share Posted September 3, 2006 Hi allI have a simple php script to covert text into a image using the GD libary, the code I use is[code]$handle = ImageCreate (275, 384) or die ("Cannot Create image"); $bg_color = ImageColorAllocate ($handle, 255, 255, 255); $txt_color = ImageColorAllocate ($handle, 0, 0, 0); ImageTTFText ($handle, 8, 180, 270, 360, $txt_color, "arial.ttf", "test text"); ImagePng ($handle);[/code] with the above, the text "test text" is converted into a image.What I want to do is to take the image that it creates and upload it onto my server for use later, I tried with the code[code]$addimage_name = $handle;$upfile = "../tmpimg/".$addimage_name;if (!copy($handle, $upfile)) {print "Could not move image into image directory";exit; }$upfile = $addimage_name;[/code]But it doesnt seem to work, no matter how I tweak it. Could someone give me help on how I can do this.Many thanks in advanceCheersEd Quote Link to comment Share on other sites More sharing options...
Barand Posted September 3, 2006 Share Posted September 3, 2006 imagepng() has a second argument - filename, so$handle = ImageCreate (275, 384) or die ("Cannot Create image"); $bg_color = ImageColorAllocate ($handle, 255, 255, 255); $txt_color = ImageColorAllocate ($handle, 0, 0, 0); ImageTTFText ($handle, 8, 180, 270, 360, $txt_color, "arial.ttf", "test text"); ImagePng ($handle, 'myimage.png'); // <- specify filenameImageDestroy($handle); // remove from memory Quote Link to comment Share on other sites More sharing options...
CanMan2004 Posted September 4, 2006 Author Share Posted September 4, 2006 thanks very much Quote Link to comment 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.