Liipimaginebundle: Symfony 3.4 and Symfony 4 Support

Created on 29 Nov 2017  路  64Comments  路  Source: liip/LiipImagineBundle

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"

Most helpful comment

My composer.json:
"liip/imagine-bundle": "^2.0@dev",
My config that finally works:

liip_imagine:
    resolvers:
        default:
            web_path:
                web_root: "%kernel.project_dir%/public"
                cache_prefix: "images/cache"
    loaders:
        default:
            filesystem:
                data_root: "%kernel.project_dir%/public/"

    driver:               "gd"
    cache:                default
    data_loader:          default
    default_image:        null
    controller:
        filter_action:         liip_imagine.controller:filterAction
        filter_runtime_action: liip_imagine.controller:filterRuntimeAction

    filter_sets: ...

All 64 comments

did you try

    liip_imagine:
        resolvers:
           default:
              web_path:
                web_root: %kernel.root_dir%/../public
                cache_prefix: imagine/cache

but it would make sense to try and make the default adjust automatically based on the Symfony version

Apart from the config issue, the version 1.9 doesn't support SF4, while the version 2 does.

But this last one is not released: which version should have I to use to install the bundle on SF4?

My composer.json:
"liip/imagine-bundle": "^2.0@dev",
My config that finally works:

liip_imagine:
    resolvers:
        default:
            web_path:
                web_root: "%kernel.project_dir%/public"
                cache_prefix: "images/cache"
    loaders:
        default:
            filesystem:
                data_root: "%kernel.project_dir%/public/"

    driver:               "gd"
    cache:                default
    data_loader:          default
    default_image:        null
    controller:
        filter_action:         liip_imagine.controller:filterAction
        filter_runtime_action: liip_imagine.controller:filterRuntimeAction

    filter_sets: ...

Hi Bogdandovgopol !

Thank you for your help, this is very usefull !

By the way, with this configuration, I got an issue ...
"Source image for path "images/logo.png" could not be found"

I store all my image in:

project/assets/images

My html.twig

<img src="{{ asset('/images/logo.png') | imagine_filter('test_small_thumbs') }}" />

My filter:
filter_sets :
        cache : ~
        test_small_thumb:
                    cache: ~
                    quality: 100
                    filters:
                        thumbnail: { size: [100, 100], mode: outbound }

What is wrong exactly ?

Thank you

I suspect you need to adjust data_root: "%kernel.project_dir%/public/"

To fix it:

I store all my image in:

project/public/images

I have SF4 and "liip/imagine-bundle" 2.0.x-dev

I used the config of Bogdandovgopol but it does not seem to do anything :(

I do this in twig:
<img src="{{ asset('images/01.jpg') | imagine_filter('squared_thumbnail') }}" >

And this is the html I get :
<img src="http://myproject.local/media/cache/resolve/squared_thumbnail/images/01.jpg" >

I don't get why there is this part in the url : "media/cache/resolve".

@blackbart420 this is the path to the cache: when you apply a filter the bundle creates a new version of the image with the filters applied.

This URL serves the new filtered image, not the original one.

This means the bundle is working the right way :)

@Aerendir thank you for your answer but how come the bundle is working ?
First of all, the image /media/cache/resolve/squared_thumbnail/images/01.jpg is not created.

According to Bogdandovgopol's configuration, I would expect the images to be generated in directory /public/images/cache and I guess I would get the following html if I the bundle was working:
<img src="http://myproject.local/images/cache/resolve/squared_thumbnail/images/01.jpg" >

But there is no folder /media/cache or /images/cache created and images or not generated.
I don't know what I am missing

If I do this:

php bin/console liip:imagine:cache:resolve 01_07082017.jpg --filters=squared_thumbnail

The image is generated. Then it is displayed on the page properly :
<img src="http://baptresse4.local/images/cache/squared_thumbnail/01_07082017.jpg" title="">

If I do not execute the command, the image are not generated and there is a strange URL:
<img src="http://baptresse4.local/media/cache/resolve/squared_thumbnail/02_07082017.jpg" title="">

What is wrong ?

Well, well, well...
I finally found a way to make it work.
The original images are in folder /public/uploads/images
The generated images go to /public/images/cache

