masum-nishat/image-resize-php
Composer 安装命令:
composer require masum-nishat/image-resize-php
包简介
Resize image to desire file size by only one compression
README 文档
README
PHP library to resize image to desire file size by only one compression.
Warning
This is a development package. I encourage not to use in production environment.
Please inform if any bug or security issue or any other problem found.
Any suggestion will be taken seriously.
Setup
This package is available through Packagist with the vendor and package identifier the same as this repo.
If using Composer, run following command:
composer require "masum-nishat/image-resize-php":"^1.1.0"
Note: This library uses GD class which do not support resizing animated gif files
Resize
Only supported resizing param is according to file size. Image dimension will be changed and final image will be under 250KB (Default).
imageResize::convert('image.jpg', 'image-converted.jpg'); //or imageResize::convert('image.png', 'image-converted.png');
Let the extension detect automatically from mime type:
imageResize::convert('image.jpg', 'image-converted'); //or imageResize::convert('image.png', 'image-converted');
Declare required maximum size:
imageResize::$targetSize = 300000; //maximum 300KB imageResize::convert('image.jpg', 'image-converted'); //or imageResize::convert('image.png', 'image-converted');
This class creat unique temp directory and delete it after using. To use custom temp directory and not delete temp components (useful for debugging):
imageResize::$tempDir = 'path/to/temp/folder'; imageResize::convert('image.jpg', 'image-converted'); //or imageResize::convert('image.png', 'image-converted');
Supported Image Types
IMAGETYPE_JPEGIMAGETYPE_PNGIMAGETYPE_GIF
Quality
Maximum quality is selected by default.
Quality change param is not implemented yet;
Exceptions
Exception handling not implemented yet.
统计信息
- 总下载量: 26
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2019-11-16