Ubuntu PHP server, captcha picture does not display characters, what's going on?
There is a picture generated, that is, no character display. Is the character set wrong? Where is the setting?
Reply to discussion (solution)
Code to check it out.
Take a look at the generated images directly and see if they are normal!
Code to check it out.
=0) {imagesetpixel ($distortion _im, (int) ($i +10+sin ($j/$im _y*2*m_pi-m_pi*0.1), $j, $rgb);}}} add interfering pixels; $count = 160;//number of interfering pixels for ($i =0; $i < $count; $i + +) {$randcolor = Imagecolorallocate ($distortion _im,mt_rand ( 0,255), Mt_rand (0,255), Mt_rand (0,255)), Imagesetpixel ($distortion _im, Mt_rand ()% $im _x, Mt_rand ()% $im _y, $randcolor) ;} $rand = Mt_rand (5,30), $rand 1 = Mt_rand (15,25), $rand 2 = Mt_rand (5,10), for ($yy = $rand; $yy <=+ $rand +2; $yy + +) {for ($px =- $px <=80; $px = $px +0.1) {$x = $px/$rand 1;if ($x!=0) {$y =sin ($x);} $py = $y * $rand 2;imagesetpixel ($distortion _im, $px +80, $py + $yy, $text _c);}} Set the file header; Header ("Content-type:image/jpeg");//Export the image to a browser or file in PNG format; Imagepng ($distortion _im);//Destroy an image and release the memory associated with image; I Magedestroy ($distortion _im); Imagedestroy ($im);} function Make_rand ($length = "32") {//CAPTCHA literal generation functions $str= "abcdefghijklmnopqrstuvwxyz"; $result = ""; for ($i =0; $i < $length , $i + +) {$num [$i]=rand (0,25); $result. = $str [$num [$i]];} return $result;} The output calls $checkcode = Make_rand (4); session_start ();//The random number is deposited in the session $_session['Helloweba_gg ']=strtolower ($checkcode); Getauthimage ($checkcode);? >
The Windows Server can. It's Ubuntu, No.
Take a look at the generated images directly and see if they are normal!
The Windows Server can. It's Ubuntu, No.
Code to check it out.
=0) {imagesetpixel ($distortion _im, (int) ($i +10+sin ($j/$im _y*2*m_pi-m_pi*0.1), $j, $rgb);}}} add interfering pixels; $count = 160;//number of interfering pixels for ($i =0; $i < $count; $i + +) {$randcolor = Imagecolorallocate ($distortion _im,mt_rand ( 0,255), Mt_rand (0,255), Mt_rand (0,255)), Imagesetpixel ($distortion _im, Mt_rand ()% $im _x, Mt_rand ()% $im _y, $randcolor) ;} $rand = Mt_rand (5,30), $rand 1 = Mt_rand (15,25), $rand 2 = Mt_rand (5,10), for ($yy = $rand; $yy <=+ $rand +2; $yy + +) {for ($px =- $px <=80; $px = $px +0.1) {$x = $px/$rand 1;if ($x!=0) {$y =sin ($x);} $py = $y * $rand 2;imagesetpixel ($distortion _im, $px +80, $py + $yy, $text _c);}} Set the file header; Header ("Content-type:image/jpeg");//Export the image to a browser or file in PNG format; Imagepng ($distortion _im);//Destroy an image and release the memory associated with image; I Magedestroy ($distortion _im); Imagedestroy ($im);} function Make_rand ($length = "32") {//CAPTCHA literal generation functions $str= "abcdefghijklmnopqrstuvwxyz"; $result = ""; for ($i =0; $i < $length , $i + +) {$num [$i]=rand (0,25); $result. = $str [$num [$i]];} return $result;} The output calls $checkcode = Make_rand (4); session_start ();//The random number is deposited in the session $_session['Helloweba_gg ']=strtolower ($checkcode); Getauthimage ($checkcode);? >
The Windows Server can. It's Ubuntu, No.
Check your font file path.
You put 62 lines of Header ("Content-type:image/jpeg"); Comment out and you'll see the error message.
TTF is a font file for Windows, you need to install the support library