liip_imagine:
    # valid drivers options include "gd" or "gmagick" or "imagick"
    resolvers:
        default:
            web_path:
                web_root: "%kernel.project_dir%/public"
                cache_prefix: images/cache

    loaders:
        default:
            filesystem:
                data_root: "uploads/images/"
                bundle_resources:
                    enabled: true

    driver:               "gd"
    cache:                default
    data_loader:          default
    default_image:        null
    controller:
        filter_action:         liip_imagine.controller:filterAction
        filter_runtime_action: liip_imagine.controller:filterRuntimeAction

    # define your filter sets under this option
    filter_sets:

There was a problem with this line from bogdandovgopol's config :
data_root: "%kernel.project_dir%/public/"

if I wrote the following in twig, it was not working :
<img src="{{ asset("uploads/images/test.jpg") | imagine_filter('squared_thumbnail') }}">

I have to set the path in the config:
data_root: "uploads/images/"
and write this in twig:
<img src="{{ asset("test.jpg") | imagine_filter('squared_thumbnail') }}">

This may be a problem when I will have images from other paths...

@blackbart420 awesome that you got things to work .. maybe you can submit a PR to the documentation with advice for Symfony 4 users?

Hi blackbart420,
I tried the settings that you gave but did not work for me on Symfony 4

with data_root: "uploads/images/" gave me error in the console
data_root: "%kernel.project_dir%/../public/uploads/images/"

When I tried the command
./bin/console liip:imagine:cache:resolve 5a59efb1adb7e250207270.jpg
the image was generated, then it is displayed on the page properly.

Hi @velkony ,
what error did you get ?

@lsmith77 I'm not sure how to do a PR, but as I said, I think there is something wrong with the data_root parameter, it does not work properly. I guess by default it should be as @bogdandovgopol said,
data_root: "%kernel.project_dir%/public/"
but it does not work when images or located in subdirectories of public.

It does not give me an error with data_root: "%kernel.project_dir%/public/"
and web_root: "%kernel.project_dir%/public"
I moved the image to the /public directory, but it does not work also
The command in the console works well.

what is the generated html for the img tag when it does not work ?

<img src="http://test-web/media/cache/resolve/test_small_thumb/5a59efb1adb7e250207270.jpg">
and in the twig template:
<img src="{{ asset("5a59efb1adb7e250207270.jpg") | imagine_filter('test_small_thumb') }}">

ok so it seems to be the same problem I met.

if you access this url in your browser :
http://test-web/media/cache/resolve/test_small_thumb/5a59efb1adb7e250207270.jpg

What does it tell you ?

404 Not Found

can you paste your config file?

liip_imagine:
    # valid drivers options include "gd" or "gmagick" or "imagick"
    resolvers:
        default:
            web_path:
                web_root: "%kernel.project_dir%/public"
                cache_prefix: images/cache

    loaders:
        default:
            filesystem:
                data_root: "%kernel.project_dir%/public/"
                bundle_resources:
                    enabled: true

    driver:               "gd"
    cache:                default
    data_loader:          default
    default_image:        null
    controller:
        filter_action:         liip_imagine.controller:filterAction
        filter_runtime_action: liip_imagine.controller:filterRuntimeAction

    # define your filter sets under this option
    filter_sets:

        cache : ~
        test_small_thumb:
            cache: ~
            quality: 100
            filters:
                thumbnail: { size: [100, 100], mode: outbound }

ok so,
first did you create the folder public/images/cache ? with chmod -R 777 images/

then try to change data_root like this:
data_root: public/

and remove both cache lines from your filter, like so:

    filter_sets:
        test_small_thumb:
            quality: 100
            filters:
                thumbnail: { size: [100, 100], mode: outbound }

then I suggest you create a folder test in public
you put your image 5a59efb1adb7e250207270.jpg in public/test

and try this :
data_root: test/

in twig don't change it, keep this:
<img src="{{ asset("5a59efb1adb7e250207270.jpg") | imagine_filter('test_small_thumb') }}">

nothing

<img src="http://idea-to-web/media/cache/resolve/test_small_thumb/5a59efb1adb7e250207270.jpg"> 
liip_imagine:
    # valid drivers options include "gd" or "gmagick" or "imagick"
    resolvers:
        default:
            web_path:
                web_root: "%kernel.project_dir%/public"
                cache_prefix: images/cache

    loaders:
        default:
            filesystem:
                data_root: test/
                bundle_resources:
                    enabled: true

    driver:               "gd"
    cache:                default
    data_loader:          default
    default_image:        null
    controller:
        filter_action:         liip_imagine.controller:filterAction
        filter_runtime_action: liip_imagine.controller:filterRuntimeAction

    # define your filter sets under this option
    filter_sets:

        test_small_thumb:
            quality: 100
            filters:
                thumbnail: { size: [100, 100], mode: outbound }

