当前位置: 首页 > news >正文

湖南省金力电力建设有限公司 网站网络营销以什么为中心

湖南省金力电力建设有限公司 网站,网络营销以什么为中心,网络域名多少钱一年,长沙市网站建设公司需求描述:需要把图片裁剪成一个指定的平行四边形,目的是使用GD库,把裁剪后的图片放在底图上面,使最终合成的图片看起来是一个底图平行四边形的样子提示:可以结合本作者的其他文章,来生成一个定制化的海报&a…

需求描述:需要把图片裁剪成一个指定的平行四边形,目的是使用GD库,把裁剪后的图片放在底图上面,使最终合成的图片看起来是一个底图+平行四边形的样子

提示:可以结合本作者的其他文章,来生成一个定制化的海报(到此为止,定制化海报生成的所有知识点就写完了,大家可以自己看看那部分是自己需要,可以自己获取相应部分)

解决方案:第一步便是生成矩形的图片,但是经过测试后发现,无论是使用GD库还是使用PS,最终的图片还是一个矩形,并不能真正的实现把图片裁剪成为自己想要的形状,那么一种方案行不通那就换成另外一种方案,使用遮蔽物遮挡,把图片变成我们想要的形状,比如左边的三角形和右边的三角形,这两个形状就是使用imagefilledpolygon函数绘制填充的多边形来填充,最终获取到想要的图案

示例图:

//图片像素点

public function pixels(){

$imgpath = '地址';

$image = $this->createImageFromFile($imgpath);

//定位(左边渲染块)

$values = array(

0, 0, // Point 1 (x, y)

0, 420, // Point 2 (x, y)

100, 0 // Point 3 (x, y)

);

//获取颜色

$gr = imagecolorallocate($image, 228, 251, 255);

imagefilledpolygon($image, $values, 3, $gr);

//定位(右边渲染块)

$values = array(

420, 420,

420, 0,

320, 420

);

$gr = imagecolorallocate($image, 228, 251, 255);

imagefilledpolygon($image, $values, 3, $gr);

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

imagepng($image);

}

//获取图片类型,从字符串中的图像流新建一图像:非本地图片获取图像流生成本地图片

function createImageFromFile($file)

{

if (preg_match('/http(s)?:\/\//', $file)) {

$fileSuffix = $this->getNetworkImgType($file);

} else {

$fileSuffix = pathinfo($file, PATHINFO_EXTENSION);

}

if (!$fileSuffix) return false;

switch ($fileSuffix) {

case 'jpeg':

if (!strpos($file, 'qnimg.ruwii.com') && !strpos($file, 'upload')) {

// imagecreatefromstring:从字符串中的图像流新建一图像, 返回一个图像标识符,其表达了从给定字符串得来的图像

$theImage = @imagecreatefromstring($this->http_get_data($file));

} else {

$theImage = @imagecreatefromjpeg($file);

if (!$theImage) {

$theImage = @imagecreatefromstring($this->http_get_data($file));

}

}

break;

case 'jpg':

if (!strpos($file, 'qnimg.ruwii.com') && !strpos($file, 'upload')) {

$theImage = @imagecreatefromstring($this->http_get_data($file));

} else {

$theImage = @imagecreatefromjpeg($file);

if (!$theImage) {

$theImage = @imagecreatefromstring($this->http_get_data($file));

}

}

break;

case 'png':

if (!strpos($file, 'qnimg.ruwii.com') && !strpos($file, 'upload')) {

$theImage = @imagecreatefromstring($this->http_get_data($file));

} else {

$theImage = @imagecreatefrompng($file);

if (!$theImage) {

$theImage = @imagecreatefromstring($this->http_get_data($file));

}

}

break;

case 'gif':

if (!strpos($file, 'qnimg.ruwii.com') && !strpos($file, 'upload')) {

$theImage = @imagecreatefromstring($this->http_get_data($file));

} else {

$theImage = @imagecreatefromgif($file);

if (!$theImage) {

$theImage = @imagecreatefromstring($this->http_get_data($file));

}

}

break;

default:

$theImage = @imagecreatefromstring($this->http_get_data($file));

break;

}

return $theImage;

}

//获取图片类型

private function getNetworkImgType($url)

{

$ch = curl_init(); //初始化curl

curl_setopt($ch, CURLOPT_URL, $url); //设置需要获取的URL

curl_setopt($ch, CURLOPT_NOBODY, 1);

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);//设置超时

curl_setopt($ch, CURLOPT_TIMEOUT, 3);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //支持https

curl_exec($ch);//执行curl会话

$http_code = curl_getinfo($ch);//获取curl连接资源句柄信息

curl_close($ch);//关闭资源连接

if ($http_code['http_code'] == 200) {

$theImgType = explode('/', $http_code['content_type']);

if ($theImgType[0] == 'image') {

return $theImgType[1];

} else {

return false;

}

} else {

return false;

}

}

//获取远程图片

function http_get_data($url)

{

$ch = curl_init();

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_URL, $url);

ob_start();

curl_exec($ch);

$return_content = ob_get_contents();

ob_end_clean();

curl_getinfo($ch, CURLINFO_HTTP_CODE);

return $return_content;

}

http://www.ritt.cn/news/16501.html

相关文章:

  • 做网站用什么格式的图片中国十大网络销售公司
  • 青岛电商网站制作南京seo优化培训
  • 做网站的大骗子网站优化公司上海
  • asp语言网站建设网站关键词查询网址
  • 用phython做网站seo推广方案怎么做
  • 海南中小企业网站建设今日头条普通版
  • 前端做一个页面多少钱seo网站优化培训找哪些
  • 从哪里设置网站关键词独立站怎么建站
  • 自己用钢管做里闪弹枪视频和照网站河南优化网站
  • 做网站字体要求搜索引擎优化原理
  • 建站网站知乎广州营销型网站
  • 如何制作局域网站百度网盘seo优化
  • cad dwt模板做网站模版站长工具关键词查询
  • 锋创科技园网站建设聊城seo整站优化报价
  • 增加网站点击量微信广点通广告平台
  • 做网站 修复漏洞推广赚钱的软件排行
  • 重庆市设计公司网站青岛网站排名提升
  • 会泽做网站搜索引擎优化作业
  • php做购物网站详情页的代码seo专业课程
  • 灵溪网站建设网店代运营一年的费用是多少
  • 网站地区词优化百度ai助手入口
  • 网站购物车怎么做seo排名快速刷
  • 做购物网站开发价格百度快照投诉中心
  • 湖南现在有疫情吗最新消息郑州seo排名第一
  • 广州网站建设信科公司广州推广系统
  • 绵阳网络公司网站建设seo分析
  • 法与家国建设征文网站怎样做网络推广营销
  • 单页面网站怎么做品牌形象推广
  • 网站建设属于应用软件吗宁波seo哪家好快速推广
  • 广东建设监理网站安徽seo推广公司