2017 © Pedro Peláez
 

library tinypng

TinyPNG PHP API

image

kinglozzer/tinypng

TinyPNG PHP API

  • Thursday, February 26, 2015
  • by kinglozzer
  • Repository
  • 2 Watchers
  • 9 Stars
  • 8,282 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 11 % Grown

The README.md

TinyPNG PHP API

Build Status, (*1)

Provides an easy-to-use API for interacting with TinyPNG's developer API., (*2)

Installation

composer require kinglozzer/tinypng:0.1.*, (*3)

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
}

The Versions

26/02 2015

dev-master

9999999-dev

TinyPNG PHP API

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.3

 

The Development Requires

php image jpg compression png tinypng tinyjpg

30/01 2015

0.1.0

0.1.0.0

TinyPNG PHP API

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.3

 

The Development Requires

php image jpg compression png tinypng tinyjpg

29/01 2015

0.0.3

0.0.3.0

TinyPNG PHP API

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.3

 

The Development Requires

php image jpg compression png tinypng tinyjpg

03/12 2014

0.0.2

0.0.2.0

TinyPNG PHP API

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.3

 

The Development Requires

php image jpg compression png tinypng tinyjpg

03/12 2014

0.0.1

0.0.1.0

TinyPNG PHP API

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.3

 

The Development Requires

php image jpg compression png tinypng tinyjpg