mh/imagetastic
Composer 安装命令:
composer require mh/imagetastic
包简介
Nifty image library in my toolbox
README 文档
README
This is a very easy toolkit to upload images to google cloud storage including a thumbnail.
Developed by Michael Holm
Google Api: https://cloud.google.com/storage/docs/json_api/v1/
<?php
use Imagetastic\Client;
require_once(__DIR__.'/vendor/autoload.php');
// your google cloud project name
$project = 'alien-dispatch-8258';
// original picture you want to upload and create thumbnail
//$imageUrl = '/tmp/my-image-file.jpg';
$imageUrl = 'https://images.pexels.com/photos/974229/pexels-photo-974229.jpeg?auto=compress&cs=tinysrgb&h=800&w=1200';
// dimentions for the thumbnail
$dimentions = [
'height' => 300,
'width' => 400,
];
// your client key, can be downloaded from your google cloud console
$client = new Client(__DIR__.'/client.json', $project);
$r = $client->process($imageUrl, $dimentions);
var_dump($r);
The output will be something:
object(stdClass)#2 (7) {
["height"]=>
int(800)
["width"]=>
int(800)
["ratio"]=>
int(1)
["done"]=>
bool(true)
["mime"]=>
string(10) "image/jpeg"
["originalPath"]=>
string(78) "https://storage.googleapis.com/alien-dispatch-8258/original/5c59a48f95d47.jpeg"
["thumbPath"]=>
string(83) "https://storage.googleapis.com/alien-dispatch-8258/thumb_400x300/5c59a48f95d47.jpeg"
}
统计信息
- 总下载量: 165
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-02-05