2017 © Pedro Peláez
 

library image-resizer

PHP class to resize images using GD

image

stormwild/image-resizer

PHP class to resize images using GD

  • Wednesday, January 7, 2015
  • by stormwild
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

ImageResizer

PHP class to resize images using GD, (*1)

History

Although, I used a version of this class in a recent project, this is really just an exercise for me to create a simple PHP class library shared through Composer and Packagist., (*2)

Setup

This package is available through Packagist with the vendor and package identifier the same as this repo., (*3)

If using Composer, in your composer.json file add:, (*4)

{
    "require": {
        "stormwild/image-resizer": "1.0.0"
    }
}

Otherwise:, (*5)

include '/path/to/ImageResizer.php';

Because this class uses namespacing, when instantiating the object, you need to either use the fully qualified namespace:, (*6)

$resized = \Stormwild\ImageResizer::resizer($path, $width, $height);

Or alias it:, (*7)


use \Stormwild\ImageResizer; $resized = ImageResizer::resizer($path, $width, $height);

Usage

    // possibly in controller action
    // check if image uploaded successfully
    // get path to uploaded image

    $path = "path/to/uploaded/file.ext"; // real path to file on server
    $width = 1050;
    $height = 700;    

    $resized = ImageResizer::resize($path, $width, $height);

    if($resized) {
        // upload to cloud storage
        // get url from cloud
        // save model with reference to image url
    }

The function resizes and replaces(updates) the uploaded file to the specified dimensions., (*8)

References

Credits to the many code samples on image resizing using GD on the web. In particular, I referenced the following:, (*9)

  • http://stackoverflow.com/questions/14649645/resize-image-in-php/14649689#14649689
  • http://stackoverflow.com/posts/14649689/revisions
  • https://github.com/eventviva/php-image-resize

The Versions

07/01 2015

dev-master

9999999-dev https://github.com/stormwild/ImageResizer

PHP class to resize images using GD

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-gd *

 

php image resize scale

07/01 2015

1.0.0

1.0.0.0 https://github.com/stormwild/ImageResizer

PHP class to resize images using GD

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-gd *

 

php image resize scale