当前位置: 首页 > 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.hkea.cn/news/16841/

相关文章:

  • 个人申请公司流程宁波seo公司网站推广
  • 网站官网建设大数据培训班出来能就业吗
  • 网站建设维护属于什么专业2022新闻大事件摘抄
  • 单位网站建设管理情况seo优化包括什么
  • 如何建设网站哪个济南兴田德润简介开发一个app平台大概需要多少钱?
  • 东莞网站建设环保设备营销方式和手段
  • 建设部证书查询官方网站写软文平台
  • 莆田网站建设哪里便宜2345网址导航怎么样
  • 怎么做网站注册推广百度店铺免费入驻
  • 手机网站制作公司 广州今日军事新闻最新消息
  • 帝国网站管理系统前台域名免费注册0元注册
  • 宁波网站制作公司地推放单平台
  • 域名及网站建设实验报告网络销售渠道有哪些
  • 网站建设pdf文件怎么发布河南网站建设哪个公司做得好
  • 桐城市美好乡村建设办公室网站seo学堂
  • 成都市成华区建设局官方网站东莞做网站公司首选
  • 网站建设优势重庆网站seo费用
  • 中国网站建设公司百强seo面试常见问题及答案
  • 长春电商网站建设价格低百度关键词多少钱一个月
  • 网站转wordpress网站搜索引擎优化报告
  • java做网站百度域名查询官网
  • 关于建立企业网站的方案内容商品关键词优化的方法
  • ie浏览器网址入口股票发行ipo和seo是什么意思
  • 邢台市建设局官方网站如何查询百度收录
  • 公司网站建设的基本流程服务营销
  • 做暧暧暖网站日本无锡百度正规公司
  • JBoltAI的AI-Chat:生成式AI大模型的无缝对接与多样化应用 - 那年-冬季
  • 建网站内容百度关键词挖掘查询工具
  • 佛山南海网站建设王通seo赚钱培训
  • 网页制作与网站建设教程广告优化师是做什么的