Download the PHP package tp5er/images without Composer

On this page you can find all versions of the php package tp5er/images. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package images

参考thinkphp3.2.3中Image操作

https://www.kancloud.cn/manual/thinkphp/1878

不依赖任何框架

一般情况下都会安装gd库

需要Imagick请安装 https://pecl.php.net/package/imagick

实例化类库

$image = new \tp5er\Images\Image();

默认使用GD库进行图像操作,如果需要使用Imagick库操作的话,需要改成:

图像操作

下面来看下基础的图像操作功能的使用方法。

打开图像文件

假设当前入口文件目录下面有一个1.jpg文件

使用open方法打开图像文件进行相关操作:

也可以简化成下面的方式:

获取图像信息

可以获取打开图片的信息,包括图像大小、类型等,例如:

$width = $image->width(); // 返回图片的宽度
$height = $image->height(); // 返回图片的高度
$type = $image->type(); // 返回图片的类型
$mime = $image->mime(); // 返回图片的mime类型
$size = $image->size(); // 返回图片的尺寸数组 0 图片宽度 1 图片高度

裁剪图片

使用crop和save方法完成裁剪图片功能。

支持从某个坐标开始裁剪,例如下面从(100,30)开始裁剪:

生成缩略图

使用thumb方法生成缩略图

// 按照原图的比例生成一个最大为150*150的缩略图并保存为thumb.jpg
$image->thumb(150, 150)->save('./thumb.jpg');

可以支持其他类型的缩略图生成,设置包括\tp5er\Images\Image的下列常量或者对应的数字:

IMAGE_THUMB_SCALE     =   1 ; //等比例缩放类型
IMAGE_THUMB_FILLED    =   2 ; //缩放后填充类型
IMAGE_THUMB_CENTER    =   3 ; //居中裁剪类型
IMAGE_THUMB_NORTHWEST =   4 ; //左上角裁剪类型
IMAGE_THUMB_SOUTHEAST =   5 ; //右下角裁剪类型
IMAGE_THUMB_FIXED     =   6 ; //固定尺寸缩放类型

居中裁剪

左上角剪裁

缩放填充

固定大小

添加图片水印

water方法的第二个参数表示水印的位置,可以传入下列Think\Imag类的常量或者对应的数字:

例如:

还可以支持水印图片的透明度(0~100,默认值是80),例如:

也可以支持给图片添加文字水印(假设在入口文件的同级目录下存在1.ttf字体文件),例如:


All versions of images with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tp5er/images contains the following files

Loading the files please wait ....