Symfony Bundle to assist in imagine manipulation using the imagine library

Overview

LiipImagineBundle

PHPUnit PHP-CS-Fixer Coverage Downloads Release
PHPUnit PHP-CS-Fixer Coverage Downloads Latest Stable Version

This bundle provides an image manipulation abstraction toolkit for Symfony-based projects.

Overview

Example

Suppose you defined a my_thumb filter set, which can be configured to perform any number of different transformations. The simplest invocation would be to pipe the path of your image to the provided imagine_filter Twig filter.

">
<img src="{{ asset('/relative/path/to/image.jpg') | imagine_filter('my_thumb') }}" />

Contributor Code of Conduct

This project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Attribution

  • Thanks to the many contributors who have dedicated their time and code to this project.

  • The standalone PHP Imagine Library is used by this bundle for image transformations.

  • This package was forked from AvalancheImagineBundle with the goal of making the code more extensible. Reference AvalancheImagineBundle#25 for additional information on the reasoning for this fork.

Setup

Installation

Using this package is similar to all Symfony bundles. The following steps must be performed

  1. Download the Bundle
  2. Enable the Bundle
  3. Register the Routes

Detailed setup instructions can be found in the installation chapter of the documentation.

Configuration

Detailed information on all available configuration options can be found in the configuration chapter of the documentation.

Usage Primer

Generally, this bundle works by applying filter sets to images from inside a template. Your filter sets are defined within the application's configuration file (often app/config/config.yml) and are comprised of a collection of filters, post-processors, and other optional parameters.

We'll learn more about post-processors and other available parameters later, but for now lets focus on how to define a simple filter set comprised of a few filters.

Create Thumbnails

Before we get started, there is a small amount of configuration needed to ensure our data loaders and cache resolvers operate correctly. Use the following boilerplate in your configuration file.

# app/config/config.yml

liip_imagine :

    # configure resolvers
    resolvers :

        # setup the default resolver
        default :

            # use the default web path
            web_path : ~

    # your filter sets are defined here
    filter_sets :

        # use the default cache configuration
        cache : ~

With the basic configuration in place, we'll start with an example that fulfills a common use-case: creating thumbnails. Lets assume we want the resulting thumbnails to have the following transformations applied to them:

  • Scale and crop the image to 120x90px.
  • Add a 2px black border to the scaled image.
  • Adjust the image quality to 75.

Adding onto our boilerplate from above, we need to define a filter set (which we'll name my_thumb) with two filters configured: the thumbnail and background filters.

# app/config/config.yml

liip_imagine :
    resolvers :
        default :
            web_path : ~

    filter_sets :
        cache : ~

        # the name of the "filter set"
        my_thumb :

            # adjust the image quality to 75%
            quality : 75

            # list of transformations to apply (the "filters")
            filters :

                # create a thumbnail: set size to 120x90 and use the "outbound" mode
                # to crop the image when the size ratio of the input differs
                thumbnail  : { size : [120, 90], mode : outbound }

                # create a 2px black border: center the thumbnail on a black background
                # 4px larger to create a 2px border around the final image
                background : { size : [124, 94], position : center, color : '#000000' }

You've now created a filter set called my_thumb that performs a thumbnail transformation. The thumbnail filter sizes the image to the desired width and height (in this example, 120x90px), and its mode: outbound option causes the resulting image to be cropped if the input ratio differs. The background filter results in a 2px black border by creating a black canvas 124x94px in size, and positioning the thumbnail at its center.

Note: A filter set can have any number of filters defined for it. Simple transformations may only require a single filter while complex transformations can have an unlimited number of filters defined for them.

There are a number of additional filters, but for now you can use your newly defined my_thumb filter set immediately within a template.

For Twig-based template, use:

">
<img src="{{ asset('/relative/path/to/image.jpg') | imagine_filter('my_thumb') }}" />

Or, for PHP-based template, use:

filter('/relative/path/to/image.jpg', 'my_thumb') ?>" /> ">
"filter('/relative/path/to/image.jpg', 'my_thumb') ?>" />

Behind the scenes, the bundle applies the filter(s) to the image on-the-fly when the first page request is served. The transformed image is then cached for subsequent requests. The final cached image path would be similar to /media/cache/my_thumb/relative/path/to/image.jpg.

Note: *Using the dev environment you might find that images are not properly rendered via the template helper. This is often caused by having intercept_redirect enabled in your application configuration. To ensure images are rendered, it is strongly suggested to disable this option:

# app/config/config_dev.yml

web_profiler :
    intercept_redirects : false

Runtime Options

Sometime, you may have a filter defined that fulfills 99% of your usage scenarios. Instead of defining a new filter for the erroneous 1% of cases, you may instead choose to alter the behavior of a filter at runtime by passing the template helper an options array.

For Twig-based template, use:

">
{% set runtimeConfig = {"thumbnail": {"size": [50, 50] }} %}

<img src="{{ asset('/relative/path/to/image.jpg') | imagine_filter('my_thumb', runtimeConfig) }}" />

Or, for PHP-based template, use:

array( "size" => array(50, 50) ) ); ?> ">

$runtimeConfig = array(
    "thumbnail" => array(
        "size" => array(50, 50)
    )
);
?>

<img src=" $this['imagine']->filter('/relative/path/to/image.jpg', 'my_thumb', $runtimeConfig) ?>" />

Path Resolution

Sometime you need to resolve the image path returned by this bundle for a filtered image. This can easily be achieved using Symfony's console binary or programmatically from within a controller or other piece of code.

Resolve with the Console

You can resolve an image URL using the console command liip:imagine:cache:resolve. The only required argument is one or more relative image paths (which must be separated by a space).

$ php bin/console liip:imagine:cache:resolve relative/path/to/image1.jpg relative/path/to/image2.jpg

Additionally, you can use the --filter option to specify which filter you want to resolve for (if the --filter option is omitted, all available filters will be resolved).

$ php bin/console liip:imagine:cache:resolve relative/path/to/image1.jpg --filter=my_thumb

Resolve Programmatically

You can resolve the image URL in your code using the getBrowserPath method of the liip_imagine.cache.manager service. Assuming you already have the service assigned to a variable called $imagineCacheManager, you would run:

$imagineCacheManager->getBrowserPath('/relative/path/to/image.jpg', 'my_thumb');

Often, you need to perform this operation in a controller. Assuming your controller inherits from the base Symfony controller, you can take advantage of the inherited get method to request the liip_imagine.cache.manager service, from which you can call getBrowserPath on a relative image path to get its resolved location.

/** @var CacheManager */
$imagineCacheManager = $this->get('liip_imagine.cache.manager');

/** @var string */
$resolvedPath = $imagineCacheManager->getBrowserPath('/relative/path/to/image.jpg', 'my_thumb');

Filters

This bundle provides a set of built-in filters and you may easily define your own filters as well. Reference the filters chapter from our documentation.

Use as a Service

If you need to use your defined "filter sets" from within your controller, you can fetch this bundle's FilterService from the service container to do the heavy lifting for you.



class MyController extends Controller
{
    public function indexAction()
    {
        /** @var FilterService */
        $imagine = $this
            ->container
            ->get('liip_imagine.service.filter');

        // 1) Simple filter, OR
        $resourcePath = $imagine->getUrlOfFilteredImage('uploads/foo.jpg', 'my_thumb');
        
        // 2) Runtime configuration
        $runtimeConfig = [
            'thumbnail' => [
                'size' => [200, 200]
            ],
        ];
        $resourcePath = $imagine->getUrlOfFilteredImageWithRuntimeFilters(
            'uploads/foo.jpg',
            'my_thumb',
            $runtimeConfig
        );

        // ..
    }
}

?>

Data Roots

By default, Symfony's web/ directory is registered as a data root to load assets from. For many installations this will be sufficient, but sometime you may need to load images from other locations. To do this, you must set the data_root parameter in your configuration (often located at app/config/config.yml).

liip_imagine:
    loaders:
        default:
            filesystem:
                data_root: /path/to/source/images/dir

As of version 1.7.2 you can register multiple data root paths, and the file locator will search each for the requested file.

liip_imagine:
    loaders:
        default:
            filesystem:
                data_root:
                    - /path/foo
                    - /path/bar

