php技术实现加载字体并保存成图片
// 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 = '字典网'; // 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);
以上代码就可以完成加载字体并保存成图片,希望大家会喜欢
分享PHP函数实现数字与文字分页代码
这篇文章主要是用PHP函数实现数字与文字分页,具体实现步骤就不罗嗦了,直接上代码/****@param$_sql*@param$_size*/function_page($_sql,$_size){//将里面的所有变量
PHP之浮点数计算比较以及取整数不准确的解决办法
php有意思的现象,应该是很多编程语言都会有这样的现象。这个是因为计算机的本身对浮点数识别的问题.....下面通过代码给大家展示下:$f=0.58;var_dump(i
怎样搭建PHP开发环境
搭建PHP开发环境首先第一步要下载开发环境wampserver下载sublimetext2sublime使用技巧1:安装漂亮的编程字体http://pan.baidu.com/s/1xMex9下载"程序编写字体?YaheiConsola