ybert/imagify-bundle

Symfony bundle for Imagify

Installs: 8

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

V1.0.0 2016-10-26 13:08 UTC

This package is auto-updated.

Last update: 2024-04-29 03:50:26 UTC


README

This bundle integrates Imagify PHP in the Symfony framework.

Installation

Use Composer to install the bundle:

composer require ybert/imagify-bundle

Then, update your app/config/AppKernel.php file:

    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Ybert\ImagifyBundle\YbertImagifyBundle(),
            // ...
        );

        return $bundles;
    }

Configure the bundle in app/config/config.yml:

ybert_imagify:
    apiKey: %imagify_apiKey%

Finally, update your app/config/parameters.yml file to store your Imagify API credentials:

parameters:
    # ...
    imagify_apiKey: MyAPIKey

Usage

The bundle automatically registers a ybert_imagify.optimizer service in the Dependency Injection Container. That service is an instance of Imagify\Optimizer.

Example usage in a controller:

// ...

    public function optimizeImage()
    {
        /**
         * Get the Imagify service
         *
         * @var \Imagify\Optimizer $imagify
         */
        $imagify = $this->get('ybert_imagify.optimizer');
        $param = array(
            "level"=> 'ultra',
            "resize"=> array("width"=> 50),
        );
        $image = '1.jpg';
        $result = $imagify->optimize($image, $param);
    }

// ...
}

For further use, please read the Imagify API documentation