2017 © Pedro Peláez
 

library tinypng-resize

Image compression and resizing.

image

teklife/tinypng-resize

Image compression and resizing.

  • Friday, October 2, 2015
  • by levidurfee
  • Repository
  • 1 Watchers
  • 1 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 5 Versions
  • 9 % Grown

The README.md

tinypng-resize

This repo will be changing over the next couple of days. If you start using it now, be careful when upgrading to 1.0.0. The code will have changed., (*1)

Build Status build v0.8.2, (*2)

A service by TinyPNG. Get a free API KEY., (*3)

The primary purpose of this repo is to be used with another app that I am still developing. This repo at it's current state can be used by others for image resizing using TinyPNG., (*4)

If you have any issues or requests, please feel free to open an issue. Pull requests are welcome., (*5)

TinyPNG has been very helpful. Even if you don't use my code, at least check out their site and the services they offer., (*6)

installation

Add "teklife/tinypng-resize" : "0.8.*" to your composer.json. It might look something like this:, (*7)

{
  "require": {
    "teklife/tinypng-resize" : "0.8.*"
  }
}

example usage

To simple compress the image:, (*8)

<?php
require_once('vendor/autoload.php');
$tp = new teklife\Tinypng('YOUR_API_KEY');
$tp->shrink('ignore/helicopter-original.png', 'ignore/helicopter-new-levi.png');

To resize based on width:, (*9)

<?php
require_once('vendor/autoload.php');
$tp = new teklife\Tinypng('YOUR_API_KEY');
$tp->shrink('ignore/helicopter-original.png', 'ignore/helicopter-new-levi.png')->resize(150);

To resize based on height:, (*10)

<?php
require_once('vendor/autoload.php');
$tp = new teklife\Tinypng('YOUR_API_KEY');
$tp->shrink('ignore/helicopter-original.png', 'ignore/helicopter-new-levi.png')->resize('', 150);

To set the image max width or height to 150:, (*11)

require_once('vendor/autoload.php');
$tp = new teklife\Tinypng('YOUR_API_KEY');
$tp->shrink('ignore/helicopter-original.png', 'ignore/helicopter-new-levi.png')->resize(150, 150, true);

The image will either be 150px wide or 150px tall. If it is 150px wide, then the height will be smaller than 150px. If it is 150px tall, then the width will be smaller than 150px. It bases this off the original image size. It will not crop the image., (*12)

To resize and crop, if necessary 150x150:, (*13)

require_once('vendor/autoload.php');
$tp = new teklife\Tinypng('YOUR_API_KEY');
$tp->shrink('ignore/helicopter-original.png', 'ignore/helicopter-new-levi.png')->resize(150, 150, false, true);

quote from TinyPNG

Images are resized by using the aspect ratio of the original image. Either the width or the height can be provided., (*14)

This may change., (*15)

todo

  • [ ] #7 when 1.0.0 is ready add it to packagist
  • [ ] #6 write more tests
  • [x] #8 make resizing an option and not the main purpose of this code
  • [ ] additional features
    • [ ] #5 add in new S3 feature
    • [ ] #4 store previous unique reference urls so the original doesn't have to be uploaded each time
    • [ ] store the filename, md5 sum, and unique reference url of the image in a sqlite db
  • [x] finish fopenShrink method for people who do not have curl
  • [x] get tests working on travis-ci tests
  • [x] add to packagist when done - 0.8.0 is added to packagist.

Using RequestBin for some testing., (*16)

The Versions

02/10 2015

dev-master

9999999-dev

Image compression and resizing.

  Sources   Download

MIT

The Requires

  • ext-json *
  • php >=5.4

 

image resize compression tinypng

07/07 2015

0.8.2

0.8.2.0

Image compression and resizing.

  Sources   Download

MIT

The Requires

  • php >=5.4
  • ext-json *

 

image resize compression tinypng

05/07 2015

0.8.1

0.8.1.0

Image compression and resizing.

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-json *

 

image resize compression tinypng

05/07 2015

0.8.0

0.8.0.0

Image compression and resizing.

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-json *

 

The Development Requires

image resize compression tinypng

03/07 2015

0.5.0

0.5.0.0

Image compression and resizing.

  Sources   Download

MIT

The Requires

  • php >=5.3.0