Chinaunix首页 | 论坛 | 博客
  • 博客访问: 255705
  • 博文数量: 36
  • 博客积分: 25
  • 博客等级: 民兵
  • 技术积分: 993
  • 用 户 组: 普通用户
  • 注册时间: 2012-06-13 08:59
文章分类

全部博文(36)

文章存档

2017年(1)

2016年(4)

2015年(9)

2014年(8)

2013年(14)

分类: PHP

2015-07-16 11:42:27

1. 获取文件大小的函数
function getsize($size,$format='kb'){
 $p=0;
 if($format=='kb'){
     $p=1;
 }
elseif($format=='mb'){
     $p=2;
     
 }elseif($format=='gb'){
     $p=3;
 }
 $size /=pow(1024,$p);
 return number_format($size,3);
}
$size= getsize($size,'kb');
echo $size.'kb';
2.生成水印图片
//这里仅仅是为了案例需要准备一些素材图片
$url = '';
$content = file_get_contents($url);
$filename = 'tmp.jpg';
file_put_contents($filename, $content);
$url = 'http://wiki.ubuntu.org.cn/images/3/3b/Qref_Edubuntu_Logo.png';
file_put_contents('logo.png', file_get_contents($url));
//开始添加水印操作
$im = imagecreatefromjpeg('center.jpg');
$logo = imagecreatefromgif('ctslogo.gif');
$size = getimagesize('ctslogo.gif');
imagecopy($im, $logo, 150, 150, 0, 0, $size[0], $size[1]);
header("content-type: image/jpeg");
imagejpeg($im);


阅读(1634) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~