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);
阅读(1665) | 评论(0) | 转发(0) |