2017 © Pedro Peláez
 

library imgman

A library designed to create, modify, handle, and store images from any protocol

image

ripaclub/imgman

A library designed to create, modify, handle, and store images from any protocol

  • Wednesday, May 18, 2016
  • by leodido
  • Repository
  • 5 Watchers
  • 4 Stars
  • 907 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 15 Versions
  • 0 % Grown

The README.md

Image manager

Latest Stable Version Build Status Coverage Status, (*1)

ImgMan is a library that allows you to create various image renditions from any PHP supported URL-style protocol containing a picture., (*2)

You can modify an image (e.g., resize, crop, format, fit in, fit out, rotate) and save different renditions stored in your configuration., (*3)

Requisites

  • PHP >= 5.5, (*4)

  • Composer, (*5)

  • Imagick (the only adapter currently supported to manipulate image), (*6)

Features

ImgMan has various features:, (*7)

  • Core, (*8)

    contains the engine that execute the operations on the image. ImageMagick is the only adapter present., (*9)

  • Operation, (*10)

    Contains a class, HelperPluginManager, that is a AbstractPluginManager where are config all operation that can attach to a rendition (i.e. Compression, Crop, FitIn, FitOut, Format, Resize, Rotate,ScaleToHeight,ScaleToWidth), (*11)

  • Storage, (*12)

    ImgMan allows you to save the image in several layers persistence, via StorageInterface objects (i.e. FileSystem, Mongo), (*13)

  • Image, (*14)

    Contains the class used to the image, (*15)

  • Service, (*16)

    A set of classes aimed at the instantiation of ImgMan service. With this service you can save the image in all renditions configured in the service (grab function) You can also save update, and delete an image in a specific redition, (*17)

Installation

Install ImageImagick (version > 3.1.2) in php extension., (*18)

Add ripaclub/imgman to your composer.json., (*19)

{
   "require": {
       "ripaclub/imgman": "0.5.*"
   }
}

Configuration

Configure service manager with service factory (for storage and service), plugin manager and imagick adapter., (*20)

return [
    \\ ...
    'abstract_factories' => [
         // Load abstract service
        'ImgMan\Service\ImageServiceAbstractFactory',
         // Load abstract factory for mongo storage
        'ImgMan\Storage\Adapter\Mongo\MongoDbAbstractServiceFactory',
        'ImgMan\Storage\Adapter\Mongo\MongoAdapterAbstractServiceFactory',
         // Load abstract factory to FileSystem storage
        'ImgMan\Storage\Adapter\FileSystem\FileSystemAbstractServiceFactory'
          // Load abstract factory to aws storage previus import of aws/aws-sdk-php 3.17.6
        'ImgMan\Storage\Adapter\Cdn\Amazon\S3\S3ServiceAbstractFactory',
        'ImgMan\Storage\Adapter\Cdn\Amazon\CloudFront\CloudFrontServiceAbstractFactory',
        'ImgMan\Storage\Adapter\Cdn\AmazonAdapterAbstractFactory',
    ],
    'factories' => [
         // Load (operation) helper plugin manager
        'ImgMan\Operation\HelperPluginManager' => 'ImgMan\Operation\HelperPluginManagerFactory',
    ],
    'invokables' => [
         // Load adapter
        'ImgMan\Adapter\Imagick' => 'ImgMan\Core\Adapter\ImagickAdapter',
        'ImgMan\ResolverDefault' => 'ImgMan\Storage\Adapter\FileSystem\Resolver\ResolverDefault'
    ],
    \\ ...

];

You can set only one storage configuration. Configure storage (e.g Mongo) where to save the images:, (*21)

return [
    \\ ...
    'imgman_mongodb' => [
        'MongoDb' => [
            'database' => 'imgManStorage'
        ]
    ],
    'imgman_adapter_mongo' => [
        'Storage' => [
            'collection' => 'image_test',
            'database' => 'MongoDb'
        ]
    ],
    \\ ...
 ];

E.g aws configuration:, (*22)

return [
    \\ ...
       'imgman_amazon_client' => [
           'AmazonS3Client' => [
               'secret' => 'testSecret',
               'key' => 'testKey',
               'region' => 'testRegion',
               'version' => 'latest',
               'name' => 'S3'
           ],
           'AmazonCloudFrontClient' => [
               'secret' => 'testSecret',
               'key' => 'testKey',
               'region' => 'testRegion',
               'version' => 'latest',
               'name' => 'CloudFront'
           ]
       ],
       'imgman_amazon_s3_service' => [
           'S3Service' => [
               'client' => 'AmazonS3Client',
               'bucket' => 'test'
           ]
       ],
       'imgman_amazon_cloud_front_service' => [
           'CloudFrontService' => [
               'client' => 'AmazonCloudFrontClient',
               'domain' => 'testdomain'
           ]
       ],
       'imgman_amazon_adapter' => [
           'Storage' => [
               's3_client' => 'S3Service',
               'cloud_front_client' => 'CloudFrontService',
               'name_strategy' => 'default',
               'name_strategy_config' => [
                   'prefix' => 'test'
               ]
           ]
       ]
    \\ ...
 ];

E.g filesystem configuration:, (*23)

