首页
开发手册
应用中心
工具
用户中心
FoundPHP 照片:文字/颜色
中文简体
中文简体
English
上一篇
下一篇
#FoundPHP 照片:文字/颜色 `框架下默认集成 FoundPHP_image 支持格式:jpg、jpeg、png、gif` `应用库地址:class/image/resize.php` `采用GD库php默认memory_limit是128M,如果需要处理大尺寸照片修改512M以上。` ###添加文字设置尺寸与定位 ------------ ```php $FoundPHP_image->image('foundphp.jpg'); //设置字体 $FoundPHP_image->font( array( 'str' => 'FoundPHP 框架真好用', //文字 'color' => '#00a9f5', //颜色 'size' => 20, //尺寸 'x' => 20, //坐标 'y' => 80, //坐标 ) ); //标准缩放 $FoundPHP_image->resize(array( 'width' =>400, 'height' =>400, 'cut' =>1, //1切图,0不切图 'zoom' =>1, //按比例缩放 )); $FoundPHP_image->save('foundphp_new'); ``` 实现效果: ![](data/files/edit/20/05/05/200505_17258654.jpg)
###添加文字增加阴影 ------------ 可能背景图比较杂乱我们看文字会发现不清晰,可以试着加阴影来解决 ```php $FoundPHP_image->image('foundphp.jpg'); //设置字体 $FoundPHP_image->font( array( 'str' => 'FoundPHP 框架真好用',//文字 'color' => '#00a9f5', //颜色 'size' => 20, //尺寸 'x' => 20, //坐标 'y' => 80, //坐标 'shadow' => '#000000', //背景颜色 'shadow_size' => 2, //阴影距离 ) ); //标准缩放 $FoundPHP_image->resize(array( 'width' =>400, 'height' =>400, 'cut' =>1, //1切图,0不切图 'zoom' =>1, //按比例缩放 )); $FoundPHP_image->save('foundphp_new'); ``` 实现效果: ![](data/files/edit/20/05/05/200505_17275733.jpg)
###添加多组文字并调整角度 ------------ 可能背景图比较杂乱我们看文字会发现不清晰,可以试着加阴影来解决 ```php $FoundPHP_image->image('foundphp.jpg'); //设置字体 $FoundPHP_image->font( array( 'str' => 'FoundPHP FrameWork Very Good!', //文字 'color' => '#ab0b0b', //颜色 'size' => 16, //尺寸 'x' => 20, //坐标 'y' => 140, //坐标 'shadow' => '#ffffff', //背景颜色 'shadow_size' => 1, //阴影距离 'angle' => 18, //角度数值逆时针旋转 ) ); //设置字体 $FoundPHP_image->font( array( 'str' => 'FoundPHP 框架真好用', //文字 'color' => '#00a9f5', //颜色 'size' => 20, //尺寸 'x' => 20, //坐标 'y' => 180, //坐标 'shadow' => '#000000', //背景颜色 'shadow_size' => 2, //阴影距离 'angle' => 18, //角度数值逆时针旋转 ) ); //标准缩放 $FoundPHP_image->resize(array( 'width' =>400, 'height' =>400, 'cut' =>1, //1切图,0不切图 'zoom' =>1, //按比例缩放 )); $FoundPHP_image->save('foundphp_new'); ``` 实现效果: ![](data/files/edit/20/05/05/200505_17319176.jpg)
###自定义文字字体 ------------ 可能背景图比较杂乱我们看文字会发现不清晰,可以试着加阴影来解决 ```php $FoundPHP_image->image('foundphp.jpg'); //设置字体 $FoundPHP_image->font( array( 'font' => 'data/fonts/comic.ttf', //自定义字体 'str' => 'FoundPHP FrameWork Very Good!', //文字 'color' => '#ab0b0b', //颜色 'size' => 16, //尺寸 'x' => 20, //坐标 'y' => 140, //坐标 'shadow' => '#ffffff', //背景颜色 'shadow_size' => 1, //阴影距离 'angle' => 18, //角度数值逆时针旋转 ) ); //设置字体 $FoundPHP_image->font( array( 'str' => 'FoundPHP 框架真好用', //文字 'color' => '#00a9f5', //颜色 'size' => 20, //尺寸 'x' => 20, //坐标 'y' => 180, //坐标 'shadow' => '#000000', //背景颜色 'shadow_size' => 2, //阴影距离 'angle' => 18, //角度数值逆时针旋转 ) ); //标准缩放 $FoundPHP_image->resize(array( 'width' =>400, 'height' =>400, 'cut' =>1, //1切图,0不切图 'zoom' =>1, //按比例缩放 )); $FoundPHP_image->save('foundphp_new'); ``` 实现效果: ![](data/files/edit/20/05/08/200508_15204331.jpg)
###自定义段落文字 ------------ 当制作协议的时候我们需要段落文字,这时候我们就可以采用段落的方法,目前只适配了英文单词换行,中文utf8未做适配。 ```php $FoundPHP_image->image('bg.jpg'); //设置段落 $FoundPHP_image->word( array( 'str' => ' Imagine life as a game in which you are juggling some five balls in the air. You name them work, family, health, friends and spirit and you’re keeping all of these in the air. You will soon understand that work is a rubber ball. If you drop it, it will bounce back.But the other four balls family, health, friends and spirit are made of glass. If you drop one of these, they will be irrevocably scuffed, marked, nicked, damaged or even shattered. They will never be the same. You must understand that and strive for balance in your life. How?', 'x' => 106, //开始左边距 'y' => 16, //开始顶边距 'left' => 108, //范围宽度左边 'right' => 1578, //范围宽度右边 'line' => 3, //有效显示行数 'line_height' => 57, //行高度像素 ) ); //标准缩放 $FoundPHP_image->resize(array( 'width' =>400, 'height' =>400, 'cut' =>1, //1切图,0不切图 'zoom' =>1, //按比例缩放 )); $FoundPHP_image->save('foundphp_new'); ``` 实现一篇文章自动换行自动适应文字,保证文字不出现溢出的现象 实现效果: ![](data/files/edit/22/10/24/221024_23427577.jpg)