As of version 1.7.3 you ask for the public resource paths from all registered bundles to be auto-registered as data roots. This allows you to load assets from the Resources/public folders that reside within the loaded bundles. To enable this feature, set the bundle_resources.enabled configuration option to true.

liip_imagine:
    loaders:
        default:
            filesystem:
                bundle_resources:
                    enabled: true

If you want to register some of the Resource/public folders, but not all, you can do so by blacklisting the bundles you don't want registered or whitelisting the bundles you do want registered. For example, to blacklist (not register) the bundles "FooBundle" and "BarBundle", you would use the following configuration.

liip_imagine:
    loaders:
        default:
            filesystem:
                bundle_resources:
                    enabled: true
                    access_control_type: blacklist
                    access_control_list:
                        - FooBundle
                        - BarBundle

Alternatively, if you want to whitelist (only register) the bundles "FooBundle" and "BarBundle", you would use the following configuration.

liip_imagine:
    loaders:
        default:
            filesystem:
                bundle_resources:
                    enabled: true
                    access_control_type: whitelist
                    access_control_list:
                        - FooBundle
                        - BarBundle

Permissions

Image locations must be readable by your web server. On a system that supports setfacl (such as Linux/BSD), use

HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1`

sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX /path/to/source/images/dir

sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX /path/to/source/images/dir

See the Symfony Permissions documentation for commands compatible with macOS and other environments.

Using Apache

You need to grant read access for Apache by adding the following to your Apache VHost configuration

AllowOverride None Allow from All ">
<VirtualHost *:80>
    

    Alias /FavouriteAlias /path/to/source/images/dir
    <Directory "/path/to/source/images/dir">
        AllowOverride None
        Allow from All
    Directory>
VirtualHost>

Alternatively, you can place the directive in a separate file within your project, and include it within your Apache VHost configuration. For example, you can create the file app/config/apache/photos.xml and add the following to your VHost file

">
<VirtualHost *:80>
    

    Include "/path/to/your/project/app/config/apache/photos.xml"
VirtualHost>

This method keeps the file with the rest of your code, allowing you to change it easily or create different environment-dependent configuration files.

Once you have configured Apache properly, the relative path to an image with the following absolute path /path/to/source/images/dir/logo.png must be /FavouriteAlias/logo.png.

Documentation

For more detailed information about the features of this bundle, refer to the documentation.

Comments
  • Symfony 3.4 and Symfony 4 Support

    Symfony 3.4 and Symfony 4 Support

    New SF3.4 and SF4.0 will be released tomorrow. It would be nice if LiipImagineBundle support these versions.

    Uncaught PHP Exception Liip\ImagineBundle\Exception\InvalidArgumentException: "Root image path not resolvable "...Web/src/../web"" at ...Web/vendor/liip/imagine-bundle/Binary/Locator/FileSystemLocator.php line 123

    My config:

    liip_imagine:
    
        resolvers:
            default:
                web_path:
                    web_root: "%kernel.project_dir%/"
                    cache_prefix: "public/imagine/cache"
        loaders:
            default:
                filesystem:
                    data_root: "%kernel.project_dir%/"
    
        driver:               "gd"
        cache:                default
        data_loader:          default
        # define your filter sets under this option
        filter_sets: ...
    

    By url I can see that it's for sure ignoring cache_prefix: "public/imagine/cache"

    opened by theedov 64
  • Roadmap 2.0

    Roadmap 2.0

    • [ ] Decouple cache from filter and filter config.
    • [ ] Decouple loader from filter and filter config.
    • [ ] Create a facade service. move logic from filterAction to it.
    • [ ] Ability to change format of cached image (TBD)
    • [ ] Cleanup code, remove duplications and deprecations.
    • [ ] Symfony 2.8 as minimum version
    • [ ] PHP 5.5 as minimum version.
    • [ ] Remove cache images with runtime config applied
    • [ ] Add ability to force cache generation. Do not use controller, always return url to cached image.
    State: Confirmed 
    opened by makasim 53
  • Complete S3 Setup: Original Images and cached Images on AWS S3

    Complete S3 Setup: Original Images and cached Images on AWS S3

    I have already commented on this issue ( #63 ), but the whole thing might be worth an own topic. It might be the case that I just misconfigured the whole thing but I can't find out which part i misconfigured or is not working.

    I try to create a full S3 setup, which means that the original images come from S3 (which should be handlet by the stream data loader, as far as I understood it) and also the cache should be saved onto S3 which should be handled via the S3 cache resolver.

    However parts or the whole thing is not working in my setup:

    Services:

    services:
        amazonS3:
            class: AmazonS3
            arguments:
                options:
                    key:      '%aws_key%'
                    secret:   '%aws_secret_key%'
                    certificate_authority: "%kernel.root_dir%/Resources/cert/cacert.pem"
    
    
        liip_imagine.data.loader.stream.profile:
            class: "%liip_imagine.data.loader.stream.class%"
            arguments:
                - "@liip_imagine"
                - 'gaufrette://profile/'
            tags:
                - { name: 'liip_imagine.data.loader', loader: 'stream.profile' }
    
        liip_imagine.cache.resolver.amazon_s3:
              class: Liip\ImagineBundle\Imagine\Cache\Resolver\AmazonS3Resolver
              arguments:
                  - "@amazonS3"
                  - "%aws_s3_bucket%"
              tags:
                  - { name: 'liip_imagine.cache.resolver', resolver: 'cache.amazon_s3' }
    

    Imagine and Gaufrette Setup:

    knp_gaufrette:
        stream_wrapper:
            filesystems:
                profile: profile_fs
        adapters:
            team_adapter:
                amazon_s3:
                    amazon_s3_id: amazonS3 
                    bucket_name: %aws_s3_bucket%
                    options:
                        create: true
                        directory:  teams
            profile_adapter:
                amazon_s3:
                    amazon_s3_id: amazonS3 
                    bucket_name: %aws_s3_bucket%
                    options:
                        create: true
                        directory:  profile
        filesystems:
            team_fs:
                adapter:    team_adapter
            profile_fs:
                adapter:    profile_adapter
    
    
    liip_imagine:
        cache: cache.amazon_s3
        formats:              []
        filter_sets:           
            profile_thumb:
                data_loader: stream.profile
                quality: 75
                filters:
                    thumbnail: { size: [90, 90], mode: outbound }
            profile_thumb_small:
                data_loader: stream.profile
                quality: 75
                filters:
                    thumbnail: { size: [30, 30], mode: outbound }
    
    

    The original Images are uploaded via VichUploaderBundle which is working perfectly fine. But the cache images are not created anywhere and the url returned by the view helper looks also very odd:

    <img class="img-profile" src="/web/app_dev.php/media/cache/profile_thumb/gaufrette://profile_fs/51d44401a4bd5.jpeg">
    <img class="img-profile" src="gaufrette://profile_fs/51d44401a4bd5.jpeg">
    
    

    The referenced view looks like this

                <img class="img-profile" src="{{ user.profilePic | imagine_filter('profile_thumb', false) }}" />
                <img class="img-profile" src="{{ user.profilePic }}" />
    

    Has someone a working setup with both the gaufrette stream data loader and a cache resolver? Maybe @neilferreira?

    Or could someone point me in the right direction to figure this out?

    ------------------ edit ------------------- For the referenced Issue here is my VichUploaderConfig:

    vich_uploader:
        db_driver: orm # or mongodb
        gaufrette: true
        storage: vich_uploader.storage.gaufrette
        mappings:
            team_logo:
                uri_prefix:  https://s3-eu-west-1.amazonaws.com/%aws_s3_bucket%/teams # you'll need this set to use the Vich URL generator
                upload_destination: team_fs
            profile_image:
                uri_prefix: https://s3-eu-west-1.amazonaws.com/%aws_s3_bucket%/profile # you'll need this set to use the Vich URL generator
                upload_destination: profile_fs
                namer: vich_uploader.namer_uniqid
                delete_on_remove: true
                delete_on_update: true
    
    Attn: Critical State: Rejected 
    opened by KeKs0r 51
  • Image not generated and

    Image not generated and "resolve" in path

    Hello, It seems that LiipImagineBundle does not create the cached image and there is a "resolve" in the path returned by imagine_filter.

    Here the twig code : < img src="{{ asset('img/gallery/p1/test2.jpg') | imagine_filter('my_thumb') }}" /> And the path returned: http://localhost/app_dev.php/media/cache/resolve/my_thumb/img/gallery/p1/test2.jpg

    If I want to generate an image, I have to manually create the image using: app/console liip:imagine:cache:resolve relative/path/to/image.jpg relative/path/to/image2.jpg --filters=my_thumb --filters=thumbnail_default

    How can I automatically generate the image? Thanks

    opened by phong-steph 46
  • No redirect option

    No redirect option

    This partially fixes #429. I know that tests are failing, but I need some help to setup tests on OS X.

    <?php
    // LiipImagineBundle/Tests/Functional/Controller/ImagineControllerTest.php
    $this->webRoot = self::$kernel->getContainer()->getParameter('kernel.root_dir').'/web';
    $this->cacheRoot = $this->webRoot.'/media/cache';
    $this->filesystem = new Filesystem;
    $this->filesystem->remove($this->cacheRoot);
    

    This generates path to unexisting folder, maybe some one can give me some points?

    opened by ama3ing 45
  • Rotation issue

    Rotation issue

    Hello.

    I'm experiencing a weird bug. I'm using the thumbnail filters and when my users upload a picture for example this one: pic

    Automatically is rotated... I've checked the exif data for this one and in orientation I found Orientation Rotate 90 CW So, I'm guessing that the bundle is taking the orientation on the exif data and applying automatically, but this behaviour can be deactivated? Because in this case this image is vertical but after uploading it, the thumbnail is displayed as landscape...

    Thanks!

    Edit --> After updating the picture here, is also rotated.

    State: Reviewing 
    opened by Merk87 39
  • "Cache directory creation problem" and "source image could not be found" with v1.7

    Hello.

    After upgrade this bundle from 1.6 to 1.7 my project doesn't works well.

    In my local environment everything works well. My "web/media/cache" dir exists with all permissions. But when I deploy my app to a production server with Capifony, it seems that this bundle can't create "cache" directory.

    Is there some change related with directory creation in this update? In my deployment server I only have "web/media" dir with all permissions, the "web/media/cache" is not deployed...

    opened by davidromani 38
  • Add WebP image conversion support

    Add WebP image conversion support

    | Q | A | --- | --- | Branch? | 2.0 | Bug fix? | no | New feature? | yes | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #755 | License | MIT | Doc PR |

    This is a simple solution. Each time a filtered image is created, a copy of it is created in the WebP format and saved to the same address with the same name and the .webp suffix. If the browser supports WebP, it redirects the user to the Webp version of the image, otherwise to the picture in the format in accordance with the configurations.

    Documentation

    The WebP format better optimizes the quality and size of the compressed image compared to JPEG and PNG. Google strongly recommends using this format. You can set it as the default format for all images.

    liip_imagine:
        default_filter_set_settings:
            format: webp
    

    However, not all browsers support the WebP format, and for compatibility with all browsers it is recommended to return images in their original format for those browsers that do not support WebP. This means that you need to store 2 versions of the image. One in WebP format and the other in original format. Remember that this almost doubles the amount of used space on the server for storing filtered images.

    liip_imagine:
        # configure webp
        webp:
            generate:    true
            quality:     100
            cache:       ~
            data_loader: ~
            post_processors: []
    
        # example filter
        filter_sets:
            thumbnail_web_path:
                filters:
                    thumbnail: { size: [223, 223], mode: inset }
    

    If browser supports WebP, the request

    https://localhost/media/cache/resolve/thumbnail_web_path/images/cats.jpeg

    will be redirected to

    https://localhost/media/cache/thumbnail_web_path/images/cats.jpeg.webp

    otherwise to

    https://localhost/media/cache/thumbnail_web_path/images/cats.jpeg

    opened by peter-gribanov 35
  • Thumbnails doesn't appear and are not created

    Thumbnails doesn't appear and are not created

    Hello,

    I have this problem on Symfony v2.1.11. It seems other people have this problem.

    To verify it, I installed a clean version of Symfony v2.3.1 in new folder with: php composer.phar create-project symfony/framework-standard-edition path/ 2.3.1

    I made configuration, and verified it with config.php, it's ok.

    I installed LiipImagnineBundle with composer adding in composer.json:

    "imagine/Imagine": "0.4.*",
    "liip/imagine-bundle": "dev-master"
    

    composer update works

    I enabled LiipImagineBundle in app/AppKernel.php with: new Liip\ImagineBundle\LiipImagineBundle(),

    I configured LiipImagineBundle route in app/config/routing.yml with:

    _imagine:
        resource: .
        type:     imagine
    

    And I configured LiipImagineBundle in app/config/config.yml with:

    liip_imagine:
        filter_sets:
            my_thumb:
                quality: 75
                filters:
                    thumbnail: { size: [120, 90], mode: outbound }
    

    To make a simple test I add this line in the welcome page /src/Acme/DemoBundle/Resources/views/Welcome/index.html.twig:

    <img src="{{ 'bundles/acmedemo/images/welcome-quick-tour.gif' | imagine_filter('my_thumb') }}" />

    but when I go to the page the thumnail doesn't appear. When I verify the HTML code in browser I have this: <img src="/symfony-test/web/app_dev.php/media/cache/my_thumb/bundles/acmedemo/images/welcome-quick-tour.gif">

    About the path, I already tried with or without parentheses and with or without asset() : same problem. I didn't find interesting topics about this on stackoverflow.

    I use PHP 5.4.9 on Ubuntu.

    Any idea ? Many thanks.

    Attn: Critical State: Rejected 
    opened by Kwadz 35
  • Multiple

    Multiple "Source image could not be found" since 1.7 update

    Since the update to 1.7, I have problems with images not being found and therefore no image beeing generated by the bundle.

    Error is "Source image could not be found", and "[1/2] NotLoadableException: Source image invalid "C:\wamp\www\MyProject\src\MyBundle\Resources\public\images\icon.png" as it is outside of the defined root path".

    I haven't changed my config

    liip_imagine:
        resolvers:
            default:
                web_path: ~
        filter_sets:
            cache: ~
            thumb:
                filters:
                    background: { size: [1140, 400], color: '#fff' }
                    strip: ~
    

    I'm also using VichUploaderBundle and the Symfony asset versioning system

    framework:
        assets:
            version: 'X'
    

    so my Twig looks either like

    {{ asset('bundles/mybundle/images/icon.png'|imagine_filter('thumb')) }}

    or

    {{ vich_uploader_asset(enity, 'iconFile')|imagine_filter('thumb') }}

    My assets are installed with symbolic links.

    opened by picks44 34
  • Does LiipImagineBundle support remote image?

    Does LiipImagineBundle support remote image?

    I have try the following code:

    {{'http://www.other-domain.com/img.jpg'|imagine_filter('face')}}
    {{'http://www.my-domain.com/my-img.jpg'|imagine_filter('face')}}
    

    LiipImagineBundle does not generate cache, but I tried the following code:

    {{'/my-img.jpg'|imagine_filter('face')}}
    

    Now it works.

    Any way to process pictures with absolute URL or remote pictures?

    Thanks.

    opened by saharabear 34
  • Thumbnail Amazon S3 + cache

    Thumbnail Amazon S3 + cache

    I'm trying to do thumbnails of already uploaded images on AWS S3.

    I followed theses steps : https://io.serendipityhq.com/experience/how-to-use-liipimaginebundle-to-manage-thumbnails-through-amazon-s3/

    But I still have something that do not work locally.

    Preconditions

    services.yaml

    liip_imagine:
        loaders:
            loader_aws_s3_images:
                stream:
                    # This refers to knp_gaufrette filesystems configuration
                    wrapper: gaufrette://articleImage_fs/
        resolvers:
            cache_resolver_aws_s3:
                aws_s3:
                    bucket: '%env(AWS_PUBLIC_BUCKET_NAME)%'
                    client_config:
                        credentials:
                            key: '%env(AWS_KEY)%'
                            secret: '%env(AWS_S3_SECRET_KEY)%'
                        region: 'us-east-1'
                        version: '2006-03-01'
                    get_options:
                        Scheme: 'https'
                    put_options:
                        CacheControl: 'max-age=86400'
        filter_sets:
            medium_thumb:
                data_loader: loader_aws_s3_images
                # We don't yet have a cache resolver configured
                cache: cache_resolver_aws_s3
                quality: 75
                filters:
                    thumbnail: { size: [ 400, 400 ], mode: outbound }
    

    knp_gaufrette.yaml

    knp_gaufrette:
        stream_wrapper: ~
        adapters:
            articleImage_adapter:
                aws_s3:
                    service_id: 'ct_file_store.s3'
                    bucket_name: '%env(AWS_PUBLIC_BUCKET_NAME)%'
                    detect_content_type: true
                    options:
                        create: true
                        directory: 'articleImages'
        filesystems:
            articleImage_fs:
                adapter: articleImage_adapter
    

    list.html.twig

    <img src="{{ article.image ? (aws_public_bucket ~ blogImages_path ~ article.image.blogImageName)|imagine_filter('medium_thumb') : asset('images/blog/placeholder-image.png') }}" alt="{{ article.title }}" class="img-responsive img-article">

    Expected result & Actual result

    Image are still not visible like the link is broken. I can see in the DOM that the URL is : https://localhost:8000/media/cache/resolve/medium_thumb/articleImages/635fa37ca598a_check_ok.png (so it looks good, if I compare with previous tutorial)

    But then when I reload page, URL must change, and it doesn't.

    Actually, if I put '|imagine_filter('medium_thumb')' right after 'asset('images/blog/placeholder-image.png')', thumbnail is working but not for images coming from AWS S3.

    Please any advices ?

    opened by Matteo989 0
  • AWS S3 cache resolver does not work with metadata

    AWS S3 cache resolver does not work with metadata

    Problem with AWS credentials without key and secret stored in envs. According to that page: https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials.html we have this setup:

    [Assume an IAM role](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials_assume_role.html).
    
    IAM roles provide applications on the instance with temporary security credentials to make AWS calls. For example, IAM roles offer an easy way to distribute and manage credentials on multiple Amazon EC2 instances.
    

    Upload of images to AWS S3 is working fine, only cache creates cause problem.

    Preconditions

    1. Symfony 5.4
    2. Liip Imagine bundle 2.9.0

    Steps to reproduce

    1. Package config
    # Liip Imagine
    liip_imagine:
      loaders:
        aws_loader:
          flysystem:
            filesystem_service: oneup_flysystem.aws_filesystem_filesystem
      data_loader: aws_loader
      cache: aws_resolver
      filter_sets:
        small:
          quality: 85
          filters:
            downscale:
              max: [150, 150]
        original:
          quality: 100
    

    service:

      image.cache.resolver.aws_s3_resolver:
        class: Liip\ImagineBundle\Imagine\Cache\Resolver\AwsS3Resolver
        arguments:
          - '@storage.aws.client'
          - '%env(FILE_BUCKET_NAME)%'
        tags:
          - { name: "liip_imagine.cache.resolver", resolver: "aws_resolver" }
    
      storage.aws.client:
        class: Aws\S3\S3Client
        arguments:
          - region: "%env(AWS_REGION)%"
            version: latest
            endpoint: "%env(CLOUD_FRONT_DOMAIN)%"
            use_path_style_endpoint: true
            credentials: ~
    

    Expected result

    1. Firing up image with filter cache it should create cached image to the AWS S3

    Actual result

    Uncaught PHP Exception Liip\ImagineBundle\Exception\Imagine\Cache\Resolver\NotStorableException: "The object could not be created on Amazon S3." at /app/vendor/liip/imagine-bundle/Imagine/Cache/Resolver/AwsS3Resolver.php line 133 {"exception":"[object] (Liip\\ImagineBundle\\Exception\\Imagine\\Cache\\Resolver\\NotStorableException(code: 0): The object could not be created on Amazon S3. at /app/vendor/liip/imagine-bundle/Imagine/Cache/Resolver/AwsS3Resolver.php:133)\n[previous exception] [object] (Aws\\S3\\Exception\\S3Exception(code: 0): Error executing \"PutObject\" on \"https://my.s3/my-bucket/small/uploads/product/images/1920/image.jpg\"; AWS HTTP error: Client error: `PUT https://my.s3/my-bucket/small/uploads/product/images/1920/image.jpg` resulted in a `403 Forbidden` response:\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>PGAD0F (truncated...)\n AccessDenied (client): Access Denied - <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>PGAD0FDNGZFFXV6Q</RequestId><HostId>ekuOedPkd9CiGo5owWlttn3DKbwYx5aVcDSQ2EC0vgv4pmky5ZuIL4TUqHfdddEiG3rzRaDi03k=</HostId></Error> at /app/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:195)\n[previous exception] [object] (GuzzleHttp\\Exception\\ClientException(code: 403): Client error: `PUT https://my.s3/my-bucket/small/uploads/product/images/1920/image.jpg` resulted in a `403 Forbidden` response:\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>PGAD0F (truncated...)\n at /app/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113)"} {"request_id":"552f6c3e-f749-4b00-85d6-baf85465ebfb"
    

    the cache image only works if I'm adding this policy to bucket:

    {
    	"Version": "2012-10-17",
    	"Statement": [
    		{
    			"Effect": "Allow",
    			"Principal": "*",
    			"Action": "s3:*",
    			"Resource": "arn:aws:s3:::my-bucket/*"
    		}
    	]
    }
    

    but this is opening our bucket to world and it is not secured at all.

    The same service storage.aws.client is used to upload images to S3. Can we use this setup without credentials to create cache ?

    opened by CodeMiner84 0
  • [Cache] Programmatically manage the cache

    [Cache] Programmatically manage the cache

    Is your feature request related to a problem? Please describe. Currently it seems rather hard to remove or warmup the cache in controllers for example.

    Describe the solution you'd like I would like to have a Service that would mimmic the functionnality on the liip:imagine:cache:remove and liip:imagine:cache:resolve.

    Describe alternatives you've considered Not doing this leads to either:

    • Call the command from within the application, but this is rather verbose (https://symfony.com/doc/current/console/command_in_controller.html)
    • Duplicate the functionality that would find the correct filters (resolveInputFiltersAndPaths) and bustCache (or warmUpCache) on each of them

    Additional context ~

    opened by homersimpsons 1
  • Defaults to service id over loader name for Filters

    Defaults to service id over loader name for Filters

    | Q | A | --- | --- | Branch? | 2.x | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes/no | Fixed tickets | First step for #1485 | License | MIT | Doc | TODO

    opened by homersimpsons 4
  • Automatically tag and register filters

    Automatically tag and register filters

    Is your feature request related to a problem? Please describe. Using custom filters is pretty verbose, you have to:

    1. Extend the Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface
    2. Create a service in your services.yaml
    3. Tag the service with the liip_imagine.filter.loader
    4. Add a loader property to the tag that will then be referred in the filter_sets

    Describe the solution you'd like Using a proper symfony compiler pass would reduce this to only the first step (1. Extend the Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface)

    In fact for (2.) and (3.), the service could be tagged automatically:

    $container->registerForAutoconfiguration(LoaderInterface::class)->addTag('liip_imagine.filter.loader');
    

    And for (4.) we could use the service_id:

    $tags = $container->findTaggedServiceIds('liip_imagine.filter.loader');
    foreach ($tags as $serviceId => $tags) {
        $manager->addMethodCall('addLoader', [$serviceId, new Reference($serviceId)]);
    }
    

    Describe alternatives you've considered ~

    Additional context ~

    opened by homersimpsons 5
  • Filter don't work inside of functional tests.

    Filter don't work inside of functional tests.

    I wrote a Bundle. The UI is tested with Panther but it doesn't really matter, because the problem exists also when I use the default symfony KernelBrowser.

    In my TestMethod I took a screenshot with panther and the 2 existing images are not resolved.

    Like I said, also when I don't use panther for that - the path is getting not resolved (path points to the controller route and no cache is created).

    As soon as I visit the test-app via a browser all works just fine - images are getting resolved and cache is getting created. It is testable by going into the tests/app/ of the cloned bundle and start a symfony webserver (symfony serve -d) than browsing to 127.0.0.1:8000/test-two-existing-images.

    It's not that my functional tests are broken (I don't test the LiipImagineBundle - filter). But it would be nice to make this work, so that the images inside the screenshots are not broken anymore.

    Steps to reproduce

    1. Clone the MediaBundle git clone [email protected]:Braunstetter/media-bundle.git
    2. cd media-bundle
    3. Run tests: composer install ./vendor/phpunit/phpunit/phpunit --filter "/(Braunstetter\\MediaBundle\\Tests\\Functional\\Ui\\FormTest::test_max_items_option_hides_add_button)

    Expected result

    The screenshot should not be broken anymore.

    Actual result

    The screenshot is broken.

    opened by MichaelBrauner 5
