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 Link to comment https://forums.phpfreaks.com/topic/19619-saving-gd-image/ 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 Link to comment https://forums.phpfreaks.com/topic/19619-saving-gd-image/#findComment-85431 Share on other sites More sharing options...
CanMan2004 Posted September 4, 2006 Author Share Posted September 4, 2006 thanks very much Link to comment https://forums.phpfreaks.com/topic/19619-saving-gd-image/#findComment-85596 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.