php生成圆角图片大屏查看

发布于:2016年06月16日 已被阅读

<?php


// $png = imagecreatefrompng('2.png');

// $jpeg = imagecreatefromjpeg('scene_1.jpg');


// list($width, $height) = getimagesize('scene_1.jpg');

// list($newwidth, $newheight) = getimagesize('2.png');

// $out = imagecreatetruecolor($width, $height);

// imagecopyresampled($out, $jpeg, 0, 0, 0, 0, $width, $height, $width, $height);

// imagecopyresampled($out, $png, 0, 0, 0, 0, $newwidth, $newheight, $newwidth, $newheight);

// imagejpeg($out, 'out.jpg', 100);

/** 圆角

$radius = 100;

$img = imagecreatetruecolor($radius, $radius); // 创建一个正方形的图像

$bgcolor = imagecolorallocate($img, 223, 0, 0); // 图像的背景

$fgcolor = imagecolorallocate($img, 0, 0, 0);

imagefill($img, 0, 0, $bgcolor);

// $radius,$radius:以图像的右下角开始画弧

// $radius*2, $radius*2:已宽度、高度画弧

// 180, 270:指定了角度的起始和结束点

// fgcolor:指定颜色

imagefilledarc($img, $radius, $radius, $radius*2, $radius*2, 180, 270, $fgcolor, IMG_ARC_PIE);

// 将弧角图片的颜色设置为透明

imagecolortransparent($img, $fgcolor);

// 变换角度

// $img = imagerotate($img, 90, 0);

// $img = imagerotate($img, 180, 0);

// $img = imagerotate($img, 270, 0);

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

imagepng($img);

**/

function get_lt_rounder_corner($radius) {

$img = imagecreatetruecolor($radius, $radius); // 创建一个正方形的图像

$bgcolor = imagecolorallocate($img, 255, 255, 255); // 图像的背景

$fgcolor = imagecolorallocate($img, 0, 0, 0);

imagefill($img, 0, 0, $bgcolor);

// $radius,$radius:以图像的右下角开始画弧

// $radius*2, $radius*2:已宽度、高度画弧

// 180, 270:指定了角度的起始和结束点

// fgcolor:指定颜色

imagefilledarc($img, $radius, $radius, $radius*2, $radius*2, 180, 270, $fgcolor, IMG_ARC_PIE);

// 将弧角图片的颜色设置为透明

imagecolortransparent($img, $fgcolor);

// 变换角度

// $img = imagerotate($img, 90, 0);

// $img = imagerotate($img, 180, 0);

// $img = imagerotate($img, 270, 0);

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

// imagepng($img);

return $img;

}


$image_width = 220;

$image_height = 220;

$resource = imagecreatefromjpeg('logo_1.jpg');


// $resource = imagecreatetruecolor($image_width, $image_height); // 创建一个正方形的图像

$bgcolor = imagecolorallocate($resource, 223, 223, 0); // 图像的背景

imagefill($resource, 0, 0, $bgcolor);


// 圆角处理

$radius = 110;

// lt(左上角)

$lt_corner = get_lt_rounder_corner($radius);

imagecopymerge($resource, $lt_corner, 0, 0, 0, 0, $radius, $radius, 100);

// lb(左下角)

$lb_corner = imagerotate($lt_corner, 90, 0);

imagecopymerge($resource, $lb_corner, 0, $image_height - $radius, 0, 0, $radius, $radius, 100);

// rb(右上角)

$rb_corner = imagerotate($lt_corner, 180, 0);

imagecopymerge($resource, $rb_corner, $image_width - $radius, $image_height - $radius, 0, 0, $radius, $radius, 100);

// rt(右下角)

$rt_corner = imagerotate($lt_corner, 270, 0);

imagecopymerge($resource, $rt_corner, $image_width - $radius, 0, 0, 0, $radius, $radius, 100);


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

imagepng($resource);

exit;

?>


最新发布
linux下svn提交忽略某些文件... (173)
使用批处理来批量更新、提交SVN... (135)
linux查看目录文件大小命令 (145)
linux tar打包压缩排除某个... (133)
Linux tar压缩和解压 (192)
SVN子命令add用法浅析 (129)
热门博文
网友FBI探案:马蓉iPad惊人发现... (43343)
霍金携手俄罗斯富豪耗资1亿美元寻找外... (4746)
如何才能查看PHP内置函数源代码... (1209)
微信支付开发当前URL未注册的解决方... (573)
《谁为爱情买单》中的经典面试 ... (441)
让虚拟主机也用上SVN:适用于个人的... (394)
精华博文
[推荐]Centos7 安装配置 SVN (156)
easyswoole框架安装 (173)
php开启pecl的支持(推荐) (157)
1-10个恋爱表现:男朋友爱你程度到... (163)
女生喜欢你的10个程度,到第六个就可... (141)
Eclipse 没有Server选项... (211)
友情链接
我来忙 (110)