kisphp/thumbnails
最新稳定版本:1.6.1
Composer 安装命令:
composer require kisphp/thumbnails
包简介
Kisphp thumbnails generator. Supports jpg, png, gif, webp images
README 文档
README
This class will help you to easily resize images and save them to disc or show them to user
Supported format:
- jpg
- jpg2000
- png
- gif
- webp
Installation
composer require kisphp/thumbnails
Then add make sure you load composer autoloader:
require_once 'path/to/vendor/autoload.php';
Usage
<?php
require_once 'path/to/vendor/autoload.php';
$image = new \Kisphp\ImageResizer();
// load original image file
$image->load('/path/to/image/file.jpg');
// set where thumbnail will be saved (optional)
$image->setTarget('/path/to/thumbnail/file.jpg');
// resize image to a 300px width and dynamic height by aspect ratio
$image->resize(300, 0);
// or
// resize image to a 300px height and dynamic width by aspect ratio
$image->resize(0, 300);
// show image and save
$image->display(true);
Change thumbnail background color
If you crop the images, you can use a custom background color to integrate the thumbnail into your design
// set default background color (here will be red, default is white)
$image->setBackgroundColor(255, 0, 0);
Resize method usage
$image->resize(new_width, new_height, crop_image=true|false);
Show image without saving it
$image->display();
Note that these methods outputs
header('Content-Type: image/..mime-type..')
统计信息
- 总下载量: 7.33k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-11