mx-rt/tinypng-laravel
Composer 安装命令:
composer require mx-rt/tinypng-laravel
包简介
Tinify API support with laravel
README 文档
README
Tinify API support with laravel
Install
$ composer require mxrotha/tinify-laravel
Add this to your config/app.php,
under "providers":
mxrotha\LaravelTinify\LaravelTinifyServiceProvider::class,
under "aliases":
'Tinify' => mxrotha\LaravelTinify\Facades\Tinify::class
And set a env variable TINIFY_APIKEY with your tinypng api key.
If you want to directly upload the image to aws s3, you need set the env variables of following with your aws s3 credentials.
S3_KEY= S3_SECRET= S3_REGION= S3_BUCKET=
Examples
$result = Tinify::fromFile('\path\to\file'); $result = Tinify::fromBuffer($source_data); $result = Tinify::fromUrl($image_url); /** To save as File **/ $result->toFile('\path\to\save'); /** To get image as data **/ $data = $result->toBuffer();
$s3_result = Tinify::fileToS3('\path\to\file', $s3_bucket_name, '/path/to/save/in/bucket'); $s3_result = Tinify::bufferToS3($source_data, $s3_bucket_name, '/path/to/save/in/bucket'); $s3_result = Tinify::urlToS3($image_url, $s3_bucket_name, '/path/to/save/in/bucket'); /** To get the url of saved image **/ $s3_image_url = $s3_result->location(); $s3_image_width = $s3_result->width(); $s3_image_hight = $s3_result->height();
NOTE: All the images directly save to s3 is publicably readable. And you can set permissions for s3 bucket folder in your aws console to make sure the privacy of images.
mx-rt/tinypng-laravel 适用场景与选型建议
mx-rt/tinypng-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 10 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「tinypng」 「tinify」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mx-rt/tinypng-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mx-rt/tinypng-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mx-rt/tinypng-laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Make your web shop faster by compressing your JPEG and PNG images. This plugin automatically optimizes your images by integrating with the popular image compression services TinyJPG and TinyPNG.
Facade of Tinify API for Yii2 Framework
Yii2 integration for TinyPng
Laravel Facade for tinify API
Pimcore Bundle - Minifies your PNG and JPEG Assets on uploading to Pimcore
Alfabank REST API integration
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-25