michaelthuren/tinify-laravel-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

michaelthuren/tinify-laravel-client

最新稳定版本:9.0.0

Composer 安装命令:

composer require michaelthuren/tinify-laravel-client

包简介

Tinify API support with laravel (TinyPNG)

README 文档

README

Supported laravel versions 9+

Install

$ composer require michaelthuren/tinify-laravel-client

Add this to your config/app.php,

under "providers":

michaelthuren\tinify-laravel-client\TinifyLaravelServiceProvider::class,

under "aliases":

'Tinify' => michaelthuren\tinify-laravel-client\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.

统计信息

  • 总下载量: 4.34k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固