carlosafonso/thumbnailr
Composer 安装命令:
composer require carlosafonso/thumbnailr
包简介
A PHP library for dynamically generating image thumbnails
README 文档
README
Thumbnailr is a PHP library for dynamically generating image thumbnails in either PNG or JPEG format.
##Installation
Thumbnailr is available via Composer. Add a reference to Thumbnailr in your composer.json file;
{
"require": {
"carlosafonso/thumbnailr": "2.*"
}
}
Then fire up a terminal and run the following wherever your composer.json file is located:
$ composer install
##Usage example
// the path to the source image $img = 'path/to/image.png'; // the thumbnail's dimensions $width = 200; $height = 100; // instantiate the library $thumbnailr = new \Thumbnailr\Thumbnailr($img); /* * Generating the thumbnail */ // this will not keep the aspect ratio (both calls are equivalent) $thumbnailr->buildThumbnail($width, $height); $thumbnailr->buildThumbnail($width, $height, self::SIZE_FIXED); // keep the aspect ratio and fit the LONGEST side inside the thumbnail, // (actual size will be smaller than specified) $thumbnailr->buildThumbnail($width, $height, self::SIZE_FIT_LONGEST); // keep the aspect ratio and fit the SHORTEST side inside the thumbnail size, // (actual size will be larger than specified) $thumbnailr->buildThumbnail($width, $height, self::SIZE_FIT_SHORTEST); /* * Saving the thumbnail */ // save to a PNG file, apply standard compression $thumbnailr->toPngFile('thumbnail.png'); // same as above specifying a compression level (higher level means smaller file size) $thumbnailr->toPngFile('thumbnail.png', 7); // get the thumbnail as raw binary data $raw_png = $thumbnailr->toPngFile(NULL); // get the PNG thumbnail as a base 64 string, apply standard compression $png_b64 = $thumbnailr->toPngBase64(); // same as above specifying a compression level $png_b64 = $thumbnailr->toPngBase64(4); // save to a JPEG file, use standard quality $thumbnailr->toJpegFile('thumbnail.jpg'); // same as above specifying a quality value (higher quality means larger file size) $thumbnailr->toJpegFile('thumbnail.jpg', 80); // get the JPEG thumbnail as a base 64 string, use standard quality $jpeg_b64 = $thumbnailr->toJpegBase64(); // same as the above specifying a quality value $jpeg_b64 = $thumbnailr->toJpegBase64(40);
carlosafonso/thumbnailr 适用场景与选型建议
carlosafonso/thumbnailr 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 90 次下载、GitHub Stars 达 7, 最近一次更新时间为 2014 年 04 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 carlosafonso/thumbnailr 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 carlosafonso/thumbnailr 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 90
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2014-04-03