On the PHP server of ubuntu, the verification code image does not display characters. what is the problem?

Source: Internet
Author: User
On the PHP server of ubuntu, the verification code image does not display characters. what is the problem? on the PHP server of ubuntu, the verification code image does not display characters. what is the problem?
If an image is generated, no characters are displayed. Is it a character set error? Where to set?


Reply to discussion (solution)

After the code is posted, let's take a look.

Open the generated image and check whether it is normal!

After the code is posted, let's take a look.

 = 0) {imagesetpixel ($ distortion_im, (int) ($ I + 10 + sin ($ j/$ im_y * 2 * M_PI-M_PI * 0.1) * 4), $ j, $ rgb) ;}}// add interference pixels; $ count = 160; // Number of interference 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); $ rand1 = mt_rand (15, 25); $ rand2 = mt_rand (5, 10 ); for ($ Yy = $ rand; $ yy <= + $ rand + 2; $ yy ++) {for ($ px =-80; $ px <= 80; $ px = $ px + 0.1) {$ x = $ px/$ rand1; if ($ x! = 0) {$ y = sin ($ x) ;}$ py = $ y * $ rand2; imagesetpixel ($ distortion_im, $ px + 80, $ py + $ yy, $ text_c) ;}}// sets the file Header; Header ("Content-type: image/JPEG"); // outputs the image to a browser or file in PNG format; imagePNG ($ distortion_im); // destroy an image and release the memory associated with the image; ImageDestroy ($ distortion_im); ImageDestroy ($ im );} function make_rand ($ length = "32") {// verification code text generation function $ 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 (); // Save the random number to the session $ _ SESSION ['helloweba _ GG'] = strtolower ($ checkcode); getAuthImage ($ checkcode);?>



Windows Server can. ubuntu cannot.

Open the generated image and check whether it is normal!


Windows Server can. ubuntu cannot.


After the code is posted, let's take a look.

 = 0) {imagesetpixel ($ distortion_im, (int) ($ I + 10 + sin ($ j/$ im_y * 2 * M_PI-M_PI * 0.1) * 4), $ j, $ rgb) ;}}// add interference pixels; $ count = 160; // Number of interference 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); $ rand1 = mt_rand (15, 25); $ rand2 = mt_rand (5, 10 ); for ($ Yy = $ rand; $ yy <= + $ rand + 2; $ yy ++) {for ($ px =-80; $ px <= 80; $ px = $ px + 0.1) {$ x = $ px/$ rand1; if ($ x! = 0) {$ y = sin ($ x) ;}$ py = $ y * $ rand2; imagesetpixel ($ distortion_im, $ px + 80, $ py + $ yy, $ text_c) ;}}// sets the file Header; Header ("Content-type: image/JPEG"); // outputs the image to a browser or file in PNG format; imagePNG ($ distortion_im); // destroy an image and release the memory associated with the image; ImageDestroy ($ distortion_im); ImageDestroy ($ im );} function make_rand ($ length = "32") {// verification code text generation function $ 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 (); // Save the random number to the session $ _ SESSION ['helloweba _ GG'] = strtolower ($ checkcode); getAuthImage ($ checkcode);?>





Windows Server can. ubuntu cannot.

Check the path of your font file.

You can comment out 62 rows of Header ("Content-type: image/JPEG") to see the error message.
Ttf is a windows font file. 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.