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