clarence/thumbnail

A library for making thumbnails, especially for composed images' thumbnail

v1.0.2 2016-03-31 06:23 UTC

This package is not auto-updated.

Last update: 2024-10-26 19:10:51 UTC


README

A library for make multi images' thumbnail in PHP

用PHP写的一个生成多张图片的组合缩略图

Install 安装

Except downloading the source code from github, it is recommended to install via composer:

除了从 github 上下载源码外,推荐使用composer安装:

composer require clarence/thumbnail

Examples 示例

Composite the following 4 images into a thumbnail:

将以下四张图组合起来生成一张缩略图:

Let's see the result firstly:

先看效果:

Then, the example codes:

再看代码:

// file: test/example.php
$thumbnail = \Clarence\Thumbnail\Thumbnail::createFromImages($srcImages, 240, 320);
$thumbnail->writeImage($outputDir."/example.jpg");

Really pretty simple codes:

十分简单的代码~

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.

Thumbnail::createFromImages 就是用于生成缩略图的关键函数,其第一个参数是原始图片的文件路径列表,第二个参数是生成的缩略图的宽度,第三个参数是生成的缩略图的高度;生成的图片是一个Imagick对象,然后可以使用writeImage将其保存到文件。

Other thumbnail types 其他缩略图类型

(1 image)

(2 images)

(3 images)

(4 images)

(CropThumbnail)

(ScaleThumbnail)

(EqualScaleTopLeftThumbnail)

(EqualScaleCenterThumbnail)