ID: 21729 Updated by: [EMAIL PROTECTED] Reported By: paolo at i-dome dot com -Status: Open +Status: Feedback Bug Type: GD related Operating System: Linux PHP Version: 4.3.0 New Comment:
Please try using this CVS snapshot: http://snaps.php.net/php4-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-STABLE-latest.zip Previous Comments: ------------------------------------------------------------------------ [2003-01-22 09:14:57] paolo at i-dome dot com This is the original script modified only for running without external parameters. You can download the image bottone1.png by the url http://www.i-dome.com/microtools/bottoni/bottone01.png and the font BOOMBOX.TTF by url http://www.i-dome.com/microtools/fonts/BOOMBOX.TTF The program must run with this parameters: testo=the text larghezza=the width (default 96 pix) The program run correctly on version 4.2.3 of PHP with gd2.0.4. Also it runs correctly when I give the parameter "larghezza" (with) at the original image width (96). Thank you very much Paolo Morandi <? $currpath=substr($SCRIPT_FILENAME,0,strrpos($SCRIPT_FILENAME,"/")); $margin_width=8; // pixel of margin $margin_height=23; //pixel from top to write $default_size=18; //default character dimension $colors=array(102,153,51); error_reporting(E_ALL); $center=$margin_width; $size=$default_size; $isize=getimagesize("bottone01.png"); if(empty($larghezza) || $larghezza < $isize[0]) $larghezza=$isize[0]; if($larghezza > 640) $larghezza=640; $width=$larghezza - ($margin_width * 2); $tsize=imagettfbbox($size, 0, "$currpath/BOOMBOX.TTF",$testo); $twidth=$tsize[2]-$tsize[0]; // echo "0=$tsize[0]|1=$tsize[1]|2=$tsize[2]|3=$tsize[3]|4=$tsize[4]|5=$tsize[5]|6=$tsize[6]|7=$tsize[7]|<BR>"; // echo "size=$size|width=$width|twidth=$twidth|center=$center|<BR>"; if($twidth > $width) { $size=round(($size*($width/$twidth)),0); $tsize=imagettfbbox($size, 0, "$currpath/BOOMBOX.TTF",$testo); $twidth=$tsize[2]-$tsize[0]; } $center+=round((($width-$twidth)/2),0); // echo "size=$size|width=$width|twidth=$twidth|center=$center|<BR>"; // imagettftext(image, size, angole, x, y, colore, font, testo) $im = ImageCreateFromPNG("bottone01.png"); if($larghezza==$isize[0]) //in this case run correct { $im = ImageCreateFromPNG ("bottone01.png"); } else // in this case don't show the text { $im1 = ImageCreateFromPNG ("bottone01.png"); $im=ImageCreateTrueColor($larghezza, $isize[1]); ImageCopy($im, $im1,0,0,0,0,$margin_width,$isize[1]); ImageCopyResized($im, $im1, $margin_width, 0, $margin_width, 0, $width, $isize[1], round($isize[0]-($margin_width * 2),0), $isize[1]); ImageCopy($im, $im1,$margin_width+$width-1,0,$isize[0]-$margin_width,0,$margin_width,$isize[1]); ImageDestroy($im1); } // ImageAlphaBlending($im, true); $tc = ImageColorAllocate ($im, $colors[0], $colors[1], $colors[2]); imagettftext($im, $size, 0, $center, $margin_height, $tc, "$currpath/BOOMBOX.TTF",$testo); // ImageAlphaBlending($im, false); header("Content-Type: image/png\n\n"); ImagePNG($im); ?> ------------------------------------------------------------------------ [2003-01-20 19:22:48] [EMAIL PROTECTED] Hello, Can you provide a small script to reproduce your problem, this function works like a charm here. This line: $tc = ImageColorAllocate ($im, $colors[$color][0], $colors[$color][1], $colors[$color][2]); can be your problem. Check the $color array, or set error_reporting(E_ALL); to see if they are initialized correctly (btw, use always this flag to develop). Second point, ImageAlphaBlending is useless in your case, ImageColorAllocate allocates a color with an opaque alpha channel. thank's for your interest, pierre ------------------------------------------------------------------------ [2003-01-19 07:27:08] paolo at i-dome dot com Don't show the text also with the latest CVS version. ------------------------------------------------------------------------ [2003-01-18 13:17:24] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php4-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-STABLE-latest.zip ------------------------------------------------------------------------ [2003-01-18 11:17:51] paolo at i-dome dot com This code work fine on PHP 4.2.3 compiled with gd2.0.4, but give a image without text with php 4.3 compiled with internal gd support. I have this problem only in the image resized and not with the original image: if($width==$isize[0]) //original size: this work { $im = ImageCreateFromPNG ("bottoni/".$tipo_bottone); } else // to resize: don't work { $im1 = ImageCreateFromPNG("bottoni/".$tipo_bottone); $im=ImageCreateTrueColor($width, $isize[1]); ImageCopy($im, im1,0,0,0,0,$margin_width,$isize[1]); ImageCopyResized($im, $im1, $margin_width, 0, $margin_width, 0, $width, $isize[1], round($isize[0]-($margin_width * 2),0), $isize[1]); ImageCopy($im, $im1,$margin_width+$width-1,0,$isize[0]-$margin_width,0,$margin_width,$isize[1]); ImageDestroy($im1); } ImageAlphaBlending($im, true); $tc = ImageColorAllocate ($im, $colors[$color][0], $colors[$color][1], $colors[$color][2]); imagettftext($im, $size, 0, $center, $margin_height, $tc, $currpath."/fonts/".$font,$testo); ImageAlphaBlending($im, false); header("Content-Type: image/png\n\n"); ImagePNG($im); Thank for support Paolo Morandi ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=21729&edit=1