CAPER Posted November 2, 2008 Share Posted November 2, 2008 need some help with resizing a font image . this is a banner script someone helped me with im not really good with php so im looking for help . this script displays a banner with the persons name on it but some people have longer names so i just want it to automatically resize the name in the banner and have it center can anyone help? <? ///:)///////////////////////////////////////////////////// // Jamroom Band-Banner Script // // Build by: Gilbert Romero // // Lizens: // // Date: today // ////////////////////////////////////////////////////// //The DB details (change to your details) $res=mysql_connect("localhost","","") or die(); mysql_select_db(""); //just a little db helper function SQLSelectRow($SQL) { $Res = mysql_query( $SQL ); if ( $Res ) { $Row = mysql_fetch_row( $Res ); return $Row; } else { return false; } } //Get the DB DATA //($Loginteile is given in the image name, first number is Login/Band ID (7_2_222_050_050.jpg)) $LoginteileRaw = explode('.', $_SERVER['PATH_INFO']); $Loginteile = explode('_', substr($LoginteileRaw [0],1)); $BandID = $Loginteile[0]; $SQL=" SELECT band_name FROM jamroom_band_info WHERE band_active = '1' AND band_id = '$BandID' "; list($dbBandName) = SQLSelectRow($SQL); $dbBCA = unserialize($dbBandCounts); //TXT SIZES $FontSmall = 2.2; $FontBig=35; //BACKGROUND (the "Banner") $image = imagecreatefrompng("wwbad2a.png"); //FONT Types($Loginteile is given in the image name, second number (7_2_222_050_050.jpg)) //change YOURFONT to your chosen TTF fonts if ($Loginteile[1]=='1' OR !$Loginteile[1]) $fontTTF = "Friday13.ttf"; elseif ($Loginteile[1]=='2') $fontTTF = "fivecent.ttf"; elseif ($Loginteile[1]=='3') $fontTTF = "damnarc.ttf"; else $fontTTF = "/trab/jamroom/verdanab.ttf"; //NamePosition Top $nameTop = 45; //NamePosition Left $nameLeft = 45; //TXT COLOR ($Loginteile is given in the image name, last 3 numbers RGB (7_2_222_050_050.jpg)) if ( $Loginteile[2] AND $Loginteile[3] AND $Loginteile[4] ) $TXT_color = imagecolorallocate($image, $Loginteile[2], $Loginteile[3], $Loginteile[4]); else $TXT_color = imagecolorallocate($image, 154, 180, 166); // Text Shadow color $TXT_colorShadow = imagecolorallocate($image, 0, 0, 0); //The TEXT (Infos) imagestring($image, $FontSmall, 7, 5, " $dbBCA[FAN_COUNT]", $TXT_color); imagestring($image, $FontSmall, 7, 17, " $dbBCA[sONG_COUNT]", $TXT_color); imagestring($image, $FontSmall, 7, 29, " $dbBCA[VIDEO_COUNT]", $TXT_color); imagestring($image, $FontSmall, 7, 41, " $dbBCA[PHOTO_COUNT]", $TXT_color); list($Continent,$Country)=split(":",$dbBandLocation); imagestring($image, $FontSmall, 100, 29, "$Country", $TXT_color); imagestring($image, $FontSmall, 100, 41, " $dbBandSoundslike", $TXT_color); imagestring($image, $FontSmall, 417, 41, "$Recorde", $TXT_color); //build the Band Name (shadow) for ($ox = -2; $ox <= 2; $ox++) { for ($oy = -2; $oy <= 2; $oy++) { imagettftext($image, $FontBig , 0, $nameLeft+$ox, $nameTop+$oy, $TXT_colorShadow ,$fontTTF, $dbBandName); } } //build the Band Name (foreground) imagettftext($image, $FontBig , 0, $nameLeft, $nameTop, $TXT_color ,$fontTTF, $dbBandName); //Set the header header("Content-type: image/png"); //DISPLAY IMAGE imagepng($image); ; //DELETE IMAGE(from server "CACHE") imagedestroy($image); ?> Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/ Share on other sites More sharing options...
corbin Posted November 2, 2008 Share Posted November 2, 2008 $image = imagecreatefrompng("wwbad2a.png"); It's creating it from an already existent background, so you will have to mod that. Also, when your script starts with <?, that should be <?php since <? is only supported by some servers. Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-680769 Share on other sites More sharing options...
CAPER Posted November 3, 2008 Author Share Posted November 3, 2008 i dont know where to really start Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-680857 Share on other sites More sharing options...
corbin Posted November 3, 2008 Share Posted November 3, 2008 Learn how to edit a PNG? Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-680927 Share on other sites More sharing options...
ddrudik Posted November 3, 2008 Share Posted November 3, 2008 This isn't necessarily a cut-and-paste solution, but it should give you an idea of how to go about finding out the values and adjustments etc. You should consider finding out what maximum number of characters in a name can be printed successfully, then adjust the font size as needed based on the length of the name if it exceeds that number. <?php $fontsize=10; $maxprintable=6; $name='This Is A Long Name.'; $namelength=strlen($name); if($namelength>$maxprintable){ $fontsize=($maxprintable/$namelength)*$fontsize; } echo $fontsize; ?> Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-681581 Share on other sites More sharing options...
corbin Posted November 4, 2008 Share Posted November 4, 2008 If you do what he suggested and see how many characters you can fit, you'll probably want to use M's as they are usually the widest character. Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-681704 Share on other sites More sharing options...
Psycho Posted November 4, 2008 Share Posted November 4, 2008 Here's an article on how to center text in an image (which includes a section on determining the length of text in an image). http://www.bitrepository.com/web-programming/php/how-to-center-a-text-on-an-image-using-gd.html However, I question the validity of imagefontwidth() to determine the width of a string of text. imagefontwidth() only takes one parameter (the font size). So while it would work fine for a fixed-width font such as courier, I don't see how it could work for a non fixed-width font such as times. Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-682065 Share on other sites More sharing options...
ddrudik Posted November 4, 2008 Share Posted November 4, 2008 It would seem the recommendation to test with the font's widest character is a valid one. Otherwise, measure the pixel width of each character, store that in an array, then use array_count_values on preg_match_all output and add up the pixel widths of the character counts found (seems more work than necessary though). Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-682069 Share on other sites More sharing options...
sasa Posted November 4, 2008 Share Posted November 4, 2008 look http://www.php.net/manual/en/function.imagettfbbox.php and users notes Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-682134 Share on other sites More sharing options...
Psycho Posted November 4, 2008 Share Posted November 4, 2008 look http://www.php.net/manual/en/function.imagettfbbox.php and users notes Hell, I thought that there "should" be such a function but couldn't find it when I did a quick search through the manual and through Google. Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-682155 Share on other sites More sharing options...
CAPER Posted November 5, 2008 Author Share Posted November 5, 2008 can anyone do this for me? how much would they charge me as i dont really have time for to do it myself lately . if anyone can do this for me please contact me at caper@darkstarzproductionz.com Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-682757 Share on other sites More sharing options...
sasa Posted November 5, 2008 Share Posted November 5, 2008 i just want it to automatically resize the name in the banner are you want to resize name ( from 'abcdefgh' to 'abc') or you want to change font size Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-682812 Share on other sites More sharing options...
CAPER Posted November 7, 2008 Author Share Posted November 7, 2008 some of my members profile names are very long so im hoping to have the script resize there name so it doesnt go off the banner and you would be able to view the whole name Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-684384 Share on other sites More sharing options...
Psycho Posted November 7, 2008 Share Posted November 7, 2008 Here's a quick script that will reduce the font so the text will fit within the image width (including defined margins) and will also center the text. The result seems to be a little off center to the right. Not sure why and I need to get back to work so I don't have time to investigate further. Adding a space to the end of the text makes it look better for a quick fix. $image = imagecreatefrompng("wwbad2a.png"); $image_size = getimagesize("wwbad2a.png"); $fontTTF = "verdanab.ttf"; $text_color = imagecolorallocate($image, 255, 255, 255); $font_max_size = 35; $angle = 0; $x_position = 20; $y_margins = 30; $y_width = $image_size[0] - (2 * $y_margins); $band_name = "Michael"; $font_size = $font_max_size; $text_sizes = imagettfbbox($font_size, $angle, $fontTTF, $band_name); $text_width = ($text_sizes[2] - $text_sizes[0]); //Decrease font size until it will fit in image while ($text_width > $y_width) { $font_size--; $text_sizes = imagettfbbox($font_size, $angle, $fontTTF, $band_name); $text_width = ($text_sizes[2] - $text_sizes[0]); } //Center horizontally $y_position = ($image_size[0] - $text_width)/2; imagettftext($image, $font_size , $angle, $y_position, 250, $text_color, $fontTTF, $band_name); //Set the header header("Content-type: image/png"); //DISPLAY IMAGE imagepng($image); ; //DELETE IMAGE(from server "CACHE") imagedestroy($image); Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-684722 Share on other sites More sharing options...
CAPER Posted November 8, 2008 Author Share Posted November 8, 2008 so would i add this code to the current script or would i have to create a new one? Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-685216 Share on other sites More sharing options...
CAPER Posted November 8, 2008 Author Share Posted November 8, 2008 heres what it looks like so far with a long profile name http://worldwidebeats.net/wwbadway.php/37_3_243_252_3.jpg Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-685220 Share on other sites More sharing options...
Psycho Posted November 8, 2008 Share Posted November 8, 2008 heres what it looks like so far with a long profile name http://worldwidebeats.net/wwbadway.php/37_3_243_252_3.jpg So is that what you want? It looks like there is a letter at the very end that supposed to start a new word, so I'm guessing not. Post the current code if you want help. Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-685308 Share on other sites More sharing options...
CAPER Posted November 8, 2008 Author Share Posted November 8, 2008 nope it didnt work it still cut off the name Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-685468 Share on other sites More sharing options...
Psycho Posted November 9, 2008 Share Posted November 9, 2008 nope it didnt work it still cut off the name So, do you still want help with this or what? Post the code you have. The code I posted worked perfectly for me, so there's probably just something with your implementation that needs correcting. Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-685782 Share on other sites More sharing options...
CAPER Posted November 9, 2008 Author Share Posted November 9, 2008 <? ///:)///////////////////////////////////////////////////// // Jamroom Band-Banner Script // // Build by: Gilbert Romero // // Lizens: // // Date: today // ////////////////////////////////////////////////////// //The DB details (change to your details) $res=mysql_connect("localhost","","") or die(); mysql_select_db(""); //just a little db helper function SQLSelectRow($SQL) { $Res = mysql_query( $SQL ); if ( $Res ) { $Row = mysql_fetch_row( $Res ); return $Row; } else { return false; } } //Get the DB DATA //($Loginteile is given in the image name, first number is Login/Band ID (7_2_222_050_050.jpg)) $LoginteileRaw = explode('.', $_SERVER['PATH_INFO']); $Loginteile = explode('_', substr($LoginteileRaw [0],1)); $BandID = $Loginteile[0]; $SQL=" SELECT band_name FROM jamroom_band_info WHERE band_active = '1' AND band_id = '$BandID' "; list($dbBandName) = SQLSelectRow($SQL); $dbBCA = unserialize($dbBandCounts); //TXT SIZES $FontSmall = 2.2; $FontBig=30; //BACKGROUND (the "Banner") $image = imagecreatefrompng("wwbad2a.png"); //FONT Types($Loginteile is given in the image name, second number (7_2_222_050_050.jpg)) //change YOURFONT to your chosen TTF fonts if ($Loginteile[1]=='1' OR !$Loginteile[1]) $fontTTF = "Friday13.ttf"; elseif ($Loginteile[1]=='2') $fontTTF = "fivecent.ttf"; elseif ($Loginteile[1]=='3') $fontTTF = "damnarc.ttf"; else $fontTTF = "/trab/jamroom/verdanab.ttf"; //NamePosition Top $nameTop = 45; //NamePosition Left $nameLeft = 100; //TXT COLOR ($Loginteile is given in the image name, last 3 numbers RGB (7_2_222_050_050.jpg)) if ( $Loginteile[2] AND $Loginteile[3] AND $Loginteile[4] ) $TXT_color = imagecolorallocate($image, $Loginteile[2], $Loginteile[3], $Loginteile[4]); else $TXT_color = imagecolorallocate($image, 154, 180, 166); // Text Shadow color $TXT_colorShadow = imagecolorallocate($image, 0, 0, 0); //The TEXT (Infos) imagestring($image, $FontSmall, 7, 5, " $dbBCA[FAN_COUNT]", $TXT_color); imagestring($image, $FontSmall, 7, 17, " $dbBCA[sONG_COUNT]", $TXT_color); imagestring($image, $FontSmall, 7, 29, " $dbBCA[VIDEO_COUNT]", $TXT_color); imagestring($image, $FontSmall, 7, 41, " $dbBCA[PHOTO_COUNT]", $TXT_color); list($Continent,$Country)=split(":",$dbBandLocation); imagestring($image, $FontSmall, 100, 29, "$Country", $TXT_color); imagestring($image, $FontSmall, 100, 41, " $dbBandSoundslike", $TXT_color); imagestring($image, $FontSmall, 417, 41, "$Recorde", $TXT_color); //build the Band Name (shadow) for ($ox = -2; $ox <= 2; $ox++) { for ($oy = -2; $oy <= 2; $oy++) { imagettftext($image, $FontBig , 0, $nameLeft+$ox, $nameTop+$oy, $TXT_colorShadow ,$fontTTF, $dbBandName); } } //build the Band Name (foreground) imagettftext($image, $FontBig , 0, $nameLeft, $nameTop, $TXT_color ,$fontTTF, $dbBandName); //Set the header header("Content-type: image/png"); //DISPLAY IMAGE imagepng($image); ; //DELETE IMAGE(from server "CACHE") imagedestroy($image); // The file $filename = 'damnarc.ttf'; // Set a maximum height and width $width = 100; $height = 45; // Content type header('Content-type: image/jpeg'); // Get new dimensions list($width_orig, $height_orig) = getimagesize($filename); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output imagejpeg($image_p, null, 100); $image = imagecreatefrompng("wwbad2a.png"); $image_size = getimagesize("wwbad2a.png"); $fontTTF = "verdanab.ttf"; $text_color = imagecolorallocate($image, 255, 255, 255); $font_max_size = 35; $angle = 0; $x_position = 20; $y_margins = 30; $y_width = $image_size[0] - (2 * $y_margins); $band_name = "Michael the artist raise"; $font_size = $font_max_size; $text_sizes = imagettfbbox($font_size, $angle, $fontTTF, $band_name); $text_width = ($text_sizes[2] - $text_sizes[0]); //Decrease font size until it will fit in image while ($text_width > $y_width) { $font_size--; $text_sizes = imagettfbbox($font_size, $angle, $fontTTF, $band_name); $text_width = ($text_sizes[2] - $text_sizes[0]); } //Center horizontally $y_position = ($image_size[0] - $text_width)/2; imagettftext($image, $font_size , $angle, $y_position, 250, $text_color, $fontTTF, $band_name); //Set the header header("Content-type: image/png"); //DISPLAY IMAGE imagepng($image); ; //DELETE IMAGE(from server "CACHE") imagedestroy($image); ?> Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-685844 Share on other sites More sharing options...
Psycho Posted November 9, 2008 Share Posted November 9, 2008 It look like all you did was tack the code I provided at the end of the code you already had?! The code I provided isn't even getting displayed becuase you have already sent the data to the browser. The logic in that code is all over the palce. Have the code build one piece of the puzzle in a logical sequence. For example the code to determine the band name font size & color comes before you put the other text on the page. I tried to rewite it to work accordingly, but since I dont have your database at my disposal I have not tested it. ///:)///////////////////////////////////////////////////// // Jamroom Band-Banner Script // // Build by: Gilbert Romero // // Lizens: // // Date: today // ////////////////////////////////////////////////////// //The DB details (change to your details) $res=mysql_connect("localhost","","") or die(); mysql_select_db(""); //just a little db helper function SQLSelectRow($SQL) { $Res = mysql_query( $SQL ); if ( $Res ) { $Row = mysql_fetch_row( $Res ); return $Row; } else { return false; } } //Get the DB DATA //($Loginteile is given in the image name, first number is Login/Band ID (7_2_222_050_050.jpg)) $LoginteileRaw = explode('.', $_SERVER['PATH_INFO']); $Loginteile = explode('_', substr($LoginteileRaw[0],1)); $BandID = $Loginteile[0]; $SQL="SELECT band_name FROM jamroom_band_info WHERE band_active = '1' AND band_id = '$BandID' "; list($dbBandName) = SQLSelectRow($SQL); $dbBCA = unserialize($dbBandCounts); //BACKGROUND (the "Banner") $image = imagecreatefrompng("wwbad2a.png"); //TXT SIZE $FontSmall = 2.2; //TXT COLOR ($Loginteile is given in the image name, last 3 numbers RGB (7_2_222_050_050.jpg)) if ( $Loginteile[2] AND $Loginteile[3] AND $Loginteile[4] ) $TXT_color = imagecolorallocate($image, $Loginteile[2], $Loginteile[3], $Loginteile[4]); else $TXT_color = imagecolorallocate($image, 154, 180, 166); //The TEXT (Infos) imagestring($image, $FontSmall, 7, 5, " $dbBCA[FAN_COUNT]", $TXT_color); imagestring($image, $FontSmall, 7, 17, " $dbBCA[sONG_COUNT]", $TXT_color); imagestring($image, $FontSmall, 7, 29, " $dbBCA[VIDEO_COUNT]", $TXT_color); imagestring($image, $FontSmall, 7, 41, " $dbBCA[PHOTO_COUNT]", $TXT_color); list($Continent,$Country)=split(":",$dbBandLocation); imagestring($image, $FontSmall, 100, 29, "$Country", $TXT_color); imagestring($image, $FontSmall, 100, 41, " $dbBandSoundslike", $TXT_color); imagestring($image, $FontSmall, 417, 41, "$Recorde", $TXT_color); //FONT Types($Loginteile is given in the image name, second number (7_2_222_050_050.jpg)) //change YOURFONT to your chosen TTF fonts if ($Loginteile[1]=='1' OR !$Loginteile[1]) $fontTTF = "Friday13.ttf"; elseif ($Loginteile[1]=='2') $fontTTF = "fivecent.ttf"; elseif ($Loginteile[1]=='3') $fontTTF = "damnarc.ttf"; else $fontTTF = "/trab/jamroom/verdanab.ttf"; // Text Shadow color $TXT_colorShadow = imagecolorallocate($image, 0, 0, 0); //Name max font size $font_max_size = 35; //Angle of name text $angle = 0; //NamePosition Top $y_position = 45; //Left and right margins $x_margins = 100; //NamePosition Left $image_size = getimagesize("wwbad2a.png"); $x_width = $image_size[0] - (2 * $x_margins); $font_size = $font_max_size; $text_sizes = imagettfbbox($font_size, $angle, $fontTTF, $dbBandName); $text_width = ($text_sizes[2] - $text_sizes[0]); while ($text_width > $x_width) { $font_size--; $text_sizes = imagettfbbox($font_size, $angle, $fontTTF, $dbBandName); $text_width = ($text_sizes[2] - $text_sizes[0]); } //Center horizontally $x_position = ($image_size[0]-$text_width)/2; imagettftext($image, $font_size , $angle, $x_position, $y_position, $text_color, $fontTTF, $band_name); //Set the header header("Content-type: image/png"); //DISPLAY IMAGE imagepng($image); ; //DELETE IMAGE(from server "CACHE") imagedestroy($image Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-686206 Share on other sites More sharing options...
CAPER Posted November 10, 2008 Author Share Posted November 10, 2008 i tried it but now it doesnt show the text Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-686514 Share on other sites More sharing options...
CAPER Posted November 12, 2008 Author Share Posted November 12, 2008 anyone want to give it a crack at? Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-688694 Share on other sites More sharing options...
Psycho Posted November 12, 2008 Share Posted November 12, 2008 OK, I've tried to incorporate my script into your original script (although I really don't like the flow of the page) <?php ///:)///////////////////////////////////////////////////// // Jamroom Band-Banner Script // // Build by: Gilbert Romero // // Lizens: // // Date: today // ////////////////////////////////////////////////////// //The DB details (change to your details) $res=mysql_connect("localhost","","") or die(); mysql_select_db(""); //just a little db helper function SQLSelectRow($SQL) { $Res = mysql_query( $SQL ); if ( $Res ) { $Row = mysql_fetch_row( $Res ); return $Row; } else { return false; } } //Get the DB DATA //($Loginteile is given in the image name, first number is Login/Band ID (7_2_222_050_050.jpg)) $LoginteileRaw = explode('.', $_SERVER['PATH_INFO']); $Loginteile = explode('_', substr($LoginteileRaw [0],1)); $BandID = $Loginteile[0]; $SQL="SELECT band_name FROM jamroom_band_info WHERE band_active = '1' AND band_id = '$BandID'"; list($dbBandName) = SQLSelectRow($SQL); $dbBCA = unserialize($dbBandCounts); //BACKGROUND (the "Banner") $image_file = "wwbad2a.png"; $image = imagecreatefrompng($image_file); //FONT Types($Loginteile is given in the image name, second number (7_2_222_050_050.jpg)) //change YOURFONT to your chosen TTF fonts if ($Loginteile[1]=='1' OR !$Loginteile[1]) $fontTTF = "Friday13.ttf"; elseif ($Loginteile[1]=='2') $fontTTF = "fivecent.ttf"; elseif ($Loginteile[1]=='3') $fontTTF = "damnarc.ttf"; else $fontTTF = "/trab/jamroom/verdanab.ttf"; //TXT COLOR ($Loginteile is given in the image name, last 3 numbers RGB (7_2_222_050_050.jpg)) if ( $Loginteile[2] AND $Loginteile[3] AND $Loginteile[4] ) $TXT_color = imagecolorallocate($image, $Loginteile[2], $Loginteile[3], $Loginteile[4]); else $TXT_color = imagecolorallocate($image, 154, 180, 166); // Text Shadow color $TXT_colorShadow = imagecolorallocate($image, 0, 0, 0); //TXT SIZES $FontSmall = 2.2; //The TEXT (Infos) imagestring($image, $FontSmall, 7, 5, " $dbBCA[FAN_COUNT]", $TXT_color); imagestring($image, $FontSmall, 7, 17, " $dbBCA[sONG_COUNT]", $TXT_color); imagestring($image, $FontSmall, 7, 29, " $dbBCA[VIDEO_COUNT]", $TXT_color); imagestring($image, $FontSmall, 7, 41, " $dbBCA[PHOTO_COUNT]", $TXT_color); list($Continent,$Country)=split(":",$dbBandLocation); imagestring($image, $FontSmall, 100, 29, "$Country", $TXT_color); imagestring($image, $FontSmall, 100, 41, " $dbBandSoundslike", $TXT_color); imagestring($image, $FontSmall, 417, 41, "$Recorde", $TXT_color); //NamePosition Top $nameTop = 45; //NamePosition Left $nameMargin = 45; //Image Size $image_size = getimagesize($image_file); //Available text width $nameWidthAvail = $image_size[0] - (2 * $nameMargin); //Font size for band name $band_font=35; $font_size = $font_max_size; $text_sizes = imagettfbbox($font_size, 0, $fontTTF, $dbBandName); $text_width = ($text_sizes[2] - $text_sizes[0]); //Decrease font size until it will fit in image while ($text_width > $nameWidthAvail) { $font_size--; $text_sizes = imagettfbbox($font_size, 0, $fontTTF, $dbBandName); $text_width = ($text_sizes[2] - $text_sizes[0]); } //Center horizontally $nameLeft = ($image_size[0] - $text_width)/2; //build the Band Name (shadow) for ($ox = -2; $ox <= 2; $ox++) { for ($oy = -2; $oy <= 2; $oy++) { imagettftext($image, $band_font, 0, $nameLeft+$ox, $nameTop+$oy, $TXT_colorShadow ,$fontTTF, $dbBandName); } } //Write the band name text imagettftext($image, $band_font, 0, $nameLeft, $nameTop, $TXT_color ,$fontTTF, $dbBandName); //Set the header header("Content-type: image/png"); //DISPLAY IMAGE imagepng($image); ; //DELETE IMAGE(from server "CACHE") imagedestroy($image); ?> Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-688791 Share on other sites More sharing options...
CAPER Posted November 12, 2008 Author Share Posted November 12, 2008 this is what it looks like so far http://worldwidebeats.net/bannerride.php/2_3_243_252_3.jpg Quote Link to comment https://forums.phpfreaks.com/topic/131104-image-resize-help/#findComment-688832 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.