图片上添加描边字和马赛克php代码
<?php教程
/**
* gd image mask
*
* @copyright ugia.cn
*/
function imagemask(&$im, $x1, $y1, $x2, $y2, $deep)
{
for($x = $x1; $x < $x2; $x += $deep)
{
for ($y = $y1; $y < $y2; $y += $deep)
{
$color = imagecolorat ($im, $x + round($deep / 2), $y + round($deep / 2));
imagefilledrectangle ($im, $x, $y, $x + $deep, $y + $deep, $color);
}
}
}
?>
示例:
<?php
header("content-type: image/png");
$im = imagecreatefromjpeg("test.jpg");
imagemask($im, 57, 22, 103, 40, 8);
imagepng($im);
imagedestroy($im);
?>
<?php
/**
* gd image text outer
*
* @copyright ugia.cn
*/
function imagetextouter(&$im, $size, $x, $y, $color, $fontfile, $text, $outer)
{
if (!function_exists('imagecolorallocatehex'))
{
function imagecolorallocatehex($im, $s)
{
if($s{0} == "#") $s = substr($s,1);
$bg_dec = hexdec($s);
return imagecolorallocate($im,
($bg_dec & 0xff0000) >> 16,
($bg_dec & 0x00ff00) >> 8,
($bg_dec & 0x0000ff)
);
}
}
$ttf = false;
if (is_file($fontfile))
{
$ttf = true;
$area = imagettfbbox($size, $angle, $fontfile, $text);
$width = $area[2] - $area[0] + 2;
$height = $area[1] - $area[5] + 2;
}
else
{
$width = strlen($text) * 10;
$height = 16;
}
$im_tmp = imagecreate($width, $height);
$white = imagecolorallocate($im_tmp, 255, 255, 255);
$black = imagecolorallocate($im_tmp, 0, 0, 0);
$color = imagecolorallocatehex($im, $color);
$outer = imagecolorallocatehex($im, $outer);
if ($ttf)
{
imagettftext($im_tmp, $size, 0, 0, $height - 2, $black, $fontfile, $text);
imagettftext($im, $size, 0, $x, $y, $color, $fontfile, $text);
$y = $y - $height + 2;
}
else
{
imagestring($im_tmp, $size, 0, 0, $text, $black);
imagestring($im, $size, $x, $y, $text, $color);
}
for ($i = 0; $i < $width; $i ++)
{
for ($j = 0; $j < $height; $j ++)
{
$c = imagecolorat($im_tmp, $i, $j);
if ($c !== $white)
{
imagecolorat ($im_tmp, $i, $j - 1) != $white || imagesetpixel($im, $x + $i, $y + $j - 1, $outer);
imagecolorat ($im_tmp, $i, $j + 1) != $white || imagesetpixel($im, $x + $i, $y + $j + 1, $outer);
imagecolorat ($im_tmp, $i - 1, $j) != $white || imagesetpixel($im, $x + $i - 1, $y + $j, $outer);
imagecolorat ($im_tmp, $i + 1, $j) != $white || imagesetpixel($im, $x + $i + 1, $y + $j, $outer);
// 取消注释,与fireworks的发光效果相同
/*
imagecolorat ($im_tmp, $i - 1, $j - 1) != $white || imagesetpixel($im, $x + $i - 1, $y + $j - 1, $outer);
imagecolorat ($im_tmp, $i + 1, $j - 1) != $white || imagesetpixel($im, $x + $i + 1, $y + $j - 1, $outer);
imagecolorat ($im_tmp, $i - 1, $j + 1) != $white || imagesetpixel($im, $x + $i - 1, $y + $j + 1, $outer);
imagecolorat ($im_tmp, $i + 1, $j + 1) != $white || imagesetpixel($im, $x + $i + 1, $y + $j + 1, $outer);
*/
}
}
}
imagedestroy($im_tmp);
}
?>
示例:
<?php
header("content-type: image/png");
$im = imagecreatefromjpeg("bluesky.jpg");
$white = imagecolorallocate($im, 255,255,255);
imagetextouter($im, 9, 10, 20, '#000000', "simsun.ttc", '新年快乐', '#ffffff');
imagetextouter($im, 2, 10, 30, '#ffff00', "", 'hello, world!' , '#103993');
imagepng($im);
imagedestroy($im);
?>
马赛克:void imagemask ( resource image, int x1, int y1, int x2, int y2, int deep)
imagemask() 把坐标 x1,y1 到 x2,y2(图像左上角为 0, 0)的矩形区域加上马赛克。
deep为模糊程度,数字越大越模糊。
描边:void imagetextouter ( resource image, int size, int x, int y, string color, string fontfile, string text, string outercolor)
imagetextouter() 将字符串 text 画到 image 所代表的图像上,从坐标 x,y(左上角为 0, 0)开始,颜色为 color,边框所使用的颜色为 outercolor,使用 fontfile 所指定的 truetype 字体文件。
如果不指定字体文件,则使用gd的内部字体。根据 php 所使用的 gd 库的不同,如果 fontfile 没有以 ‘/’开头,则 ‘.ttf’ 将被加到文件名之后并且会搜索库定义字体路径。
如果指定了字体文件,由 x,y 所表示的坐标定义了第一个字符的基本点(大概是字符的左下角)。否则 x,y 定义了第一个字符的右上角。
fontfile 是想要使用的 truetype 字体的文件名。
text 是文本字符串,可以包含 utf-8 字符序列(形式为:{)来访问字体中超过前 255 个的字符。
color 是十六进制的#rrggbb格式的颜色,如#ff0000为红色。
outercolor 描边颜色,十六进制的#rrggbb格式。
提供一款超完美的php文件在线压缩程序,原理很简单就是把文件以二进制形式保存了,以前用过利用rar的内核程序,这是php自带的压缩功能。代码如下 | 复制代码 |
set_time_limit(0); var $file_count = 0 ; /* if ($timearray['year'] < 1980) { return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | if($this->fp=@fopen($this->gzfilename,"w")){ |
这款国外的php图片上传代码是一款好的文件与图片上传代码,并且还支持文件在线管理哦,是一款比较的好图片管理系统哦。
代码如下 | 复制代码 |
define('max', 2); if ($zip) { // recently uploaded query $q = mysql_query('select count(`id`) as `count` from `uploads`'); if ($_get['p'] == 'help') { } elseif ($_get['p'] == 'terms-of-service') { } else { } while($r = mysql_fetch_assoc($q)) { ?> } } switch ($_get['error']) { } ?????? css?? #slider { #slider h3 { #slider #slide #image { |
源码下载地址
http://down.111cn.net/php/2010/0927/20956.html
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style>
#container {
margin: auto;
width: 400px;
border-top-width: 0px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #000033;
border-right-color: #000033;
border-bottom-color: #000033;
border-left-color: #000033;
background-color: #ffffff;
}
#container #header #header_left {
float: left;
background-image: url(images/header_left.gif);
background-repeat: no-repeat;
height: 42px;
width: 45px;
}
#container #header #header_right {
background-image: url(images/header_right.gif);
background-repeat: no-repeat;
height: 42px;
width: 6px;
float: right;
}
body {
padding-top: 30px;
background-color: #cccccc;
}
#container #content {
padding: 5px;
font-family: geneva, arial, helvetica, sans-serif;
font-size: 12px;
font-weight: normal;
color: #666666;
}
#container #footer {
font-family: geneva, arial, helvetica, sans-serif;
font-size: 12px;
color: #999999;
text-align: right;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-top-color: #999999;
border-right-color: #000033;
border-bottom-color: #000033;
border-left-color: #000033;
padding-top: 5px;
padding-right: 10px;
padding-bottom: 5px;
padding-left: 5px;
}
#container #footer a {
color: #999999;
text-decoration: none;
font-family: geneva, arial, helvetica, sans-serif;
font-size: 10px;
}
#container #header #header_main {
float: left;
padding: 5px;
font-family: geneva, arial, helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
color: #ffffff;
margin-top: 5px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
.sbtn {
background-image: url(images/button.gif);
border: 1px solid #000033;
height: 22px;
width: 82px;
font-family: geneva, arial, helvetica, sans-serif;
font-size: 12px;
color: #ffffff;
font-weight: bold;
background-position: center;
padding: 0px;
margin-top: 20px;
margin-right: 20px;
margin-bottom: 0px;
margin-left: 20px;
}
button {
font-family: geneva, arial, helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
color: #ffffff;
height: 22px;
width: 82px;
background-image: url(images/button.gif);
}
#container #content #form1 legend {
padding: 5px;
margin: auto;
}
form {
margin: 10px 5px 0px 5px;
}
#container #header {
padding: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
background-image: url(images/header_bg.gif);
background-repeat: repeat-x;
height: 42px;
}
label {
padding: 0px;
text-align: center;
}
.msg {
text-align:left;
color:#666;
background-repeat: no-repeat;
margin-left:30px;
margin-right:30px;
padding:5px;
padding-left:30px;
}
.emsg {
text-align:left;
margin-left:30px;
margin-right:30px;
color:#666;
background-repeat: no-repeat;
padding:5px;
padding-left:30px;
}
#loader{
visibility:hidden;
}
#f1_upload_form{
height:100px;
}
#f1_error{
font-family: geneva, arial, helvetica, sans-serif;
font-size: 12px;
font-weight:bold;
color:#ff0000;
}
#f1_ok{
font-family: geneva, arial, helvetica, sans-serif;
font-size: 12px;
font-weight:bold;
color:#00ff00;
}
#f1_upload_form {
font-family: geneva, arial, helvetica, sans-serif;
font-size: 12px;
font-weight: normal;
color: #666666;
}
#f1_upload_process{
z-index:100;
visibility:hidden;
position:absolute;
text-align:center;
width:400px;
}
</style>
<script language="网页特效" type="text/javascript">
<!--
function startupload(){
document.getelementbyid('f1_upload_process').style.visibility = 'visible';
document.getelementbyid('f1_upload_form').style.visibility = 'hidden';
return true;
}
function stopupload(success){
var result = '';
if (success == 1){
result = '<span class="msg">the file was uploaded successfully!</span><br/><br/>';
}
else {
result = '<span class="emsg">there was an error during file upload!</span><br/><br/>';
}
document.getelementbyid('f1_upload_process').style.visibility = 'hidden';
document.getelementbyid('f1_upload_form').innerhtml = result + '<label>file: <input name="myfile" type="file" size="30" /></label><label><input type="submit" name="submitbtn" class="sbtn" value="upload" /></label>';
document.getelementbyid('f1_upload_form').style.visibility = 'visible';
return true;
}
//-->
</script>
</head>
<body>
<div id="container">
<div id="header"><div id="header_left"></div>
<div id="header_main">max's ajax file uploader</div><div id="header_right"></div></div>
<div id="content">
<form action="upload.php" method="post" enctype="multipart/form-data" target="upload_target" onsubmit="startupload();" >
<p id="f1_upload_process">loading...<br/><img src="loader.gif" /><br/></p>
<p id="f1_upload_form" align="center"><br/>
<label>file:
<input name="myfile" type="file" size="30" />
</label>
<label>
<input type="submit" name="submitbtn" class="sbtn" value="upload" />
</label>
</p>
<iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
</form>
</div>
</div>
</body>
代码如下 | 复制代码 |
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> function $(id) function startupload(){ function stopupload(success,pic){ //--> <body> |
upload.php
代码如下 | 复制代码 |
<?php $result = 0; if(@move_uploaded_file($_files['myfile']['tmp_name'], $target_path)) {
|
相关文章
使用PHP+JavaScript将HTML页面转换为图片的实例分享
这篇文章主要介绍了使用PHP+JavaScript将HTML元素转换为图片的实例分享,文后结果的截图只能体现出替换的字体,也不能说将静态页面转为图片可以加快加载,只是这种做法比较interesting XD需要的朋友可以参考下...2016-04-19- 这篇文章主要介绍了C#从数据库读取图片并保存的方法,帮助大家更好的理解和使用c#,感兴趣的朋友可以了解下...2021-01-16
- 今天小编在这里就来给各位Photoshop的这一款软件的使用者们来说说把古装美女图片转为细腻的工笔画效果的制作教程,各位想知道方法的使用者们,那么下面就快来跟着小编一...2016-09-14
- 这篇文章主要介绍了Python 图片转数组,二进制互转操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-03-09
- php如何实现抓取网页图片,相较于手动的粘贴复制,使用小程序要方便快捷多了,喜欢编程的人总会喜欢制作一些简单有用的小软件,最近就参考了网上一个php抓取图片代码,封装了一个php远程抓取图片的类,测试了一下,效果还不错分享...2015-10-30
- 有一种方法,可以不打开网站而直接查看到这个网站的源代码.. 这样可以有效地防止误入恶意网站... 在浏览器地址栏输入: view-source:http://...2016-09-20
- <?php require('path.inc.php'); header('content-Type: text/html; charset=utf-8'); $borough_id = intval($_GET['id']); if(!$borough_id){ echo ' ...2016-11-25
- 下面小编就为大家带来一篇利用JS实现点击按钮后图片自动切换的简单方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2016-10-25
jquery左右滚动焦点图banner图片鼠标经过显示上下页按钮
jquery左右滚动焦点图banner图片鼠标经过显示上下页按钮...2013-10-13- 本文实例讲述了JS基于Mootools实现的个性菜单效果代码。分享给大家供大家参考,具体如下:这里演示基于Mootools做的带动画的垂直型菜单,是一个初学者写的,用来学习Mootools的使用有帮助,下载时请注意要将外部引用的mootools...2015-10-23
- 本文实例讲述了JS+CSS实现分类动态选择及移动功能效果代码。分享给大家供大家参考,具体如下:这是一个类似选项卡功能的选择插件,与普通的TAb区别是加入了动画效果,多用于商品类网站,用作商品分类功能,不过其它网站也可以用,...2015-10-21
- 本文实例讲述了JS实现自定义简单网页软键盘效果。分享给大家供大家参考,具体如下:这是一款自定义的简单点的网页软键盘,没有使用任何控件,仅是为了练习JavaScript编写水平,安全性方面没有过多考虑,有顾虑的可以不用,目的是学...2015-11-08
- php 取除连续空格与换行代码,这些我们都用到str_replace与正则函数 第一种: $content=str_replace("n","",$content); echo $content; 第二种: $content=preg_replac...2016-11-25
- 这篇文章主要为大家详细介绍了js实现上传图片及时预览的相关资料,具有一定的参考价值,感兴趣的朋友可以参考一下...2016-05-09
- php简单用户登陆程序代码 这些教程很对初学者来讲是很有用的哦,这款就下面这一点点代码了哦。 <center> <p> </p> <p> </p> <form name="form1...2016-11-25
- Photoshop的这一款软件小编相信很多的人都已经是使用过了吧,那么今天小编在这里就给大家带来了用Photoshop软件制作枪战电影海报的教程,想知道制作步骤的玩家们,那么下面...2016-09-14
- 公司一些wordpress网站由于下载的插件存在恶意代码,导致整个服务器所有网站PHP文件都存在恶意代码,就写了个简单的脚本清除。恶意代码示例...2015-10-23
- 本文实例讲述了JS实现双击屏幕滚动效果代码。分享给大家供大家参考,具体如下:这里演示双击滚屏效果代码的实现方法,不知道有觉得有用处的没,现在网上还有很多还在用这个特效的呢,代码分享给大家吧。运行效果截图如下:在线演...2015-10-30
- 其实挺简单的就是if(navigator.userAgent.indexOf('UCBrowser') > -1) {alert("uc浏览器");}else{//不是uc浏览器执行的操作}如果想测试某个浏览器的特征可以通过如下方法获取JS获取浏览器信息 浏览器代码名称:navigator...2015-11-08
- 一、日期减去天数等于第二个日期function cc(dd,dadd){//可以加上错误处理var a = new Date(dd)a = a.valueOf()a = a - dadd * 24 * 60 * 60 * 1000a = new Date(a)alert(a.getFullYear() + "年" + (a.getMonth() +...2015-11-08