ok...
I think it is not going to save the world but try to put quotes:

cache_prefix: "images/cache"
data_root: "test/"

and so if you try again now the command ./bin/console liip:imagine:cache:resolve 5a59efb1adb7e250207270.jpg does it still work ?

Error in the console: Root image path not resolvable "test/" after the command ./bin/console liip:imagine:cache:resolve

I have liip/imagine-bundle - 2.0.x-dev with S4

ok go in the public directory and do:
php ../bin/console liip:imagine:cache:resolve 5a59efb1adb7e250207270.jpg

the image was generated like this.

I have it in /public/cache/test_small_thumb/

That's weird, it should have been generated in /public/images/cache/test_small_thumb/

you're right
I have not looked well
the image is in /public/images/cache/test_small_thumb/

I do have the same version as you.
But I remember I could see an error when I accessed the url like this:
http://idea-to-web/media/cache/resolve/test_small_thumb/5a59efb1adb7e250207270.jpg

You don't have a stack trace ?

maybe you should also do
chmod 777 public/test

I deleted the project and re-installed, now I use another local domain, but it is the same

maybe I have to wait for someone to fix the error

Well I don't know what else you can try sorry...

I can just give you my complete config:

config/routes/imagine.yaml

_liip_imagine:
    resource: "@LiipImagineBundle/Resources/config/routing.yaml"

config/packages/imagine.yaml

liip_imagine:
    resolvers:
        default:
            web_path:
                web_root: "%kernel.project_dir%/public"
                cache_prefix: "images/cache"

    loaders:
        default:
            filesystem:
                data_root: "uploads/images/"
                bundle_resources:
                    enabled: true

    driver:               "gd"
    cache:                default
    data_loader:          default
    default_image:        null
    controller:
        filter_action:         liip_imagine.controller:filterAction
        filter_runtime_action: liip_imagine.controller:filterRuntimeAction

    filter_sets:
        squared_thumbnail:
            jpeg_quality:          85
            png_compression_level: 8
            filters:
                auto_rotate: ~
                strip: ~
                thumbnail:
                    size:          [400, 400]
                    mode:          outbound
                    allow_upscale: true

original images in :
public/uploads/images

generated in :
public/images/cache/squared_thumbnail

so I created the folder public/images/cache and did:
chmod 777 -R public/images
chmod 777 -R public/uploads

Finally in twig I just write:
<img src="{{ asset("test.jpg") | imagine_filter('squared_thumbnail') }}" >
with test.jpg being of course in public/uploads/images

That's all I did.

When I load the page with a new image not yet generated, I get this html:

<img src="http://project.local/media/cache/resolve/squared_thumbnail/test.jpg">
but the image is displayed.
And when I reload the page, the html is :
<img src="http://project.local/images/cache/squared_thumbnail/test.jpg">

I tried everything but it does not work
no image is generated or the second url
Thank you for your time

Is there a possibility that the problem comes from nginx?

I use apache locally and online so maybe.

Have a look here: https://github.com/liip/LiipImagineBundle/issues/249#issuecomment-25608328

Hi @blackbart420 ,
I did a few more tests.
I made a new installation of Symfony v4.0.3 with LiipImagineBundle v2.0.x-dev.
I used apache for web server but unfortunately it still does not work.
I did the same with nginx.

Finally I decided to try Symfony v3.3.15 with LiipImagineBundle v1.9.
It works without any problems.
As a conclusion I can say that the bunde does not work with Symfony 4.

I agree @velkony

I've lost half a day trying to find a configuration that worked for me.

The bundle lacks documentation and support for SF4

in a fresh Symfony 4 app based on the skeleton, I did composer require liip/imagine-bundle:2.0.x-dev.

I then removed the comments in the imagine.yaml and added the following lines

    resolvers:
        default:
            web_path:
                web_root: "%kernel.project_dir%/public"
                cache_prefix: media/cache

    loaders:
        default:
            filesystem:
                data_root: "%kernel.project_dir%/public/uploads/images"
                bundle_resources:
                    enabled: true

I then added these files:

  • /public/uploads/images/test.png
  • /public/media/cache/.gitkeep

