2017 © Pedro Peláez
 

library image-resizer

An image-resizing librarylet

image

twowholeworms/image-resizer

An image-resizing librarylet

  • Wednesday, September 23, 2015
  • by TwoWholeWorms
  • Repository
  • 1 Watchers
  • 0 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Image Resizer

This librarylet provides a class which allows you to easily resize images using PHP's GD library., (*1)

Installation

The easiest way to install this library is with composer. Simply run this command in your project's root directory:, (*2)

composer require twowholeworms/image-resizer

Usage

Here's the simplest usage for the resizer:, (*3)

<?php

use TwoWholeWorms\Utilities\ImageResizer;

// Resize an image using the default settings (PNG, cover) to 300x200
$processedImage = ImageResizer::load('/path/to/image_file.png')->resize(300, 200);

You can save the results directly to a file like this:, (*4)

<?php

use TwoWholeWorms\Utilities\ImageResizer;

// Resize an image using the default settings (PNG, cover) to 300x200 and save it to a file
$resizer = ImageResizer::load('/path/to/image_file.png')->save('/path/to/save/processed_image.png');

You can load from a URL:, (*5)

<?php

use TwoWholeWorms\Utilities\ImageResizer;

$resizer = ImageResizer::load('http://url.to/image.png');

You can pass in configuration options when loading the source image:, (*6)

<?php

use TwoWholeWorms\Utilities\ImageResizer;

// Create a new instance with specific settings
$resizer = ImageResizer::load('/path/to/image.gif', [
    'format' => IMAGETYPE_PNG,
    'mode' => ImageResizer::MODE_COVER,
    'width' => 300,
    'height' => 200,
]);

Or you can set each option individually:, (*7)

<?php

use TwoWholeWorms\Utilities\ImageResizer;

$resizer = ImageResizer::load('/path/to/image.gif');
$resizer->setFormat(IMAGETYPE_JPEG)
        ->setMode(ImageResizer::MODE_STRETCH)
        ->setWidth(150)
        ->setHeight(100);

If you want to save several image sizes straight from one source image, you can just do this:, (*8)

<?php

use TwoWholeWorms\Utilities\ImageResizer;

$resizer = ImageResizer::load('/path/to/image')
$resizer->save($destFileLarge, ['width' => 1000, 'height' => 750]);
$resizer->save($destFileMedium, ['width' => 600, 'height' => 400]);
$resizer->save($destFileSmall, ['width' => 300, 'height' => 200]);
$resizer->save($destFileThumb, ['width' => 100, 'height' => 100]);

The Versions

23/09 2015

dev-master

9999999-dev https://github.com/TwoWholeWorms/image-resizer

An image-resizing librarylet

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-gd *

 

image gd resizer vinari

23/09 2015

dev-dev

dev-dev https://github.com/TwoWholeWorms/image-resizer

An image-resizing librarylet

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-gd *

 

image gd resizer vinari