thumbnail 缩略图
A library for make multi images' thumbnail in PHP, (*1)
用PHP写的一个生成多张图片的组合缩略图, (*2)
Install 安装
Except downloading the source code from github, it is recommended to install via composer:, (*3)
除了从 github 上下载源码外,推荐使用composer安装:, (*4)
composer require clarence/thumbnail
Examples 示例
Composite the following 4 images into a thumbnail:, (*5)
将以下四张图组合起来生成一张缩略图:, (*6)




Let's see the result firstly:, (*7)
先看效果:, (*8)
, (*9)
Then, the example codes:, (*10)
再看代码:, (*11)
// file: test/example.php
$thumbnail = \Clarence\Thumbnail\Thumbnail::createFromImages($srcImages, 240, 320);
$thumbnail->writeImage($outputDir."/example.jpg");
Really pretty simple codes:, (*12)
十分简单的代码~, (*13)
Thumbnail::createFromImages
is ussed to create the composited thumbnail. The first parameter is an array of original images' pathes; The second parameter is the thumbnail's width; The third parameter is the thumbnail's height; Then the image created is an instance of Imagick
- so writeImage
can be used to save it to a file., (*14)
Thumbnail::createFromImages
就是用于生成缩略图的关键函数,其第一个参数是原始图片的文件路径列表,第二个参数是生成的缩略图的宽度,第三个参数是生成的缩略图的高度;生成的图片是一个Imagick
对象,然后可以使用writeImage
将其保存到文件。, (*15)
Other thumbnail types 其他缩略图类型
(1 image), (*16)
(2 images), (*17)
(3 images), (*18)
(4 images), (*19)
(CropThumbnail), (*20)
(ScaleThumbnail), (*21)
(EqualScaleTopLeftThumbnail), (*22)
(EqualScaleCenterThumbnail), (*23)