Finally I edited templates/default/homepage.html.twig and added image: <img src="{{ asset("test.png") | imagine_filter('squared_thumbnail') }}"> within the body tag.

Finally I ran ./bin/console server:run and loading up http://127.0.0.1:8001/ showed the image and subsequently I could also load http://127.0.0.1:8001/media/cache/squared_thumbnail/test.png things worked flawlessly.

Also if I clear the cache and load http://127.0.0.1:8001/media/cache/resolve/squared_thumbnail/test.png it also redirects properly to http://127.0.0.1:8001/media/cache/squared_thumbnail/test.png and generates the image.

Furthermore clearing the cache and running ./bin/console liip:imagine:cache:resolve test.png outputs http://localhost/media/cache/squared_thumbnail/test.png and the file is created as expected.

Hi, @lsmith77 ,
unfortunately, the bundle does not work for me with these settings.
I do not use the integrated web server in Symfony.
I tested with Nginx.
When I run the command ./bin/console liip:imagine:cache:resolve test.png in the console, an image is generated.
it means I don't have any error in the settings.
How can I debug the code to reveal where the problem is?

I tried with the integrated server in Symfony and it works.
This means I have to set nginx.
Could anybody send me the correct settings please?

See https://github.com/liip/LiipImagineBundle/issues/784#issuecomment-320150743, and read that entire thread if you need additional guidance: there was a bunch of discussion about Nginx configuration.

After many attempts I reached a working version of Nginx conf on S4.
This configuration it should not be like this. Can someone give me advice?

server {
    listen 80;
    server_name  vps456703.ovh.net;

    root /var/www/html/vps456703/public;

    charset utf-8;

    location ~ ^/index\.php(.*?)\.(?:ico|gif|jpeg|jpg|png|css|js)$ {

        expires 18h;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        access_log off;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        internal;
        add_header 'Access-Control-Allow-Origin' '*';
    }

   location / {
        try_files $uri /index.php$is_args$args;
    }


    location ~ ^/index\.php(/|$) {
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        internal;
        add_header 'Access-Control-Allow-Origin' '*';
    }

    location ~ \.php$ {
        return 404;
    }

    access_log  /var/log/nginx/vps456703.access.log;
    error_log  /var/log/nginx/vps456703.error.log warn;

}

I can install liip with composer require :

