glukash / glu-image by glukash

3,714
6
2
Package Data
Maintainer Username: glukash
Maintainer Contact: glukash@gmail.com (Lukasz Gaszyna)
Package Create Date: 2014-07-09
Package Last Update: 2014-07-22
Language: PHP
License: MIT
Last Refreshed: 2024-11-22 03:13:21
Package Statistics
Total Downloads: 3,714
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 6
Total Watchers: 2
Total Forks: 5
Total Open Issues: 3

GluImage

glukash\glu-image is a PHP image manipulation helper library.

The package includes ServiceProvider and Facade for easy Laravel 4 integration.

##Purpose

  • The package supports two image manipulation methods: resize and crop.
  • Easly resize and crop jpg, png, and gif images.
  • Supports animated gif using GD Library. (No Imagick, Gmagick is needed).

Dependencies

The package uses:

Requirements

  • PHP >=5.3
  • GD Library (>=2.0)

Quick Installation

To install through composer, put the following in your composer.json file:

{
	"repositories": [
	    {
	        "type": "git",
	        "url": "https://github.com/glukash/GifCreator"
	    }
	],
	"require": {
		"glukash/glu-image": "0.*"
	}
}

Without adding the "repositories" key, composer will pull the original Sybio/GifCreator and you will not be able to chain methods on animated gif files after first save().

{
	"repositories": [
	    {
	        "type": "git",
	        "url": "https://github.com/glukash/GifCreator"
	    }
	]
}

Laravel Integration

Add Intervention\Image and Glukash\GluImage service providers in app/config/app.php.

'providers' => array(

	// ...
	'Intervention\Image\ImageServiceProvider',
	'Glukash\GluImage\GluImageServiceProvider',
),

Add GluImage alias in app/config/app.php.

'aliases' => array(

	// ...

	'GluImage' => 'Glukash\GluImage\Facades\GluImage',
),

If you want to use Intervention\Image package directly, add InterImage alias in app/config/app.php. This is not a necessary step for using GluImage.

'aliases' => array(

	// ...

	'InterImage' => 'Intervention\Image\Facades\Image',
),

Code Examples

$img = GluImage::get( $path_to_images.'/01.jpg' );
$img->resize(540,360);
$img->save( $path_to_images.'/01-resized.jpg' );

// ...

GluImage::get( $path_to_images.'/01.jpg' )->resize(540,360)->save( $path_to_images.'/01-resized.jpg' );

// ...

GluImage::get( $path_to_images.'/01.jpg' )->crop(540,360)->save( $path_to_images.'/01-cropped.jpg' );

// ...

// one chain creates two different files
GluImage::get( $path_to_images.'/01.jpg' )
	->resize(540,360)
	->save( $path_to_images.'/01-resized1.jpg' )
	->resize(360,220)
	->save( $path_to_images.'/01-resized2.jpg' );

// ...

// chaining another methods after save() method for animated gif files 
// is available only with forked version of GifCreator
GluImage::get( $path_to_images.'/01.gif' )
	->resize(540,360)
	->save( $path_to_images.'/01-resized.gif' )
	->crop(360,220)
	->save( $path_to_images.'/01-resized-and-cropped.gif' );

License

GluImage is licensed under the MIT License.

Copyright 2014 Lukasz Gaszyna