本帖最后由 元首 于 2009-12-24 12:29 编辑
这是一张铁血论坛的图片, 凡是上传在该论坛的图片,都会被打上黑底白字.为此, 我们仿效之.
打开source/function_cp.php文件.
查找:- $setarr['picid'] = inserttable('pic', $setarr, 1);
复制代码 估计在171行. 在它的下一行增加:- //为图片设置新的水印
- images_test($new_name,$_SGLOBAL['supe_uid']);
复制代码 接着查找:- function stream_save($strdata, $albumid = 0, $fileext = 'jpg', $name='', $title='', $delsize=0, $from = false) {
复制代码 在它的上一行增加:- // 实现黑底白字
- function images_test($path,$uid=1){
- if(is_file($path) === false)
- return false;
- $logoimage = $path;
- $logoimg = getimagesize($logoimage);
- if($logoimg[0]<=190)
- return false;
- switch ($logoimg[2]) {
- case 1 :
- $in = imagecreatefromgif($logoimage);
- break;
- case 2 :
- $in = imagecreatefromjpeg($logoimage);
- break;
- case 3 :
- $in = imagecreatefrompng($logoimage);
- break;
- }
- $height = 22;
- $length = (int) $logoimg[0];
- $im = imagecreatetruecolor($length,$height);
-
- $red = imagecolorallocate($im,255,255,255); //背景色
- $red2 = imagecolorallocate($im,109,109,109); //文字的颜色
- imageline($im,0,0,$length,0,$red2);
- $font = 'http://www.xxxxx.com/'.$uid; //黑底上的文字
- imagestring($im,4,$length/2-(strlen($font)/2),3,$font,$red);
- imagecopy($in,$im, 0,$logoimg[1]-$height, 0, 0, $logoimg[0], $logoimg[1]);
- switch ($logoimg[2]) {
- case 1 :
- imagegif($in,$path);
- break;
- case 2 :
- imagejpeg($in,$path);
- break;
- case 3 :
- imagepng($in,$path);
- break;
- }
- }
复制代码 好了, 插件完成. |