Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.
/ ImageBundle Public archive

[ABANDONED] An image editing bundle using PHP's GD library if other solutions fail for some reason.

License

Notifications You must be signed in to change notification settings

ShadeSoft/ImageBundle

Repository files navigation

Image Bundle for Symfony

ABANDONED - Please use GDImage instead.

An image editing bundle using PHP's GD library if other solutions fail for some reason.

Latest Stable Version Build Status StyleCI Total Downloads License

Installation

Step 1: Download the Bundle

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.

Step 2: Enable the Bundle

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(),
        );

        // ...
    }

    // ...
}

Usage:

Usage with PHP

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

Usage with Twig

{{ 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.

Cache

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