Asperon Posted August 20, 2007 Share Posted August 20, 2007 after you create an image in GD how do you save it to your computer or database? Link to comment https://forums.phpfreaks.com/topic/65887-solved-saving-an-image-in-php/ Share on other sites More sharing options...
MadTechie Posted August 20, 2007 Share Posted August 20, 2007 imagejpeg — Output image to browser or file bool imagejpeg ( resource $image [, string $filename [, int $quality]] ) Link to comment https://forums.phpfreaks.com/topic/65887-solved-saving-an-image-in-php/#findComment-329345 Share on other sites More sharing options...
Asperon Posted August 20, 2007 Author Share Posted August 20, 2007 I looked it up on php.net... but its considered null unless I have the filters and quality...this what i have ImagePNG($im,'image1.png','???,'PNG_NO_FILTER'); what do I put for quality? Link to comment https://forums.phpfreaks.com/topic/65887-solved-saving-an-image-in-php/#findComment-329352 Share on other sites More sharing options...
Daniel0 Posted August 20, 2007 Share Posted August 20, 2007 Argument 2, 3 and 4 are optional. You don't need them. You need argument 2 (filename) or course if you are going to save it. Link to comment https://forums.phpfreaks.com/topic/65887-solved-saving-an-image-in-php/#findComment-329357 Share on other sites More sharing options...
MadTechie Posted August 20, 2007 Share Posted August 20, 2007 as Daniel0 said. so ImagePNG($im,'image1.png') should be ok Link to comment https://forums.phpfreaks.com/topic/65887-solved-saving-an-image-in-php/#findComment-329358 Share on other sites More sharing options...
Asperon Posted August 20, 2007 Author Share Posted August 20, 2007 well either way its not saving.... I think I have things all messed up anyways, I would post code, but there's a bit too much to read through...basically, I have form that you fill out...and you hit update...and it is supposed to display the image you created using the form.... I have the form run and i include the php file with the image function...but the png comes out as a that wierd code and I don't know how to <img> embed when it isn't from another file, so I was gonna try saving it.. but I don't think that's the best way. here's the set up image.php ---> update ---> $_GET inside of image.php ---> include the createImage() function (parameters are from $_GET) ---> imgPNG($im) (this part doesn't show properly) image.php : <?php $bgColor = $_GET['bgColor']; $logo = $_GET['logo']; $ln1[0] = $_GET['ln1_text']; $ln1[1] = $_GET['ln1_font']; $ln1[2] = $_GET['ln1_size']; $ln1[3] = $_GET['ln1_color']; $ln1[4] = $_GET['ln1_align']; $ln2[0] = $_GET['ln2_text']; $ln2[1] = $_GET['ln2_font']; $ln2[2] = $_GET['ln2_size']; $ln2[3] = $_GET['ln2_color']; $ln2[4] = $_GET['ln2_align']; $ln3[0] = $_GET['ln3_text']; $ln3[1] = $_GET['ln3_font']; $ln3[2] = $_GET['ln3_size']; $ln3[3] = $_GET['ln3_color']; $ln3[4] = $_GET['ln3_align']; $ln4[0] = $_GET['ln4_text']; $ln4[1] = $_GET['ln4_font']; $ln4[2] = $_GET['ln4_size']; $ln4[3] = $_GET['ln4_color']; $ln4[4] = $_GET['ln4_align']; $ln5[0] = $_GET['ln5_text']; $ln5[1] = $_GET['ln5_font']; $ln5[2] = $_GET['ln5_size']; $ln5[3] = $_GET['ln5_color']; $ln5[4] = $_GET['ln5_align']; ?> <html> <body> <head><title>Customize</title></head> <form method="GET" action="image.php"> //forms </form> <?php include('imageDisplay.php'); createImage($bgColor,$logo,$ln1,$ln2,$ln3,$ln4,ln5); ?> </body> </html> imageDisplay.php: <?php function createImage($bgColor, $logo, $ln1, $ln2, $ln3, $ln4, $ln5){ //create canvas $width = 500; $height = 203; $im = ImageCreateTrueColor($width,$height); switch($bgColor){ case 'Black' : $canvas = ImageColorAllocate($im,0,0,0); break; case 'White' : $canvas = ImageColorAllocate($im,255,255,255); //more code... //create and destroy Header('Content-type: image/png'); ImagePNG($im) ImageDestroy($im); } ?> Link to comment https://forums.phpfreaks.com/topic/65887-solved-saving-an-image-in-php/#findComment-329365 Share on other sites More sharing options...
Asperon Posted August 20, 2007 Author Share Posted August 20, 2007 crap I did something...now it goes blank when I update it .............. (fixed that...) Link to comment https://forums.phpfreaks.com/topic/65887-solved-saving-an-image-in-php/#findComment-329367 Share on other sites More sharing options...
Asperon Posted August 20, 2007 Author Share Posted August 20, 2007 well, I have things to do, post with your ideas, that would be great... I"ll try to get another question up if I can't fix it by the end of the week, thanks Link to comment https://forums.phpfreaks.com/topic/65887-solved-saving-an-image-in-php/#findComment-329369 Share on other sites More sharing options...
MadTechie Posted August 20, 2007 Share Posted August 20, 2007 image.php will not work we're come back to that for now test imageDisplay.php directly Link to comment https://forums.phpfreaks.com/topic/65887-solved-saving-an-image-in-php/#findComment-329370 Share on other sites More sharing options...
Asperon Posted August 23, 2007 Author Share Posted August 23, 2007 k, I'm back after a few days, I'm going to set my imageDisplay.php to test it directly. Link to comment https://forums.phpfreaks.com/topic/65887-solved-saving-an-image-in-php/#findComment-332237 Share on other sites More sharing options...
Asperon Posted August 23, 2007 Author Share Posted August 23, 2007 ok, so if I set my image.php to $_GET to imageDisplay.php, and have imageDisplay request all the variables, then define the function, then output,it works, though, some of my fonts dont' work, I need to check that, but it will output...I think that I will go with that for now and add some design to the imageDisplay.php page and let the user decide whether to keep it or do something else with it, thank you for you help. Link to comment https://forums.phpfreaks.com/topic/65887-solved-saving-an-image-in-php/#findComment-332256 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.