Problem 1
- liip/imagine-bundle 1.9.1 requires symfony/asset ~2.3|~3.0 -> satisfiable by symfony/asset[2.7.x-dev, 2.8.x-dev, 3.0.x-dev, 3.1.x-dev, 3.2.x-dev, 3.3.x-dev, 3.4.x-dev, v2.7.0, v2.7.0-BETA1, v2.7.0-BETA2, v2.7.1, v2.7.10, v2.7.11, v2.7.12, v2.7.13, v2.7.14, v2.7.15, v2.7.16, v2.7.17, v2.7.18, v2.7.19, v2.7.2, v2.7.20, v2.7.21, v2.7.22, v2.7.23, v2.7.24, v2.7.25, v2.7.26, v2.7.27, v2.7.28, v2.7.29, v2.7.3, v2.7.30, v2.7.31, v2.7.32, v2.7.33, v2.7.34, v2.7.35, v2.7.36, v2.7.37, v2.7.38, v2.7.39, v2.7.4, v2.7.40, v2.7.41, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.0-BETA1, v2.8.1, v2.8.10, v2.8.11, v2.8.12, v2.8.13, v2.8.14, v2.8.15, v2.8.16, v2.8.17, v2.8.18, v2.8.19, v2.8.2, v2.8.20, v2.8.21, v2.8.22, v2.8.23, v2.8.24, v2.8.25, v2.8.26, v2.8.27, v2.8.28, v2.8.29, v2.8.3, v2.8.30, v2.8.31, v2.8.32, v2.8.33, v2.8.34, v2.8.4, v2.8.5, v2.8.6, v2.8.7, v2.8.8, v2.8.9, v3.0.0, v3.0.0-BETA1, v3.0.1, v3.0.2, v3.0.3, v3.0.4, v3.0.5, v3.0.6, v3.0.7, v3.0.8, v3.0.9, v3.1.0, v3.1.0-BETA1, v3.1.0-RC1, v3.1.1, v3.1.10, v3.1.2, v3.1.3, v3.1.4, v3.1.5, v3.1.6, v3.1.7, v3.1.8, v3.1.9, v3.2.0, v3.2.0-BETA1, v3.2.0-RC1, v3.2.0-RC2, v3.2.1, v3.2.10, v3.2.11, v3.2.12, v3.2.13, v3.2.14, v3.2.2, v3.2.3, v3.2.4, v3.2.5, v3.2.6, v3.2.7, v3.2.8, v3.2.9, v3.3.0, v3.3.0-BETA1, v3.3.0-RC1, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.15, v3.3.16, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.0-BETA1, v3.4.0-BETA2, v3.4.0-BETA3, v3.4.0-BETA4, v3.4.0-RC1, v3.4.0-RC2, v3.4.1, v3.4.2, v3.4.3, v3.4.4] but these conflict with your requirements or minimum-stability.
- liip/imagine-bundle 1.9.0 requires symfony/asset ~2.3|~3.0 -> satisfiable by symfony/asset[2.7.x-dev, 2.8.x-dev, 3.0.x-dev, 3.1.x-dev, 3.2.x-dev, 3.3.x-dev, 3.4.x-dev, v2.7.0, v2.7.0-BETA1, v2.7.0-BETA2, v2.7.1, v2.7.10, v2.7.11, v2.7.12, v2.7.13, v2.7.14, v2.7.15, v2.7.16, v2.7.17, v2.7.18, v2.7.19, v2.7.2, v2.7.20, v2.7.21, v2.7.22, v2.7.23, v2.7.24, v2.7.25, v2.7.26, v2.7.27, v2.7.28, v2.7.29, v2.7.3, v2.7.30, v2.7.31, v2.7.32, v2.7.33, v2.7.34, v2.7.35, v2.7.36, v2.7.37, v2.7.38, v2.7.39, v2.7.4, v2.7.40, v2.7.41, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.0-BETA1, v2.8.1, v2.8.10, v2.8.11, v2.8.12, v2.8.13, v2.8.14, v2.8.15, v2.8.16, v2.8.17, v2.8.18, v2.8.19, v2.8.2, v2.8.20, v2.8.21, v2.8.22, v2.8.23, v2.8.24, v2.8.25, v2.8.26, v2.8.27, v2.8.28, v2.8.29, v2.8.3, v2.8.30, v2.8.31, v2.8.32, v2.8.33, v2.8.34, v2.8.4, v2.8.5, v2.8.6, v2.8.7, v2.8.8, v2.8.9, v3.0.0, v3.0.0-BETA1, v3.0.1, v3.0.2, v3.0.3, v3.0.4, v3.0.5, v3.0.6, v3.0.7, v3.0.8, v3.0.9, v3.1.0, v3.1.0-BETA1, v3.1.0-RC1, v3.1.1, v3.1.10, v3.1.2, v3.1.3, v3.1.4, v3.1.5, v3.1.6, v3.1.7, v3.1.8, v3.1.9, v3.2.0, v3.2.0-BETA1, v3.2.0-RC1, v3.2.0-RC2, v3.2.1, v3.2.10, v3.2.11, v3.2.12, v3.2.13, v3.2.14, v3.2.2, v3.2.3, v3.2.4, v3.2.5, v3.2.6, v3.2.7, v3.2.8, v3.2.9, v3.3.0, v3.3.0-BETA1, v3.3.0-RC1, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.15, v3.3.16, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.0-BETA1, v3.4.0-BETA2, v3.4.0-BETA3, v3.4.0-BETA4, v3.4.0-RC1, v3.4.0-RC2, v3.4.1, v3.4.2, v3.4.3, v3.4.4] but these conflict with your requirements or minimum-stability.
- Installation request for liip/imagine-bundle ^1.9 -> satisfiable by liip/imagine-bundle[1.9.0, 1.9.1].

I have already instale asset et imagine bundle for symfony4 (4.0.3)

The 1.9.x releases aren't compatible with Symfony 4.x. You need to use the 2.x branch of this bundle.

Thx work well :)

Hello,

I made all , that mr. @lsmith77 , suggested, and when I run the command ./bin/console liip:imagine:cache:resolve test.png in the console, an image is generated.

But then i run project on local server at Windows from phpstorm, there is no images generated and 404 err.
It is a Windows bug? Should I try to run it in docker with nginx server?

I don鈥檛 know if something has become mpre problematic with 4.x, but yes web server configuration can of course break this Bundle. Can you try with running the php internal webserver and see if the issue persists?

