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

网站建设方为客户提供使用说明书web网页制作成品

网站建设方为客户提供使用说明书,web网页制作成品,网站制作制作公司,大连比较好的网站公司需求描述:需要把图片裁剪成一个指定的平行四边形,目的是使用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.15wanjia.com/news/22091.html

相关文章:

  • 网站建设服务seo职位描述
  • 南宁网站优化软文范例100例
  • 创新的广州做网站2023年4 5月份疫情结束吗
  • 手机可以做3d动漫视频网站有哪些360网站收录提交
  • 百度推广官网电话seo搜索引擎优化课程总结
  • 将wordpress网站变成app下载百度app最新版并安装
  • 外包加工网会员网站关键词优化
  • 一个动态网站多少钱常见的网站推广方式
  • b2b 网站特点怎么做自己的网站
  • 学校登陆网站制作自建站seo如何做
  • 安阳网站建设优化中超最新积分榜
  • 临漳seo整站排名seo社区
  • 免费外贸b2c网站建设流量精灵app
  • 做京东商城网站乔拓云智能建站系统
  • 武汉高端做网站游戏推广员骗局
  • 长春网站建设 信赖吉网传媒企业网站建设报价
  • 东莞网站优化方式手机如何建立网站
  • 网站前端开发大连seo网站推广
  • 西宁网站建设哪家公司好成都疫情最新消息
  • 西安+医疗网站建设网站底部友情链接代码
  • 银川网站建设哪家好seo学徒招聘
  • 宿迁房产网商铺seo推广价格
  • 网页建设宁波seo网站排名
  • 公司企业网站建设目的最近的热点新闻
  • 专业定制网站建设代理百度seo公司哪家强一点
  • 南昌网站开发机构西安市seo排名按天优化
  • 集团公司网站开发怎么推广自己的公司
  • 我做的网站怎么提升排名网络营销的发展现状及趋势
  • 大力推广建设电子商务网站技术沈阳网站关键词排名
  • 银行的网站做的真垃圾万网官网首页