return [
    \\ ...
        'imgman_adapter_filesystem' => [
            'Storage' => [
                'path' => DIR_PATH_,
                'resolver' => 'ImgMan\ResolverDefault'
            ],
        ]
    \\ ...
 ];

Configure ImgMan service with the storage, helper, adapter and the various operations to attach on the renditions:, (*24)

return [
    \\ ...
    'imgman_services' => [
        'ImgMan\Service\First' => [
            'adapter' => 'ImgMan\Adapter\Imagick',
            'storage' => 'Storage',
            'helper_manager' => 'ImgMan\Operation\HelperPluginManager',
            'renditions' => [
                'thumb' => [
                    'resize' => [
                        'width'  => 200,
                        'height' => 200,
                    ],
                    'compression' => [
                        'compression' => 90,
                        'compressionQuality' => 70,
                    ]
                ],
                'thumbmaxi' => [
                    'resize' => [
                        'width'  => 400,
                        'height' => 400,
                    ],
                ],
            ],
        ],
    ],
    \\ ...
 ];

Usage

Now we get the IgmMan service, load a picture from file stream (filesystem) and save it in 3 renditions (original, thumb, and thumbmaxi)., (*25)

$imgMan = $this->getServiceLocator()->get('ImgMan\Service\First');
$image = new ImgMan\Image\Image(__DIR__. '/../../../name_image.png'); //the path can be also a URL
$imgMan->grab($image, '/first/name/identifier/');

Finally, we can recover the image rendition we desire this way:, (*26)

$imageOriginal = $imgMan->get('/first/name/identifier/', 'original');
$imageThumb = $imgMan->get('/first/name/identifier/', 'thumb');
$imageThumbMaxi = $imgMan->get('/first/name/identifier/', 'thumbmaxi');

Analytics, (*27)

The Versions

18/05 2016

dev-master

9999999-dev https://github.com/ripaclub/imgman

A library designed to create, modify, handle, and store images from any protocol

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

image resize crop gd imagick images rotate pictures streams picture figure image manager image magick renditions fit in fit out figures

18/05 2016

v1.2.2

1.2.2.0 https://github.com/ripaclub/imgman

A library designed to create, modify, handle, and store images from any protocol

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

image resize crop gd imagick images rotate pictures streams picture figure image manager image magick renditions fit in fit out figures

18/05 2016

dev-develop

dev-develop https://github.com/ripaclub/imgman

A library designed to create, modify, handle, and store images from any protocol

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

image resize crop gd imagick images rotate pictures streams picture figure image manager image magick renditions fit in fit out figures

17/05 2016

v1.2.1

1.2.1.0 https://github.com/ripaclub/imgman

A library designed to create, modify, handle, and store images from any protocol

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

image resize crop gd imagick images rotate pictures streams picture figure image manager image magick renditions fit in fit out figures

16/05 2016

v1.2.0

1.2.0.0 https://github.com/ripaclub/imgman

A library designed to create, modify, handle, and store images from any protocol

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

image resize crop gd imagick images rotate pictures streams picture figure image manager image magick renditions fit in fit out figures

16/05 2016

v1.1.0

1.1.0.0 https://github.com/ripaclub/imgman

A library designed to create, modify, handle, and store images from any protocol

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

image resize crop gd imagick images rotate pictures streams picture figure image manager image magick renditions fit in fit out figures

13/05 2016

v0.6.0

0.6.0.0 https://github.com/ripaclub/imgman

A library designed to create, modify, handle, and store images from any protocol

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

image resize crop gd imagick images rotate pictures streams picture figure image manager image magick renditions fit in fit out figures

13/05 2016

v1.0.0

1.0.0.0 https://github.com/ripaclub/imgman

A library designed to create, modify, handle, and store images from any protocol

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

image resize crop gd imagick images rotate pictures streams picture figure image manager image magick renditions fit in fit out figures

21/04 2016

v0.5.0

0.5.0.0 https://github.com/ripaclub/imgman

A library designed to create, modify, handle, and store images from any protocol

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

image resize crop gd imagick images rotate pictures streams picture figure image manager image magick renditions fit in fit out figures

30/09 2015

v0.4.1

0.4.1.0 https://github.com/ripaclub/imgman

A library designed to create, modify, handle, and store images from any protocol

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

image resize crop gd imagick images rotate pictures streams picture figure image manager image magick renditions fit in fit out figures

16/03 2015

v0.4.0

0.4.0.0 https://github.com/ripaclub/imgman

A library designed to create, modify, handle, and store images from any protocol

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

image resize crop gd imagick images rotate pictures streams picture figure image manager image magick renditions fit in fit out figures

04/11 2014

v0.3.1

0.3.1.0 https://github.com/ripaclub/imgman

A library designed to create, modify, handle, and store images from any protocol

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

image resize crop gd imagick images rotate pictures streams picture figure image manager image magick renditions fit in fit out figures

29/10 2014

v0.3.0

0.3.0.0 https://github.com/ripaclub/imgman

A library designed to create, modify, handle, and store images from any protocol

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

image resize crop gd imagick images rotate pictures streams picture figure image manager image magick renditions fit in fit out figures