PHPackages                             yll1024335892/phptools - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. yll1024335892/phptools

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yll1024335892/phptools
======================

A php's tools

1.0.0(7y ago)014MITPHP

Since Dec 1Pushed 7y ago1 watchersCompare

[ Source](https://github.com/yll1024335892/phptools)[ Packagist](https://packagist.org/packages/yll1024335892/phptools)[ RSS](/packages/yll1024335892-phptools/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

 phptools
==========

[](#-phptools-)

 A php's tools.

Installing
----------

[](#installing)

```
$ composer require yll1024335892/phptools -vvv
```

Usage
-----

[](#usage)

TODO

Contributing
------------

[](#contributing)

You can contribute in one of three ways:

1. File bug reports using the [issue tracker](https://github.com/yll1024335892/phptools/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/yll1024335892/phptools/issues).
3. Contribute new features or update the wiki.

*The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.*

ImageClass.php 图片处理的工具
----------------------

[](#imageclassphp-图片处理的工具)

```
$image=new ImageClass("xx.png");//打开图片
gif的水印需要优化
```

#### 1.添加水印 - water 方法

[](#1添加水印---water-方法)

```
参数
1、水印图片路径
2、水印位置【默认 image::RB - 右下角】，可以使用的参数：
    const LT =   1 ; //左上角
    const TC =   2 ; //上居中
    const RT =   3 ; //右上角
    const LC =   4 ; //左居中
    const CC =   5 ; //居中
    const RC =   6 ; //右居中
    const LB =   7 ; //左下角
    const BC =   8 ; //下居中
    const RB =   9 ; //右下角
    传递时使用数值即可！
3、水印透明度【默认 80】
演示
$image = new ImageClass('demo.jpg');
$image->water('water.png',$img::CC,100);//居中透明度100的水印
$image->save('demo_save');//保存图片【参数文件名，不要传递扩展名】原图是什么扩展就是什么扩展名
```

#### 2.缩略图 - thumb() 方法

[](#2缩略图---thumb-方法)

```
参数
1、缩略图最大宽度
2、缩略图最大高度
3、缩略图裁剪类型
    const TB1 =  1 ; //缩略图等比例缩放
    const TB2 =  2 ; //缩略图缩放后填充
    const TB3 =  3 ; //缩略图居中裁剪
    const TB4 =  4 ; //左上角裁剪类型
    const TB5 =  5 ; //右下角裁剪类型
    const TB6 =  6 ; //固定尺寸缩放类型
    传参时请使用数值！
演示
$image = new ImageClass('demo.jpg');
$image->thumb(200, 200, 3);
$image->save('demo22');
echo '';
```

#### 3.图片裁切 - crop 方法

[](#3图片裁切---crop-方法)

```
参数
1、裁切区域宽度
2、裁切区域高度
3、裁切区域x坐标【默认 0】
4、裁切区域y坐标【默认 0】
5、图像保存宽度【默认等于裁切宽度】
6、图像保存高度【默认等于裁切高度】
演示
$image = new ImageClass('demo.jpg');
$image->crop(200, 200, 100, 100, 50, 50);
$image->save('demo22');
echo '';
```

#### 4.添加文字到图片 - text 方法

[](#4添加文字到图片---text-方法)

```
参数
1、添加的文字内容
2、字号
3、文字颜色及透明度 rgb 模式【默认 array(0, 0, 0)】
4、 文字写入位置【默认 9】
    const LT =   1 ; //左上角
    const TC =   2 ; //上居中
    const RT =   3 ; //右上角
    const LC =   4 ; //左居中
    const CC =   5 ; //居中
    const RC =   6 ; //右居中
    const LB =   7 ; //左下角
    const BC =   8 ; //下居中
    const RB =   9 ; //右下角
    传递时使用数值即可！
5、文字相对当前位置的偏移量
6、文字倾斜角度
7、字体文件路径【默认 src/temp/fonts/AMBROSIA.ttf】
演示
$image = new ImageClass('demo.gif');
$image->text('yll1024335892', 20, array(255, 0, 0));
$image->save('demo22');
echo '';
```

UploadClass.php文件上传工具类
----------------------

[](#uploadclassphp文件上传工具类)

#### 功能描述

[](#功能描述)

```
1、文件扩展名、类型检查
2、文件大小检查
3、目录创建
4、命名规则定制
```

#### 使用方式

[](#使用方式)

> 1,实例化上传对象

```
$upload = new UploadClass('fileName', 'upload', '2.png');
UploadClass 类构造函数参数
1、文件域名称()
2、上传文件保存文件夹位置
3、可选参数【上传后文件名，默认 null - 根据设置的规则命名】

```

> 2,设置上传信息

```
$upload->allowType = 'image/png,image/jpeg,image/pjpeg,image/x-png,image/gif'; //设置上传允许的类型
$upload->allowExeName  = 'jpg,gif,png'; //允许上传文件的扩展名
$upload->allowSize = 1024允许上传文件的大小 [单位 K]
$upload->dirCreateRule = 'no'; //子文件夹创建规则  no - 不自动创建  |  y - 年 | m - 月(Ym) | d - 日(Ymd)
$upload->renameRule = 3; //文件重命名规则  1: 原文件名 | 2: 随机命名 | 3: _1 后缀形式重命名 | 默认是原文件名

```

> 3,上传文件

```
$uper->upload();

```

> 4,演示

```
