发表时间:2017-06-08来源:网络
php生成圆角图片的方法 电脑中php怎么生成圆角图片教程。我们在使用电脑的时候,总是会遇到很多的的电脑难题。当我们需要在电脑中使用PHP生成圆角图片的时候,我们应该怎么操作呢?一起来看看吧。
具体如下:
代码如下:
<?php
$image_file = $_GET['src'];
$corner_radius = isset($_GET['radius']) ? $_GET['radius'] : 20; // The default corner radius is set to 20px
$topleft = (isset($_GET['topleft']) and $_GET['topleft'] == "no") ? false : true; // Top-left rounded corner is shown by default
$bottomleft = (isset($_GET['bottomleft']) and $_GET['bottomleft'] == "no") ? false : true; // Bottom-left rounded corner is shown by default
$bottomright = (isset($_GET['bottomright']) and $_GET['bottomright'] == "no") ? false : true; // Bottom-right rounded corner is shown by default
$topright = (isset($_GET['topright']) and $_GET['topright'] == "no") ? false : true; // Top-right rounded corner is shown by default
$imagetype=strtolower($_GET['imagetype']);
$backcolor=$_GET['backcolor'];
$endsize=$corner_radius;
$startsize=$endsize*3-1;
$arcsize=$startsize*2+1;
if (($imagetype=='jpeg') or ($imagetype=='jpg')) {
$image = imagecreatefromjpeg($image_file);
} else {
if (($imagetype=='GIF') or ($imagetype=='gif')) {
$image = imagecreatefromgif($image_file);
} else {
$image = imagecreatefrompng($image_file);
}
}
$size = getimagesize($image_file);
// Top-left corner
$background = imagecreatetruecolor($size[0],$size[1]);
imagecopymerge($background,$image,0,0,0,0,$size[0],$size[1],100);
$startx=$size[0]*2-1;
$starty=$size[1]*2-1;
$im_temp = imagecreatetruecolor($startx,$starty);
imagecopyresampled($im_temp, $background, 0, 0, 0, 0, $startx, $starty, $size[0], $size[1]);
$bg = imagecolorallocate($im_temp, hexdec(substr($backcolor,0,2)),hexdec(substr($backcolor,2,2)),hexdec(substr($backcolor,4,2)));
$fg = imagecolorallocate($im_temp, hexdec(substr($forecolor,0,2)),hexdec(substr($forecolor,2,2)),hexdec(substr($forecolor,4,2)));
if ($topleft == true) {
imagearc($im_temp, $startsize, $startsize, $arcsize, $arcsize, 180,270,$bg);
imagefilltoborder($im_temp,0,0,$bg,$bg);
}
// Bottom-left corner
if ($bottomleft == true) {
imagearc($im_temp,$startsize,$starty-$startsize,$arcsize,$arcsize,90,180,$bg);
imagefilltoborder($im_temp,0,$starty,$bg,$bg);
}
// Bottom-right corner
if ($bottomright == true) {
imagearc($im_temp, $startx-$startsize, $starty-$startsize,$arcsize, $arcsize, 0,90,$bg);
imagefilltoborder($im_temp,$startx,$starty,$bg,$bg);
}
// Top-right corner
if ($topright == true) {
imagearc($im_temp, $startx-$startsize, $startsize,$arcsize, $arcsize, 270,360,$bg);
imagefilltoborder($im_temp,$startx,0,$bg,$bg);
}
$newimage = imagecreatetruecolor($size[0],$size[1]);
imagecopyresampled($image,$im_temp,0,0,0,0,$size[0],$size[1],$startx,$starty);
// Output final image
header("Content-type: image/png");
imagepng($image);
imagedestroy($image);
imagedestroy($background);
imagedestroy($im_temp);
?>
CI框架连接数据库配置操作以及多数据库操作
asp 简单读取数据表并列出来 ASP如何快速从数据库读取大量数据
C语言关键字及其解释介绍 C语言32个关键字详解
C语言中sizeof是什么意思 c语言里sizeof怎样用法详解
最简单的asp登陆界面代码 asp登陆界面源代码详细介绍
PHP中的魔术方法 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep,
PHP中include和require区别之我见
PHP中的(++i)前缀自增 和 (i++)后缀自增
将视频设置为Android手机开机动画的教程
php递归返回值的问题
掌上小满app(又名OKKI)下载v6.24.2 安卓版
108.1M |商务办公
星巴克中国官方版app下载v10.9.3 安卓版
138.0M |生活服务
abc reading app手机版下载v7.3.35 安卓最新版本
218.9M |学习教育
智慧联想摄像头app(更名智享家)下载v4.1.6.2 安卓最新版本
211.4M |生活服务
星通货主app下载v902 安卓版
142.5M |生活服务
火花思维官方版下载v2.1.1 安卓手机版
208.6M |学习教育
火山小视频极速版2025(改名抖音火山版)下载v33.4.0 安卓官方正版
248.5M |影音播放
泰州通app下载v2.2.2 安卓版
126.9M |商务办公
2022-03-21
2022-03-17
2014-09-05
2014-09-05
2015-07-05
2022-03-21
2014-09-05
2014-09-05
2014-09-05
2022-03-20