@e-d0 You can review a working Nginx web server configuration in https://github.com/liip/LiipImagineBundle/issues/1050#issuecomment-364643506. That is for Symfony 3.x, so you will need to change how Symfony's front controller is called, but otherwise you can get a good idea of a proper configuration there.

So, i wasted a lot of time to configure docker image to work with Imagick driver , but finally have done it.
I still can generate image through CLI , but from controller i have got an error:

then i move to route 'http://192.168.99.100/media/cache/resolve/squared_thumbnail/uploads/images/72987e3f64c7c7fe36e74a1db0d82d7a.jpg'

got an error:

Source image for path "uploads/images/72987e3f64c7c7fe36e74a1db0d82d7a.jpg" could not be found

Here is stacktrace:

Symfony\Component\HttpKernel\Exception\NotFoundHttpException:
Source image for path "uploads/images/72987e3f64c7c7fe36e74a1db0d82d7a.jpg" could not be found

  at vendor/liip/imagine-bundle/Controller/ImagineController.php:82
  at Liip\ImagineBundle\Controller\ImagineController->filterAction(object(Request), 'uploads/images/72987e3f64c7c7fe36e74a1db0d82d7a.jpg', 'squared_thumbnail')
     (vendor/symfony/http-kernel/HttpKernel.php:149)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:66)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:190)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (public/index.php:34)

the Imagine Yaml configured , like at mr. @lsmith77 example. How to make it work?

@e-d0 Please provide the full configuration file you are using for this bundle, as well as the version of this bundle and the version of Symfony.

@robfrawley

Symfony 4.0.3
bundle: "liip/imagine-bundle": "2.0.x-dev"
"vich/uploader-bundle": "^1.8",

imagine. yaml

liip_imagine:
    # valid drivers options include "gd" or "gmagick" or "imagick"
    driver: "imagick"

    # define your filter sets under this option
    filter_sets:

        # an example thumbnail transformation definition
        # https://symfony.com/doc/current/bundles/LiipImagineBundle/basic-usage.html#create-thumbnails
        squared_thumbnail:

            # set your image quality defaults
            jpeg_quality:          85
            png_compression_level: 8

            # setup the filter steps to apply for this transformation
            filters:

                # auto rotate the image using EXIF metadata
                auto_rotate: ~

                # strip the image of all metadata
                strip: ~

                # scale and square the image to the given dimensions
                thumbnail:
                    size:          [253, 253]
                    mode:          outbound
                    allow_upscale: true

                # create border by placing image on larger black background
                background:
                    size:     [256, 256]
                    position: center
                    color:    '#fff'

    resolvers:
        default:
            web_path:
                web_root: "%kernel.project_dir%/public"
                cache_prefix: media/cache/resolve

    loaders:
        default:
            filesystem:
                data_root: "%kernel.project_dir%/public/uploads/images"
                bundle_resources:
                    enabled: true

@e-d0 The value of loaders.default.filesystem.data_root in your configuration file is

%kernel.project_dir%/public/uploads/images

and you are requesting the image as

uploads/images/72987e3f64c7c7fe36e74a1db0d82d7a.jpg

This causes the loader to ask for the following path:

%kernel.project_dir%/public/uploads/images/uploads/images/72987e3f64c7c7fe36e74a1db0d82d7a.jpg

Obviously, that is not correct, you don't want to duplicate uploads/images/uploads/images/. Either do one or the other of the following:

  • Change the loaders.default.filesystem.data_root configuration option value to %kernel.project_dir%/public/, and continue requesting the image using uploads/images/72987e3f64c7c7fe36e74a1db0d82d7a.jpg, or
  • Keep the loaders.default.filesystem.data_root configuration option value as-is, and request the image using only 72987e3f64c7c7fe36e74a1db0d82d7a.jpg.

@robfrawley , Nice! Thank you! Now It is work perfectly !

Any idea when a stable release is expected?

Just in case this may help someone. the above mentioned behavior occurs when I used the php server locally. As soon as I use symfony's server locally, or in live, everything works like charm. so this means it is a server configuration issue.

thanks @idrissou
RE next release, lets coordinate in #1186 if there is anything to coordinate. i hope to tag 2.2.0 end of august.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

weyandch picture weyandch  路  5Comments

TELLO0815 picture TELLO0815  路  4Comments

markwatney2016 picture markwatney2016  路  4Comments

robfrawley picture robfrawley  路  4Comments

tobias-r picture tobias-r  路  4Comments