php 生成多个水印,php如何实现图片合成并生成水印(完整代码)

本篇文章给大家带来的内容是关于php如何实现图片合成并生成水印(完整代码),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。<?php

$dst_path ='./upload/goods/2018/06-04/2bd2518a2e4e6d8bdab9f01434b9f754.png';

$src_path = './public/upload/weixin/20180620/a643cf1ee7dd5bda12270647ca543f60.png';

$hz = substr(strrchr($dst_path, '.'), 1);

$image = date("YmdHis").rand(100000,999999).".".$hz;

//创建图片的实例

$dst = imagecreatefromstring(file_get_contents($dst_path));

$src = imagecreatefromstring(file_get_contents($src_path));

//获取水印图片的宽高

$src_w =139;$src_h=58;

list($src_w,$src_h) = getimagesize($src_path);

//如果水印图片本身带透明色,则使用imagecopy方法

imagecopy($dst, $src, 85,85, 0, 0, $src_w, $src_h);

//输出图片

list($src_w, $src_h, $dst_type) = getimagesize($dst_path);

switch ($dst_type) {

case 1://GIF

header('Content-Type: image/gif');

imagegif($dst,".".$image);

break;

case 2://JPG

header('Content-Type: image/jpeg');

imagejpeg($dst,".".$image);

break;

case 3://PNG

header('Content-Type: image/png');

imagepng($dst,".".$image);

break;

default:

break;

}

imagedestroy($dst);

imagedestroy($src);

return $image;

相关推荐:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值