Ubuntu PHP server, captcha picture does not show characters, what's going on

Source: Internet
Author: User
Tags php server
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

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.