2017 © Pedro Peláez
 

library image

image

lassehaslev/image

  • Friday, April 28, 2017
  • by LasseHaslev
  • Repository
  • 1 Watchers
  • 0 Stars
  • 76 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

image-handler

PHP image handler gives easy to use function for manipulating images, (*1)

Motivation

Resizing and cropping images on web is pain, and i wanted an image-engine that does this for me., (*2)

This package and its base concept is greatly inspired by Croppa., (*3)

Usage

I use this package mainly in my Laravel projects., (*4)

Run composer require lassehaslev/image in your project folder, (*5)

Laravel

If you want to use this package in you laravel project. We automaticly crops and resize the images based on the filename., (*6)

Open config/app.php and add LasseHaslev\Image\Providers\LaravelServiceProvider::class to providers array., (*7)

Classes

You can nativly use this package in all php projects., (*8)

CropHandler

Adds base folder and crops folder and handle image from image path., (*9)

If no crops folder is set, we crate crops in same folder as original., (*10)

$baseFolder = '/image';
$cropsFolder = '/image/crops';
$handler = CropHandler::create( $baseFolder, $cropsFolder );

$this->handler
    ->handle( [
        'name'=>'test-image.jpg',
        'width'=>89,
        'height'=>89,
        'resize'=>true,
    ] )
    ->save( 'test-image-89x89-resize.jpg' );

Adaptors

You can use adapotors to handle image., (*11)

class Adaptor implements CropAdaptorInterface
{
    public function transform( $input, $handler = null )
    {
        return [
            'name'=>$input,
            'width'=>300,
            'height'=>200,
            'resize'=>true,
        ];
    }
}
$baseFolder = '/image';
$cropsFolder = '/image/crops';
$handler = CropHandler::create( $baseFolder, $cropsFolder, new Adaptor );

$this->handler
    ->handle( 'originalFilename.jpg' )
    ->save( 'newFilename' );

ImageModifier

The ImageModifier is the base image class for manipulating the images., (*12)

use LasseHaslev\Image\Modifiers\ImageModifier;
$modifier = ImageModifier::create( { absolute image path } );

// Crop image function
$modifier->crop( $x1, $y1, $x2, $y2 );

// Crop image to width and height based on fucuspoint
$modifier->cropToFit( $width, $height, $focusPointX = 0, $focusPointY = 0 );

// Resize width and height
$modifier->resize( $width, $height );

// Save the new image
$modifier->save( {absolutePath} );

// Example
$modifier->cropToFit( 300, 300 )
    ->save( '/path/to/image.jpg' );

ImageHandler

The ImageHandler is for handling image and the crops. It extends from ImageModifier., (*13)

use LasseHaslev\Image\Handlers\ImageHandler;
$modifier = ImageHandler::create( $filepath );

// Remove the crops
$modifier->removeCrops();

// Save
$modifier->save( $pathOrFilename, $isFullPath = false );

Development

I have a problem with my tests. but i dont know why. Sometimes it passes and sometimes it dont. ``` bash, (*14)

Prepare test images

sh prepare.sh, (*15)

Install php dependencies

composer install, (*16)

Install elixir dependencies

npm install, (*17)

run Test driven development through elixir

gulp tdd ``` ``, (*18)

License

MIT, dawg, (*19)

The Versions

28/04 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Lasse S. Haslev

28/04 2017

0.2.1

0.2.1.0

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Lasse S. Haslev

28/04 2017

0.2.0

0.2.0.0

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Lasse S. Haslev

21/02 2017

0.1.3

0.1.3.0

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Lasse S. Haslev

21/02 2017

0.1.2

0.1.2.0

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Lasse S. Haslev

21/02 2017

0.1.1

0.1.1.0

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Lasse S. Haslev

29/06 2016

dev-development

dev-development

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Lasse S. Haslev

29/06 2016

0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Lasse S. Haslev