PHP code example of ybert / imagify-bundle

1. Go to this page and download the library: Download ybert/imagify-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ybert / imagify-bundle example snippets


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

        return $bundles;
    }

// ...

    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);
    }

// ...
}