shadysaiyan Posted May 31, 2008 Share Posted May 31, 2008 Okay, i had a similar topic before, but this is a bit different i think. My question is. What is the code for saving the generated dynamic image ince its generated and with the username of the user that made it? also the .htaccess for making it so if a member goes to http://mydomain.com/forums/username.png it will show their generated/saved sig? Everything works correctly, just need to know how to do these two things. here is the code for my php sig <? $db_host = "db_host"; $db_user = "dbuser"; $db_pass = "db_pass"; $db_name = "db_name"; $db = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db ($db_name) or die ("Cannot Connect To Database"); $result = mysql_query("SELECT * from ibf_members"); $result1 = mysql_query("SELECT * from ibf_pfields_content"); while($row = mysql_fetch_array($result)) { while($row1 = mysql_fetch_array($result1)) { header("Content-type: image/png"); $im = imagecreatefrompng("sig.png"); $color = imagecolorallocate($im, 0,12,47); $white = ImageColorAllocate($im,255,255,255); imagestring($im, 3, 250, 136, "animedestination.com", $white); imagestring($im, 3, 5, 0, $row['members_display_name'], $white); imagestring($im, 2, 175, 35, "Username: " . $row['members_display_name'], $color); imagestring($im, 2, 175, 45, "Member No: " . $row['id'], $color); imagestring($im, 2, 175, 55, "Posts: " . $row['posts'], $color); imagestring($im, 2, 175, 65, "Title: " . $row['title'], $color); imagestring($im, 2, 175, 75, "Profile Views: " . $row['members_profile_views'], $color); imagestring($im, 2, 175, 85, "Favorite Anime: " . $row1['field_1'], $color); imagepng($im); imagedestroy($im); } } ?> Also forgot to mention i use Invision Power Board. Quote Link to comment https://forums.phpfreaks.com/topic/108169-automatically-saving-dynamic-images/ Share on other sites More sharing options...
hansford Posted June 1, 2008 Share Posted June 1, 2008 //first you need an image path and the filename you want to use $imgpath = "images/yourimagename.png"; //you may also get the path this way $imagename = "yourimagename.png"; $imgpath = $_SERVER['DOCUMENT_ROOT'] . "/images/" . $imagename; //second save the file to your chosen directory imagepng($im, $imgpath,100); I don't have an answer for your second question-sorry. Quote Link to comment https://forums.phpfreaks.com/topic/108169-automatically-saving-dynamic-images/#findComment-554545 Share on other sites More sharing options...
shadysaiyan Posted June 1, 2008 Author Share Posted June 1, 2008 Thanks, it generated the file and i even got it to generate it with the filename as the username, but when it load the sig.php i get an error message now saying it contains errors, and when i got the the generated image. it just shows me the whole URL to it. Here's my new code: <? $db_host = "db_host"; $db_user = "dbuser"; $db_pass = "db_pass"; $db_name = "db_name"; $db = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db ($db_name) or die ("Cannot Connect To Database"); $result = mysql_query("SELECT * from ibf_members"); $result1 = mysql_query("SELECT * from ibf_pfields_content"); while($row = mysql_fetch_array($result)) { while($row1 = mysql_fetch_array($result1)) { header("Content-type: image/png"); $imagename = $row['members_display_name'] . ".png"; $imgpath = $_SERVER['DOCUMENT_ROOT'] . "/forums/signatures/" . $row['members_display_name'] . ".png"; $im = imagecreatefrompng("sig.png"); $color = imagecolorallocate($im, 0,12,47); $white = ImageColorAllocate($im,255,255,255); $font = 'fonts/arialbd.ttf'; imagettftext($im, 9, 0, 275, 147, $white, $font, "animedestination.com"); imagettftext($im, 9, 0, 5, 10, $white, $font, $row['members_display_name']); imagettftext($im, 7.5, 0, 175, 35, $color, $font, "Username: " . $row['members_display_name']); imagettftext($im, 7.5, 0, 175, 45, $color, $font, "Member No: " . $row['id']); imagettftext($im, 7.5, 0, 175, 55, $color, $font, "Posts: " . $row['posts']); imagettftext($im, 7.5, 0, 175, 65, $color, $font, "Title: " . $row['title']); imagettftext($im, 7.5, 0, 175, 75, $color, $font, "Profile Views: " . $row['members_profile_views']); imagettftext($im, 7.5, 0, 175, 85, $color, $font, "Currently Watching: " . $row1['field_1']); imagepng($im, $imgpath,100); imagedestroy($im); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/108169-automatically-saving-dynamic-images/#findComment-554563 Share on other sites More sharing options...
shadysaiyan Posted June 1, 2008 Author Share Posted June 1, 2008 i was just editing a bit more and trying stuff to make it work, i found that when i removed the 100 from the imagepng tag it generated correctly, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/108169-automatically-saving-dynamic-images/#findComment-554588 Share on other sites More sharing options...
hansford Posted June 2, 2008 Share Posted June 2, 2008 sorry, I'm use to writing jpeg images where the imagejpeg($im, $imgpath,100); The 100 is for the quality from 0-100 looking over the manual for png images I see there is a place for a 3rd argument which is quality but its for Compression level: from 0 (no compression) to 9. Quote Link to comment https://forums.phpfreaks.com/topic/108169-automatically-saving-dynamic-images/#findComment-555401 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.