yannickl88/image
Composer 安装命令:
composer require yannickl88/image
包简介
Library for reading, transforming and writing image files.
README 文档
README
Library for reading, transforming and writing image files.
This libary was born out of the need to have a consistent API for interacting with images. The goal is to have simple methods for common image tasks like cropping and resizing.
Usage
Supported file extensions for reading:
- PNG
- JPG
- JPEG
- GIF
Supported file extension for writing:
- PNG
- WEBP (if mod gd has been enabled with WebP support)
Example usages:
$image = \Yannickl88\Image\Image::fromFile('/some/image.png'); // Resize to 50 x 50 $thumbnail = $image->resize(50, 50); $thumbnail->save('/some/thumbnail.png'); // Fit the image to a width and height of 50, 50 while maintaining it's aspect ratio. $thumbnail = $image->fit(50, 50); $thumbnail->save('/some/thumbnail.png'); // Crop at 50, 50 with a square of 100 x 100 $thumbnail = $image->crop([50, 50, 100, 100]); $thumbnail->save('/some/thumbnail.png'); // Resize and crop at the same time $thumbnail = $image->sampleTo([50, 50, 100, 100], [0, 0, 50, 50]); $thumbnail->save('/some/thumbnail.png'); // Set the quality, where 0 being low and 1 high (value between 0 and 1) $compressed = $image->quality(0.25); $compressed->save('/some/preview.png'); // Get image width var_dump($image->width()); // int // Get image height var_dump($image->height()); // int // Get image bounding box var_dump($image->rect()); // array(0, 0, width, height) // Get a color at a given coordinate var_dump($image->color(0, 0)); // array(red, green, blue, alpha) // Get the image orientation var_dump($image->orientation()); // ImageInterface::ORIENTATION_LANDSCAPE // Get the raw data and output it header('Content-type: image/png'); header('Content-Disposition: filename="image.png"'); echo $image->data('.png');
Migration
See Migration Guide.
Installation
$ composer require yannickl88/image- This library follows semantic versioning strictly.
yannickl88/image 适用场景与选型建议
yannickl88/image 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 415 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 10 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 yannickl88/image 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 yannickl88/image 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 415
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-19