FoundPHP 照片:水印
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(右下角) |
图例:
切图水印居中打水印
$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');
实现效果:
切图左上角旋转水印图
旋转特殊角度会造成照片部分丢失
$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');
实现效果:
补色jpg照片调整透明度的水印
为了让你看的更清楚,我们采用了红色背景设置水印透明60%
$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');
实现效果: