kinglozzer/tinypng 问题修复 & 功能扩展

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

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

kinglozzer/tinypng

最新稳定版本:0.1.0

Composer 安装命令:

composer require kinglozzer/tinypng

包简介

TinyPNG PHP API

README 文档

README

Build Status

Provides an easy-to-use API for interacting with TinyPNG's developer API.

Installation

composer require kinglozzer/tinypng:0.1.*

Usage

use Kinglozzer\TinyPng\Compressor;
use Kinglozzer\TinyPng\Exception\AuthorizationException;
use Kinglozzer\TinyPng\Exception\InputException;
use Kinglozzer\TinyPng\Exception\LogicException;

$compressor = new Compressor('<your-tinypng-api-key>');

try {
    $result = $compressor->compress('/path/to/original.png');
    $result = $compressor->compress('<image data>', true); // Compress raw image data
    $result->writeTo('/path/to/compressed.png'); // Write the returned image
    $result->getCompressedFileSize(); // Int size of compressed image, e.g: 104050
    $result->getCompressedFileSize(true); // Human-readable, e.g: '101.61 KB'
    $result->getResponseData(); // array containing JSON-decoded response data
} catch (AuthorizationException $e) {
    // Invalid credentials or requests per month exceeded
} catch (InputException $e) {
    // Not a valid PNG or JPEG
} catch (Exception $e) {
    // Unknown error
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2014-12-03