求一个PHP可以生成缩略图和加水印的类.. 缩图的话能固定宽高缩和按比例缩...重要的是不能失真..网上找过一些,都不太好用..希望可以有人给我提供一个,谢谢..
解决方案 »
- SSL 通配符证书有人申请过嘛?
- 类似这种网站,用DEDE改写还是重新开发好呢?
- 这是为什么?
- 奇怪了,以前好好的,怎么今天就不行了,请各位帮忙,急用这个功能
- 如何将utf-8字符串转换成html的unicode标记?
- 求 IIS自动整合PHP工具
- 请问哪里有关于新闻组和邮件列表的文章?老师让写两篇关于他俩的文章啊。另外,请问有朋友用PHP作出支持他们的程序吗?(不知这样问对不
- 请问哪里有支持PHP+Mysql的免费主页空间?
- 一个简单的计数器问题(浏览次数)在线等待
- 求助PHPEXCEL问题
- 为什么启动不了apache服务器?
- 优化表后出现了is marked as crashed and last (automatic?) repair failed
function watermask($destination,$waterpngfilename,$pos = 'rb',$transparent = 50)
{
$imagetype = array("1"=>"gif","2"=>"jpeg","3"=>"png","4"=>"wbmp"); //here,is the type of image style
$image_size = getimagesize($destination);
$iinfo=getimagesize($destination,$iinfo);
$f ="imagecreatefrom".$imagetype[$iinfo[2]];
$simage = $f($destination);
$imagesize_mask = getimagesize($waterpngfilename);
$f ="imagecreatefrom".$imagetype[$imagesize_mask[2]];
$simage1 = $f($waterpngfilename);
switch($pos) //the position of the watermask you want
{
case 'lt':
imagecopymerge($simage,$simage1,0,0,0,0,$imagesize_mask[0],
$imagesize_mask[1],$transparent);
break;
case 'lb':
imagecopymerge($simage,$simage1,0,$image_size[1]-$imagesize_mask[1]
,0,0,$imagesize_mask[0],$imagesize_mask[1],$transparent);
break;
case 'rt':
imagecopymerge($simage,$simage1,$image_size[0]-$imagesize_mask[0],
0,0,0,$imagesize_mask[0],$imagesize_mask[1],$transparent);
break;
case 'rb':
imagecopymerge($simage,$simage1,$image_size[0]-$imagesize_mask[0],
$image_size[1]-$imagesize_mask[1],0,0,$imagesize_mask[0],
$imagesize_mask[1],$transparent);
break;
}
$f ="image".$imagetype[$iinfo[2]];
$f($simage,$destination);
imagedestroy($simage);
imagedestroy($simage1);
}
function DrawImage(ImgD,iwidth,iheight){
//参数(图片,允许的宽度,允许的高度)
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= iwidth/iheight){
if(image.width>iwidth){
ImgD.width=iwidth;
ImgD.height=(image.height*iwidth)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
else{
if(image.height>iheight){
ImgD.height=iheight;
ImgD.width=(image.width*iheight)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
}
}