ABANDONED - Please use GDImage instead.
An image editing bundle using PHP's GD library if other solutions fail for some reason.
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require shadesoft/image-bundle
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new ShadeSoft\ImageBundle\ShadeSoftImageBundle(),
);
// ...
}
// ...
}
<?php
// src/Acme/DemoController.php
// ...
class DemoController extends Controller
{
public function DemoAction(Request $request) {
$img = '../../web/assets/temp.jpg';
$imgSizer = $this->get('shadesoft_image.sizer');
$imgSizer->thumbnail($img, 400, 300);
}
}
{{ asset('/path/to/image'|thumbnail(400, 300)) }}
{# recommended to use with cache functionality enabled, see below #}
For usage details, please check the 'Parameters' and 'Available functions' sections of the shadesoft/gd-image documentation.
To enable cache, you just need to configure the bundle like below:
# app/config/config.yml for Symfony 2/3, and config/packages/shade_soft_image.yaml for Symfony 4
shade_soft_image:
cache_directory: /path/to/desired/cache/directory