国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

<i id="nkjuw"></i>
      1. <center id="nkjuw"></center>
        1. php技術(shù)實(shí)現(xiàn)加載字體并保存成圖片

          Original 2017-01-20 15:43:53 301
          abstract:下面通過一段代碼給大家詳解介紹下php技術(shù)實(shí)現(xiàn)加載字體并保存成圖片。// Set the content-type header("Content-type: image/png");    // Create the image $im = imagecreatetr

          下面通過一段代碼給大家詳解介紹下php技術(shù)實(shí)現(xiàn)加載字體并保存成圖片。

          // Set the content-type
          header("Content-type: image/png");
            
          // Create the image
          $im = imagecreatetruecolor(400, 100);
            
          // Create some colors
          $white = imagecolorallocate($im, 255, 255, 255);
          $grey = imagecolorallocate($im, 128, 128, 128);
          $black = imagecolorallocate($im, 0, 0, 0);
          imagefilledrectangle($im, 0, 0, 399, 100, $white);
            
          // The text to draw
          $text = '字典網(wǎng)';
          // Replace path by your own font path
          $font = 'fontName.ttf';
            
          // Add some shadow to the text
          //imagettftext($im, 60, 0, 11, 21, $grey, $font, $text);
            
          // Add the text
          imagettftext($im, 60, 0, 0, 70, $black, $font, $text);
            
          // Using imagepng() results in clearer text compared with imagejpeg()
          imagepng($im);
          imagedestroy($im);

          如果想保存圖可以用下面代碼

          ob_start(); 
            imagejpeg($im);
          $img = ob_get_contents(); 
          ob_end_clean(); 
          $size = strlen($img); 
             
          $fp2=@fopen('tst.jpg', "a"); 
          fwrite($fp2,$img); 
          fclose($fp2);

          更多關(guān)于php技術(shù)實(shí)現(xiàn)加載字體并保存成圖片請(qǐng)關(guān)注PHP中文網(wǎng)(www.miracleart.cn)其他文章!   


          Release Notes

          Popular Entries