Releases(2.10.0)
  • 2.10.0(Dec 1, 2022)

  • 2.9.0(Oct 6, 2022)

  • 2.8.0(May 30, 2022)

  • 2.7.6(Jan 14, 2022)

  • 2.7.5(Jan 11, 2022)

  • 2.7.4(Dec 27, 2021)

  • 2.7.3(Dec 3, 2021)

  • 2.7.2(Nov 11, 2021)

  • 2.7.1(Nov 2, 2021)

  • 2.7.0(Oct 28, 2021)

    • By default, redirect with 302 instead of 301 #1404 (dbu)
    • Create Lazy-Loaded Twig Extension #1376 (emmanuelballery)
    • lazy twig extension: handle asset versioning, added imagine_filter_cache, better test coverage #1397 (dbu)
    • asset versions: have & instead of second ? when image url already has a query string #1402 (dbu)
    • fix handling of + in image names, added some functional tests #1391 (dbu)
    • Allow installing doctrine/cache 2.0 #1395 (dbu)
    • [Flysystem Resolver] Allowing "noPredefinedVisibility" for the visibility config parameter #1389 (comxd)
    • Change registering the form theme to prepend the configuration #1387 (mbabker)
    • Fix service definitions for mime and extension guessers #1379 (mbabker)
    • Allow installing doctrine/cache 2.0 #1375 (alcaeus)
    • Messenger support #1360 (mynameisbogdan)
    • Add Twig filter for resolve path to cache #1348 (peter-gribanov)
    • Add WebP client side resolving section in documentation #1380 (peter-gribanov)
    • Generate WebP in liip:imagine:cache:resolve CLI command and async resolve cache messages #1347 (peter-gribanov)
    • Add FormatExtensionResolver #1300 (ossinkine)
    • Documentation improvements #1396, #1399, #1400, #1403, #1401 (dbu)
    • Add doc for disabling auth on filter controllers #1383 (mbabker)
    Source code(tar.gz)
    Source code(zip)
  • 2.6.1(May 22, 2021)

    https://github.com/liip/LiipImagineBundle/compare/2.6.0...2.x

    • php-cs-fixer 3x update #1377
    • $ should not be there #1373
    • Undefined quality key (fixes #1310) #1370
    Source code(tar.gz)
    Source code(zip)
  • 2.6.0(Apr 1, 2021)

    • Don't use cs2pr to report PHP-CS-Fixer suggestions #1355
    • Added support for Flysystem V2 #1349, #1357, #1359
    • Simplified the "strong" role in the documentation #1361
    Source code(tar.gz)
    Source code(zip)
  • 2.5.0(Feb 10, 2021)

    Special thanks to @fbourigault and @peter-gribanov for their efforts to make this release happen!

    • GitHub Actions and test suite improvements #1320, #1327, #1328, #1330, #1335, #1339, #1341, #1342, #1343, #1344, #1345
    • Not resolve WebP in CacheManager #1333
    • Enable WebP support in tests #1329
    • Test resolve WebP from cache #1332
    • Test WebP configuration #1326
    • Create "foo bar.jpeg.webp" #1331
    • Add note for using 302 redirect in HTTP connections for WebP #1334, #1340
    • Support PHP 8 #1325
    • Allow to use Doctrine/Persistence:^2 #1305
    • Depend on doctrine/persistence instead of doctrine/orm #1337
    • Fix missing port in url parsing #1353
    • Suggest symfony/templating instead of requiring deprecated component #1350
    Source code(tar.gz)
    Source code(zip)
  • 2.4.0(Dec 22, 2020)

    • Expose reference type further up (follow up to #1224) #1263
    • Allow PDF files for the thumbnail generation #1297
    • Fix styleci config #1299
    • Update aws_s3.rst with clarifications re service setup #1302
    • Extend WatermarkFilter with multiple option #1281
    • Add WebP image conversion support #1307
    • Replace assertContains with assertStringContainsString #1317
    • Fix skipped functional tests with Symfony 5.x #1316
    Source code(tar.gz)
    Source code(zip)
  • 2.3.1(Jun 26, 2020)

  • 2.3.0(Jan 7, 2020)

    2.3.0 Symfony 5 (2020-01-07)

    Full Changelog

    Merged pull requests:

    Source code(tar.gz)
    Source code(zip)
  • 2.2.0(Oct 4, 2019)

    Full Changelog

    • Allow unresolvable data roots for filesystem locator (robfrawley)
    • Add "fixed-size" filter implementation (peter-gribanov)
    • Only use actual path without any query parameters from the url (TiMESPLiNTER)
    • Add missing ImageType::getBlockPrefix() method (EmmanuelVella)
    • Replace app/console with bin/console (welcoMattic)
    • Fix Symfony 4.2 Deprecation Warnings (hjanuschka)
    • Fix special characters encoding in URL path (dbalabka)
    • Update imagine/imagine dependency to 1.1 (maximgubar)
    • Only use actual path without any query parameters from the url (maximgubar)
    • [Dependency Injection] Add aliases for data and filter manager (fpaterno)
    • Use Autorotate Filter from Imagine library (franmomu)
    • Fix Mime deprecations for Symfony 4 (franmomu)
    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(Jul 10, 2018)

    Changelog

    Full Changelog

    • added bypassing of loaders and resolvers configuration #1110 (maximgubar)
    • php-cs-fixer: skip native constants check #1107 (maximgubar)
    • added ability to inject custom drivers #1105 (maximgubar)
    • [Filters] [Config] [DI] Add Filter configuration class as public service #1098 (maximgubar)
    • [Data Loader] [Docs] Add chain loader implementation and related docs #1096 (robfrawley)
    • Added transparency to background filter #1095 (nielstholenaar)
    • [Docs] Add routing removal in Upgrade file #1092 (tifabien)
    • [Tests] [Deprecation] Updated bundle notation to accommodate Symfony 4.1 and set browser client to not catch exceptions #1090 (robfrawley)
    • moved GitHub-specific documents into .github and split issue template #1089 (maximgubar)
    • fix annotation #1072 (auipga)
    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(May 1, 2018)

    Changelog

    Full Changelog

    • [Post Processors] [Filters] [BC BREAK] Remove configurable post processor interface for one interface and cleanup filter manager #1075 (robfrawley)
    • [Meta] Add code of conduct and update contributor instructions #1071 (robfrawley)
    • [Dependencies] Update imagine/imagine to ^0.7.1,<0.8 #1067 (robfrawley)
    • [Documentation] Correct indentation in AWS-S3 cache resolver documentation #1063 (robfrawley)
    • [CS] Globally update code style using new php-cs-fixer rules #1058 (robfrawley)
    • [CI] [CS] Add a required php-cs-fixer build run to Travis matrix #1057 (robfrawley)
    • [Tests] Add missing PHPUnit @covers annotations #1054 (robfrawley)
    • [CI] Move the "simple-phpunit install" command to Travis install section to collapse the output #1048 (dbu)
    • [CS] [Dependencies] [Dependency Injection] [Form] [General] Update compiler log format, remove legacy code, remove deprecated, fix docblocks/style, general Travis config, upgrade coveralls, and general fixes #1047 (robfrawley)
    • [CS] Changes to support new php-cs-fixer rule set #1046 (robfrawley)
    • [Dependencies] Revert php-cs-fixer development dependency removal #1045 (dbu)
    • [Dependency Injection] Detect proper web root path based on Symfony kernel version #1044 (robfrawley)
    • [Async] [DI] Make resolve_cache_processor a public service #1043 (silverbackdan)
    • [CS] Implement new php-cs-fixer rules and related code cleanup #1040 (sebastianblum)
    • [Dependency Injection] Change cache manager from private service to public to fix deprecation #1038 (fabianoroberto)
    • [CI] Extend and enhance Travis build matrix #1035 (sebastianblum)
    • [Dependencies] Remove unused php-cs-fixer from require-dev #1031 (dbu)
    • [Tests] [CI] [Dependencies] Refactored Travis config to use simple-phpunit and remove phpunit Composer dependency #1029 (sebastianblum)
    • [Documentation] Fix binary name in png-quant.rst #1026 (bruno-ds)
    • [Post-Processors] Replaced ProcessBuilder with Process and add additional tests #1025 (fabianbloching)
    • [Tests] Fix tests on Symfony 3.4 and 4.0 #1023 (lsmith77)
    • [Dependency Injection] Add alias for cache manager #1022 (garak)
    • [Documentation] Align example and description quality values in png-quant.rst #1020 (qkdreyer)
    • [Dependency Injection] Change imagine controller from private service to public service #1019 (michaelperrin)
    • [Dependencies] Enable Symfony 4.0 support #1013 (lsmith77)
    • [Dependencies] Enable Symfony 4.0 support #1010 (llaakkkk)
    • [Tests] [CI] Add PHP 7.2 to Travis test matrix #1009 (dbu)
    • [Documentation] Fix bucket parameter nesting level in aws_s3.rst YAML example #996 (bocharsky-bw)
    • [Data Loader] [Data Locator] [Dependency Injection] Pass root paths to FileSystemLocator during construction #930 (rpkamp)
    • [Dependency Injection] [Filter] Implement filter service abstraction for creating images #922 (rpkamp)

    Upgrade

    • [Post Processor] [BC BREAK] The PostProcessorConfigurablePostProcessorInterface interface has been completely removed and the PostProcessorInterface interface has been updated to allow passing the configuration array to its process method as the second parameter. The PostProcessorInterface::process() now implements the following signature: process(BinaryInterface $binary, array $options = []): BinaryInterface. All custom post processors in your project must be updated to match this new signature.

    • [Dependencies] The imagine/Imagine dependency has been updated from the 0.6.x series to require 0.7.1 or greater. If you project has a hard dependency on any prior version, you will need to update your dependencies.

    • [Form] The legacy setDefaultOptions() and getName() methods on Form/Type/ImageType have been removed, as these methods are no longer required for Symfony. If using them, you will need to update your implementation.

    • [Dependency Injection] The DependencyInjection/Factory/ChildDefinitionTrait trait has been removed, as it handled logic to support legacy Symfony versions no longer targeted.

    • [Dependency Injection] The compiler pass log method signature has changed to log(ContainerBuilder $container, string $message, ...$replacements): void. If you are extending AbstractCompilerPass and using this protected method, you must update your usage.

    • [Dependency Injection] The default values for the liip_imagine.loaders.<name>.filesystem.data_root and liip_imagine.resolvers.<name>.web_path.web_root configuration options are now variable based on the Symfony version. For Symfony 4.0.0 and later, the value is %kernel.project_dir%/public, and for prior releases (such as the Symfony 3.x), the value is %kernel.project_dir%/web. This should automatically provide a suitable default for the different directory structures of the 4.x and 3.x Symfony releases.

    • [Dependency Injection] [Filter] A new filter service abstraction is available as liip_imagine.service.filter with a createFilteredBinary($path, $filter, array $runtimeFilters = []) method to quickly get the filtered binary image and a getUrlOfFilteredImage($path, $filter, $resolver = null) method to quickly resolve and get the filtered image URL.

    • [Data Loader] The FileSystemLoader::__construct() method signature has changed in accordance with the prior deprecation notice; the third parameter must be of signature \Liip\ImagineBundle\Binary\Locator\LocatorInterface $locator and the fourth parameter must be of signature array $dataRoots.

    • [Data Loader] The GridFSLoader data loader has been removed as the required mongo extension has been deprecated and will not be ported to PHP 7.x.

    • [Dependency Injection] A new interface \Liip\ImagineBundle\DependencyInjection/Factory/FactoryInterface has been introduced and is shared between the loaders (LoaderFactoryInterface) and resolvers (ResolverFactoryInterface).

    • [Dependency Injection] All class name parameters have been removed from the service definitions. Instead of overwriting the class name parameters to provide your own implementation, use service decoration.

    • [Data Transformer] The data transformer interface (\Liip\ImagineBundle\Imagine\Data\Transforme\TransformerInterface) was deprecated in version 1.x and has been removed.

    • [Templating] The imagine extension \Liip\ImagineBundle\Templating\ImagineExtension has been renamed to FilterExtension. Similarly, the template helper \Liip\ImagineBundle\Templating\Helper\ImagineHelper has been renamed to FilterHelper.

    • [Utility] The \Liip\ImagineBundle\Utility/Framework/SymfonyFramework::hasDefinitionSharing() method has been removed due to our higher Symfony requirements rending it unnecessary.

    • [General] The use of fully-qualified class name strings is no longer supported and the ::class compile-time class constant is now used.

    • [Enqueue] Enqueue's producer send() method has been deprecated and will be removed, use sendCommand() instead. When interacting with the producer to resolve images in the background you must make the following changes to your code:

      <?php
      
        // 1.0
        $producer->send(\Liip\ImagineBundle\Async\Topics::RESOLVE_CACHE /* ... */);
      
        // 2.0
        $producer->sendCommand(\Liip\ImagineBundle\Async\Commands::RESOLVE_CACHE /* ... */);
      
    Source code(tar.gz)
    Source code(zip)
  • 1.9.1(Sep 9, 2017)

    Changelog

    Full Changelog

    • [Console] [BC BREAK] The resolve command's --as-script/-s option/shortcut renamed to --machine-readable/-m (fixes #988), its output updated to aligned with the resolve command, and the --machine-readable/-m option added. #991 (robfrawley)

    Upgrade

    • [Console] [BC BREAK] The resolve command's --as-script/-s option name/shortcut conflicted with Symfony 2.x core console options (specifically --shell/-s) and has been renamed to --machine-readable/-m (fixes #988). The -s option shortcut was the only conflict, but the --as-script option name proved confusing and unclear so it too was renamed.

    • [Console] The output formatting for the remove command has been updated and aligned with the behavior previously introduced in 1.9.0 for the resolve command, making both of them consistent and in-line with the expected 2.0.0 output. The --machine-readable/-m option name/shortcut has now been added to the remove command as well, enabling predictable, consistent, script parseable output stripped of text styles and supplemental formatting.

    Source code(tar.gz)
    Source code(zip)
  • 1.9.0(Sep 2, 2017)

    Changelog

    Full Changelog

    • [Tests] Fix filesystem loader deprecation message in tests. #982 (robfrawley)
    • [Filter] Add "centerright" and "centerleft" positions to background filter. #974 (cmodijk)
    • [Config] Allow to configure the HTTP response code for redirects. #970 (lstrojny)
    • [Console] Added --force option, renamed --filters to --filter, and pretty resolve command. #967 (robfrawley)
    • [CS] Fix two docblock annotations. #965 (imanalopher)
    • [Data Loader] [Deprecation] The FileSystemLoader no longer accepts an array of data root paths; instead pass a FileSystemLocator, which should instead be passed said paths. #963 (robfrawley, rpkamp)
    • [Composer] Allow avalanche123/Imagine version 0.7.0. #958 (robfrawley)
    • [Data Loader] [Documentation] Add chain loader documentation. #957 (robfrawley)
    • [Data Loader] Add chain loader implementation. #953 (robfrawley)
    • [CS] Fix templating extension method return type. #951 (imanalopher)
    • [Dependency Injection] Fix compiler pass log message typo. #947 (you-ser)
    • [Travis] Default to trusty container image (with precise image for php 5.3). #945 (robfrawley)
    • [Enqueue] Use simplified transport configuration. #942 (makasim)
    • [Filter] Add resolution loader implementation. #941 (robfrawley)
    • [Travis] Remove Symfony 3.3 from allowed failures. #940 (robfrawley)
    • [Utility] Use simplified Symfony kernel version comparison operation. #939 (robfrawley)

    Upgrade

    • [Data Loader] The arguments for the FileSystemLoader class constructor have changed. Passing an array of roots as the third parameter and an (optional) LocatorInterace as the fourth parameter is deprecated. A LocatorInterface should now be passed as third parameter, and the array of roots to the LocatorInterface::__construct() method directly. All prior signatures will continue to work until 2.0 is release.
    • [Console] Added the --force parameter to resolve console command to force image resolution regardless of cache. Added the --as-script parameter to resolve console command to disable verbose, "prettified" output.
    • [Composer] Imagine library upgraded to version 0.7.x.
    Source code(tar.gz)
    Source code(zip)
  • 1.8.0(May 9, 2017)

    Changelog

    Full Changelog

    • [Minor] [Bug] Revert to php-cs-fixer 1.x and run fixer #927 (robfrawley)
    • [Routing] Deprecate XML routing file in favor of YAML #925 (robfrawley)
    • [Filter] Add flip filter implementation to core #920 (robfrawley)
    • [Queue] Resolve image caches in background using message queue. #919 (makasim)

    Upgrade

    • [Routing] The Resources/config/routing.xml file has been deprecated and will be removed in 2.0. Use the new YAML variant moving forward Resources/config/routing.yaml.
    Source code(tar.gz)
    Source code(zip)
  • 1.7.4(Mar 18, 2017)

  • 1.7.3(Mar 2, 2017)

    Changelog

    Full Changelog

    • [Tests] Support PHPUnit 5.x (and remove depredations) #887 (robfrawley)
    • [Tests] Assert expected deprecation using symfony/phpunit-bridge #886 (robfrawley)
    • [Minor] [Docs] Fix typo in general filters documentation #888 (svenluijten)
    • [Loader] Add bundle resources to safe path when requested #883 (bobvandevijver, robfrawley)
    • [Tests] Enable mongo unit tests on PHP7 using "mongo" => "mongodb" extension adapter #882 (robfrawley)
    • [Loader] [Locator] FileSystemLocator service must not be shared #875 (robfrawley)

    Upgrade

    • [Data Loader] The FileSystemLoader now allows you to assign keys to data roots, and directly reference them when requesting resources.

      
        # provide index for data roots
        liip_imagine:
          loaders:
            default:
              filesystem:
                data_root:
                  foo: /path/to/foo
                  bar: /path/to/bar
      
      

      Assume you have a file name file.ext in both data root paths. Given the above configuration, you can specifically request the file from the /path/to/foo root using the following file syntax: @foo:file.ext. Similarly, you can request the same file from /path/to/bar using @bar:file.ext. Note, that the auto-registered bundles (detailed below) are given indexes of their short bundle name (for example, given the bundle FooBundle, you can request a file from its public resources path via @FooBundle:path/to/file.ext).

    • [Data Loader] The FileSystemLoader now supports automatically registering the Resources/public folders within all loaded bundles. This can be enabled via the following configuration.

      
        # enable bundle auto-registration
        liip_imagine:
          loaders:
            default:
              filesystem:
                bundle_resources:
                  enabled: true
      
      

      Additionally, you can whitelist or blacklist specific bundles from the auto-registration routine.

      
        # blacklist "FooBundle" from auto-registration
        liip_imagine:
          loaders:
            default:
              filesystem:
                bundle_resources:
                  enabled: true
                  access_control_type: blacklist
                  access_control_list:
                    - FooBundle
      
        # whitelist "BarBundle" from auto-registration
        liip_imagine:
          loaders:
            default:
              filesystem:
                bundle_resources:
                  enabled: true
                  access_control_type: whitelist
                  access_control_list:
                    - BarBundle
      
      
    • [Data Locator] The *Locator services passed to FileSystemLoader are now marked as "non-shared" or "prototype" within the DI container, resulting in new instances being passed every time the services are requested.

    Source code(tar.gz)
    Source code(zip)
  • 1.7.2(Feb 7, 2017)

    Changelog

    Full Changelog

    • [Loader] Abstract filesystem resource locator and legacy insecure locator implementation #866 (robfrawley)
    • [Minor] [Loader] Fix for FileSystemLoader annotation #868 (tgabi333)
    • [DependencyInjection] Container logging for compiler passes #867 (robfrawley)
    • [CI] Use Prestissimo package for Travis build #864 (robfrawley)
    • [GitHub] Add Hithub templates for issues and PRs #863 (robfrawley)
    • [Symfony] Bug fixes and deprecation cleanup for Symfony 3.3 #860 (robfrawley)
    • [Filter] Upscale filter should use the highest dimension to calculate ratio #856 (Rattler3)

    Upgrade

    • [Data Loader] The FileSystemLoader's resource locator has been abstracted out into FileSystemLocator (provides the same realpath-based locator algorithm introduced in the 1.7.0 release) and FileSystemInsecureLocator (provides the old locator algorithm from version 1.6.x and prior).

      The latter implementation can present security concerns, as it will blindly following symbolic links, including those that point outside your configured data_root directory(ies). It is not recommended unless your deployment process relies heavily on multi-level symbolic links that renders the new locator difficult (and sometime impossible) to setup.

    • [Deprecation] [Data Loader] Instantiating FileSystemLoader without providing a forth constructor argument of signature \Liip\ImagineBundle\Binary\Locator\LocatorInterface $locator is deprecated and the ability to do so will be removed in the next major release, 2.0.

    • [Configuration] The liip_imagine.loaders.default.filesystem.locator bundle configuration option has been introduced and allows the following enum values: filesystem and filesystem_insecure. These correspond to the aforementioned FileSystemLocator and FileSystemInsecureLocator resource locator implementations that affect the behavior of FileSystemLoader. This option defaults to filesystem.

      
        # use the current, default locator algorithm
        liip_imagine:
          loaders:
            default:
              filesystem:
                locator: filesystem
      
        # use the old (pre 0.7.x) locator algorithm
        liip_imagine:
          loaders:
            default:
              filesystem:
                locator: filesystem_insecure
      
      
    • [Dependency Injection] All compiler passes (filters, post-processors, data loaders, cache resolvers, etc) have been updated to log their behavior, allowing you to easily debug tagged services, including both core-provided and custom services defined by your application). In Symfony >= 3.2 this output is located in the var/cache/[dev|prod|env]/app*ProjectContainerCompiler.log file. Output will be similar to the following example on a fresh install.

      
        LoadersCompilerPass: Registered imagine-bimdle binary loader: liip_imagine.binary.loader.default
        FiltersCompilerPass: Registered imagine-bimdle filter loader: liip_imagine.filter.loader.relative_resize
        FiltersCompilerPass: Registered imagine-bimdle filter loader: liip_imagine.filter.loader.resize
        FiltersCompilerPass: Registered imagine-bimdle filter loader: liip_imagine.filter.loader.thumbnail
        FiltersCompilerPass: Registered imagine-bimdle filter loader: liip_imagine.filter.loader.crop
        FiltersCompilerPass: Registered imagine-bimdle filter loader: liip_imagine.filter.loader.grayscale
        FiltersCompilerPass: Registered imagine-bimdle filter loader: liip_imagine.filter.loader.paste
        FiltersCompilerPass: Registered imagine-bimdle filter loader: liip_imagine.filter.loader.watermark
        FiltersCompilerPass: Registered imagine-bimdle filter loader: liip_imagine.filter.loader.background
        FiltersCompilerPass: Registered imagine-bimdle filter loader: liip_imagine.filter.loader.strip
        FiltersCompilerPass: Registered imagine-bimdle filter loader: liip_imagine.filter.loader.scale
        FiltersCompilerPass: Registered imagine-bimdle filter loader: liip_imagine.filter.loader.upscale
        FiltersCompilerPass: Registered imagine-bimdle filter loader: liip_imagine.filter.loader.downscale
        FiltersCompilerPass: Registered imagine-bimdle filter loader: liip_imagine.filter.loader.auto_rotate
        FiltersCompilerPass: Registered imagine-bimdle filter loader: liip_imagine.filter.loader.rotate
        FiltersCompilerPass: Registered imagine-bimdle filter loader: liip_imagine.filter.loader.interlace
        PostProcessorsCompilerPass: Registered imagine-bimdle filter post-processor: liip_imagine.filter.post_processor.jpegoptim
        PostProcessorsCompilerPass: Registered imagine-bimdle filter post-processor: liip_imagine.filter.post_processor.optipng
        PostProcessorsCompilerPass: Registered imagine-bimdle filter post-processor: liip_imagine.filter.post_processor.pngquant
        PostProcessorsCompilerPass: Registered imagine-bimdle filter post-processor: liip_imagine.filter.post_processor.mozjpeg
        ResolversCompilerPass: Registered imagine-bimdle cache resolver: liip_imagine.cache.resolver.default
        ResolversCompilerPass: Registered imagine-bimdle cache resolver: liip_imagine.cache.resolver.no_cache_web_path
      
      
    Source code(tar.gz)
    Source code(zip)
  • 1.7.1(Jan 20, 2017)

    Changelog

    Full Changelog

    Upgrade

    • [Data Loader] The FileSystemLoader data loader performs a more robust security check against image resource paths to ensure they reside within the defined data root path(s). If utilizing symbolic links, you should reference the troubleshooting guide at the end of this upgrade notice.

    • [Data Loader] The FileSystemLoader data loader now accepts an array of paths (as strings) for its third constructor argument, enabling the loader to check multiple paths for the requested image resource. Note that this change creates a BC break for those relying on the protected class property FileSystemLoader::$dataRoot, whose type has changed to string[] and has been renamed to $dataRoots (plural).

    • [Configuration] The liip_imagine.loaders.default.filesystem.data_root configuration option now accepts an array of paths (as strings), or a single string path (to preserve BC). This change allows the filesystem data loader to check multiple data root paths for the requested image resource. The following YML configuration provides examples using both a string and an array for the value.

        # provide an array of scalar paths
        liip_imagine:
          loaders:
            default:
              filesystem:
                data_root:
                  - /multiple/root/paths/foo
                  - /multiple/root/paths/bar
      
        # provide an single scalar path
        liip_imagine:
          loaders:
            default:
              filesystem:
                data_root: /single/root/path
      
    • [Troubleshooting] If you are using the FileSystemLoader data loader in conjunction with symbolic links that point outside the data_root (which defaults to %kernel.root_dir%/../web) then you are required to set all outside resource paths under the data_root option.

      The following is a list of the most common exception error messages encountered when the data_root option is not correctly configured

      • Source image not resolvable "%s" in root path(s) "%s"
      • Source image invalid "%s" as it is outside of the defined root path(s) "%s"

      The full option key for data_root is

        liip_imagine.loaders.default.filesystem.data_root
      
    Source code(tar.gz)
    Source code(zip)
  • 1.7.0(Jan 9, 2017)

    Source code(tar.gz)
    Source code(zip)
  • 1.6.0(Jul 23, 2016)

    Note this release requires a higher minimal version of the imagine library "imagine/Imagine": "^0.6.3,<0.7",

    • Fix tempnam usages #723
    • Quote strings starting '%' in YAML #745
    • Add Flysystem resolver #715
    • background filter: allow image positioning #721
    • Implement Imagine Grayscale filter #638
    • Downscale filter scales an image to fit bounding box #696
    • Ignore invalid exif orientations #751
    • Add configuration options for jpegoptim post-processor
    • Enable configuration of post processors using parameters #720 / #756 / #759
    Source code(tar.gz)
    Source code(zip)
  • 1.5.3(May 6, 2016)

  • 1.5.2(Feb 16, 2016)

Owner
Liip
Liip, needs you to develop websites, apps and e-commerce solutions in a selforganised manner. Are you in? Apply now!
Liip
Wonderfully easy on-demand image manipulation library with an HTTP based API.

Glide Glide is a wonderfully easy on-demand image manipulation library written in PHP. Its straightforward API is exposed via HTTP, similar to cloud i

The League of Extraordinary Packages 2.4k Dec 19, 2022
PHP Thumb is a light-weight image manipulation library aimed at thumbnail generation

PHP Thumb NOTICE - This project was recently updated to 2.0 and is PSR-0 compliant and supports Composer integration. Some parts of the documentation

Ian Selby 985 Dec 4, 2022
PHP Image Manipulation

Intervention Image Intervention Image is a PHP image handling and manipulation library providing an easier and expressive way to create, edit, and com

null 13k Jan 3, 2023
This is an image manipulation REST API written in PHP Laravel Framework

Laravel Image Manipulation REST API Demo Here is fully working Demo: https://www.lobiimages.com/ You have to register first in order to generate acces

TheCodeholic 42 Dec 15, 2022
PHP Exif Library - library for reading and writing Exif headers in JPEG and TIFF files using PHP.

PEL: PHP Exif Library README file for PEL: PHP Exif Library. A library with support for reading and writing Exif headers in JPEG and TIFF images using

null 264 Dec 4, 2022
Goldbach Algorithms Mask is a PHP library developed for Symfony for apply a mask to strings.

Goldbach Algorithms Mask (fondly nicknamed GoldMask) is a PHP library developed for Symfony for apply a mask to strings.

Goldbach Algorithms 1 Oct 30, 2021
A library using PHP to generate QRCode from https://www.qrcode-monkey.com free

PHP Class Generate Free QRCode ?? A library using PHP to generate QRCode from https://www.qrcode-monkey.com free ✋ NOTE: Do not generate too many QRCo

Nguyen Truong Nguyen 53 Dec 28, 2022
ImageWorkshop is a PHP5.3+ library that helps you to manage images based on GD library

================================ ImageWorkshop class ================================ Summary and features Really flexible and easy-to-use PHP class t

Clément Guillemain 853 Dec 27, 2022
Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.

Image Optimizer This library is handy and very easy to use optimizer for image files. It uses optipng, pngquant, jpegoptim, svgo and few more librarie

Piotr Śliwa 879 Dec 30, 2022
Create images with embedded text using advanced typography

Image with Text This class makes it super easy to render images with multiple, independently styled text blocks. You can control each text block's ali

New Media Campaigns 144 Sep 7, 2022
Auto Image & file upload, resize and crop for Laravel eloquent model using Intervention image

Laravel ImageUp The qcod/laravel-imageup is a trait which gives you auto upload, resize and crop for image feature with tons of customization. Install

QCode.in 708 Dec 22, 2022
Generate Avatars using Initials, Bears or Kittens

Avatary Simple avatar generator Explore the docs » View Demo · Report Bug · Request Feature Table of Contents About The Project Built With Getting Sta

Prettify Studio 33 Nov 30, 2022
Alternative image provider for fakerphp using picsum.photos

Fakerphp Picsum Images Introduction Alternative image provider for fakerphp using picsum.photos This package has been forked from mmo/faker-images for

Arnaud Becher 16 Dec 9, 2022
Laravel Optical Character Reader(OCR) package using ocr engines like Tesseract

LaraOCR Laravel Optical Character Reader(OCR) package using ocr engines like Tesseract under the hood. Features Read text from image using WebUI/Progr

Al Imran Ahmed 100 Jan 4, 2023
PHP Captcha library

Captcha Installation With composer : { ... "require": { "gregwar/captcha": "1.*" } } Usage You can create a captcha with the Captc

Grégoire Passault 1.6k Dec 25, 2022
This is a class of php QR Code, This library helps you generate QR codes in a jiffy.

This is a class of php QR Code, This library helps you generate QR codes in a jiffy.

null 59 Oct 5, 2022
PHP library to resize, scale and crop images.

PHP library to resize, scale and crop images.

Gumlet 1.1k Jan 3, 2023
PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options !

PHP Image Editor PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options ! ✨ Supporting ⭐ Star this repos

Franck Alary 17 Nov 13, 2022
PHPExif is a library which gives you easy access to the EXIF meta-data of an image

PHPExif v0.6.4 PHPExif is a library which gives you easy access to the EXIF meta-data of an image. PHPExif serves as a wrapper around some native or C

null 135 Dec 4, 2022