php ile resme yazılan yazıda aşagı nasıl geçilir?
23
●1.355
- 29-08-2010, 12:08:09PHP Manual'dan bu kod;
Desc: Same function as above but it can display multi-line strings.
<?php function sendimagetext($text) { // Set font size $font_size = 4; $ts=explode("\n",$text); $width=0; foreach ($ts as $k=>$string) { //compute width $width=max($width,strlen($string)); } // Create image width dependant on width of the string $width = imagefontwidth($font_size)*$width; // Set height to that of the font $height = imagefontheight($font_size)*count($ts); $el=imagefontheight($font_size); $em=imagefontwidth($font_size); // Create the image pallette $img = imagecreatetruecolor($width,$height); // Dark red background $bg = imagecolorallocate($img, 0xAA, 0x00, 0x00); imagefilledrectangle($img, 0, 0,$width ,$height , $bg); // White font color $color = imagecolorallocate($img, 255, 255, 255); foreach ($ts as $k=>$string) { // Length of the string $len = strlen($string); // Y-coordinate of character, X changes, Y is static $ypos = 0; // Loop through the string for($i=0;$i<$len;$i++){ // Position of the character horizontally $xpos = $i * $em; $ypos = $k * $el; // Draw character imagechar($img, $font_size, $xpos, $ypos, $string, $color); // Remove character from string $string = substr($string, 1); } } // Return the image header("Content-Type: image/png"); imagepng($img); // Remove image imagedestroy($img); } ?> - 29-08-2010, 13:37:59saol ben buna font yüklemeyi nasıl yapıcam?
gd kütüphanesinden anlamamda
bayGaReZ adlı üyeden alıntı: mesajı görüntüle - 29-08-2010, 14:19:12bayGaReZ adlı üyeden alıntı: mesajı görüntüle
<?php function sendimagetext($text) { // Set font size $font_size = 4; $ts=explode("\n",$text); $width=0; foreach ($ts as $k=>$string) { //compute width $width=max($width,strlen($string)); } $b="fontlar/VOX.TTF"; $font_size=imageloadfont("$b"); // Create image width dependant on width of the string $width = imagefontwidth($font_size)*$width; // Set height to that of the font $height = imagefontheight($font_size)*count($ts); $el=imagefontheight($font_size); $em=imagefontwidth($font_size); // Create the image pallette $img = imagecreatetruecolor($width,$height); // Dark red background $bg = imagecolorallocate($img, 255, 255, 255); imagefilledrectangle($img, 0, 0,$width ,$height , $bg); // White font color $color = imagecolorallocate($img, 0x33, 0x33, 0x33); foreach ($ts as $k=>$string) { // Length of the string $len = strlen($string); // Y-coordinate of character, X changes, Y is static $ypos = 0; // Loop through the string for($i=0;$i<$len;$i++){ // Position of the character horizontally $xpos = $i * $em; $ypos = $k * $el; // Draw character $font="fontlar/VOX.TTF"; imagechar($img, $font_size, $xpos, $ypos, $string, $color); // Remove character from string $string = substr($string, 1); } } // Return the image // header("Content-Type: image/png"); imagepng($img); // Remove image imagedestroy($img); } $mert="Büyük Harfler:\nA"; sendimagetext($mert); ?>bu şekilde yaptım ancak hata verdi