library tinypng
TinyPNG PHP API
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
TinyPNG PHP API
, (*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
}
dev-master
9999999-dev
TinyPNG PHP API
Sources
Download
BSD-3-Clause
The Requires
The Development Requires
php
image
jpg
compression
png
tinypng
tinyjpg
0.1.0
0.1.0.0
TinyPNG PHP API
Sources
Download
BSD-3-Clause
The Requires
The Development Requires
php
image
jpg
compression
png
tinypng
tinyjpg
0.0.3
0.0.3.0
TinyPNG PHP API
Sources
Download
BSD-3-Clause
The Requires
The Development Requires
php
image
jpg
compression
png
tinypng
tinyjpg
0.0.2
0.0.2.0
TinyPNG PHP API
Sources
Download
BSD-3-Clause
The Requires
The Development Requires
php
image
jpg
compression
png
tinypng
tinyjpg
0.0.1
0.0.1.0
TinyPNG PHP API
Sources
Download
BSD-3-Clause
The Requires
The Development Requires
php
image
jpg
compression
png
tinypng
tinyjpg