首页
开发手册
应用中心
工具
用户中心
FoundPHP 照片:水印
中文简体
中文简体
English
上一篇
下一篇
#FoundPHP 照片:水印 `框架下默认集成 FoundPHP_image 支持格式:jpg、jpeg、png、gif` `应用库地址:class/image/resize.php` `采用GD库php默认memory_limit是128M,如果需要处理大尺寸照片修改512M以上。` **采用缩放zoom的时候可以用xy定位,默认中间定位** | 左侧 | 中部 | 右侧 | | ------------ | ------------ | ------------ | | tl(左上角) |
top(顶部)
| tr(右上角) | | left(左边) |
center(居中)
| right(右边) | | bl(左下角) |
bottom(底部)
| br(右下角) |
**图例:** ![](data/files/edit/20/05/03/200503_00152031.jpg) ###切图水印居中打水印 ```php $FoundPHP_image->image('foundphp.jpg'); //设置图片水印 $FoundPHP_image->mark( array( 'img' =>'FoundPHP_mini.png', //水印照片 'xy' =>'center', //居中显示 'x' =>10, //左移动10像素 'y' =>10, //右移动10像素 ) ); $FoundPHP_image->resize(array( 'width' =>400, 'height' =>400, 'cut' =>1, //1切图,0不切图 'zoom' =>0, )); $FoundPHP_image->save('foundphp_new'); ``` 实现效果: ![](data/files/edit/20/05/05/200505_16586561.jpg)
###切图左上角旋转水印图 旋转特殊角度会造成照片部分丢失 ```php $FoundPHP_image->image('foundphp.jpg'); //设置图片水印 $FoundPHP_image->mark( array( 'img' =>'FoundPHP_mini.png', //水印照片 'xy' =>'tl', //居中显示 'angle' => 90, //角度数值逆时针旋转 'x' =>10, //左移动10像素 'y' =>10, //右移动10像素 ) ); $FoundPHP_image->resize(array( 'width' =>400, 'height' =>400, 'cut' =>1, //1切图,0不切图 'zoom' =>0, )); $FoundPHP_image->save('foundphp_new'); ``` 实现效果: ![](data/files/edit/20/05/05/200505_17008087.jpg)
###补色jpg照片调整透明度的水印 为了让你看的更清楚,我们采用了红色背景设置水印透明60% ```php $FoundPHP_image->image('foundphp.jpg'); //设置图片水印 $FoundPHP_image->mark( array( 'img' =>'FoundPHP_icon.jpg', //水印照片 'xy' =>'br', //居中显示 'alpha' => 60, //透明度 ) ); $FoundPHP_image->resize(array( 'width' =>400, 'height' =>400, 'cut' =>0, //1切图,0不切图 'zoom' =>1, 'bgcolor' =>'#800000', //png 与gif 透明设置无效 )); $FoundPHP_image->save('foundphp_new'); ``` 实现效果: ![](data/files/edit/20/05/05/200505_17171820.jpg)