curl+imagick,获取远程图片并且添加水印

//$fimg = file_get_contents('https://image.dapengjiaoyu.com/2019/05/e7e1160a8fd0eca5fa30494c31b47283.gif','rbw');

$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, 'GET' );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt ( $ch, CURLOPT_URL, 'https://image.dapengjiaoyu.com/2019/05/e7e1160a8fd0eca5fa30494c31b47283.gif' );
ob_start ();
curl_exec ($ch);
$return_content = ob_get_contents();
ob_end_clean ();
//$return_code = curl_getinfo ( $ch, CURLINFO_HTTP_CODE );

//$imagick = new Imagick();
//创建一个Imagick对象,同时获取要处理的源图
$imagick = new Imagick();
$imagick->readImageBlob($return_content);

//$url = 'http://local.dpwap_new.com/001.gif';
//$im = file_get_contents($url,0,null,0,1);
//ob_start();//打开输出
//readfile($url);//输出图片文件
//$img = ob_get_contents();//得到浏览器输出
//var_dump($img);
//ob_end_clean();//清除输出并关闭
//$imagick->readImageFile($fimg);
$draw = new ImagickDraw ();
$draw->setFontSize(20);
$draw->setFillColor('#FF0000');
$draw->settextencoding('UTF-8');
$width = $imagick->getImageWidth();
$height = $imagick->getImageHeight();
foreach ( $imagick as $frame ) {
$frame->annotateImage ($draw, 9, 20, 0, '777');
}
header('Content-type: ' . strtolower($imagick->getImageFormat()));
//$imagick->writeImage('002.gif');
echo $imagick->getImagesBlob();
添加水印
//$im->compositeImage($logo,Imagick::COMPOSITE_OVER,$srcW['width']-280,$srcH['height']-77);

转载于:https://www.cnblogs.com/i6010/articles/10937815.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值