-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to configure LiipImagineBundle to use a dynamic image stored in S3 as watermark? #628
Comments
It looks like you need a dynamic filter, If so there is such a feature in the bundle, It was added in this PR #313 There is not a dedicated chapter in the documentation. Is it what you are looking for? |
Hello Makasim, Thanks for your answer. I saw in another site someone using this runconfig on Twig. I tried to use it but it doesn't work. I did something like this:
Is it available on the version of Liip I'm using? It's the 1.3. For the image, I'm using the complete S3 URL. Is it right? And what should I inform in the config.yml? I tried with the image null:
|
The way I used to do dynamic filters in the past was similar to this post. I was extending the ImagineController and adding the value for the filters inside like this developper did. We don't do it anymore? http://iswwwup.com/t/08955e0401a8/image-dynamic-filter-with-liipimaginebundle.html |
Yes it available since 1.0.
What exactly does not work |
Actually, I dump the runtimeConfig and the values are ok but the watermark is not applied. I wonder if it is because I'm using images from S3. The original image and the image used as watermark are on S3. |
It does not matter what loaders\resolvers you are using, it must work |
Ok, I'll keep trying. Thanks. |
Makasim, just another question. Sorry for disturbing. I think I didn't understand how to fill the runtimeConfig. In the config.yml, I have:
The loader stream.shooting is well defined on my service.yml and works for other filters without watermark. This is the service:
Then in the Twig, I have:
But it seems that something is missing. How could Liip know that the "image" path and the "position" must be used for the watermark? |
try this one {% set watermark = "http://" ~ amazon_s3_media_url ~ "/establishment/" ~ establishment.watermarkPath %}
{% set runtimeConfig = {"watermark": {"image": watermark, "position": "bottom" }} %}
{% set url_photo_medium = photo.imagepath | imagine_filter("photo_high", runtimeConfig) %}
You can put a debuger break point to this line to https://github.com/liip/LiipImagineBundle/blob/master/Controller/ImagineController.php#L157 to see what is going on under the hood. |
I tried but there's no way to make it work. It seems that, since I upgraded to the version 1.3 of Liip with a custom loader, the watermark filter doesn't work anymore. I stopped trying to make it work with a dynamic filter and I'm trying only to add a watermark from the config file. It doesn't work neither. For example:
An then:
I tried many paths for the image with images that I know that exist in S3 or in my server. I can't understand what I'm doing wrong. |
It seems work only for local files, https://github.com/liip/LiipImagineBundle/blob/master/Imagine/Filter/Loader/WatermarkFilterLoader.php#L32 I think it is not right |
Yes, I saw that. So I tried to use local images as watermark but it still doesn't work. Maybe the image that will receive the watermark can't be on S3 neither. But this would be strange as the other filters work with S3 images. |
Should I create another issue or edit the subject of this issue to see if someone knows why the watermark is not working? I just created an empty controller and I'm making some more tests directly on the controller.
If I do a var_dump of the config of the filter, the image is null for the watermark: array(11) { ["data_loader"]=> string(15) "stream.shooting" ["quality"]=> int(70) ["filters"]=> array(1) { ["watermark"]=> array(3) { ["image"]=> NULL ["size"]=> float(0.5) ["position"]=> string(6) "bottom" } } ["jpeg_quality"]=> NULL ["png_compression_level"]=> NULL ["png_compression_filter"]=> NULL ["format"]=> NULL ["animated"]=> bool(false) ["cache"]=> NULL ["default_image"]=> NULL ["post_processors"]=> array(0) { } }
If I do a var_dump of the new config of the filter, the image is there: array(11) { ["data_loader"]=> string(15) "stream.shooting" ["quality"]=> int(70) ["filters"]=> array(1) { ["watermark"]=> array(3) { ["image"]=> string(99) "https://www.google.com/logos/doodles/2015/olga-cossettinis-117th-birthday-5667193748455424-hp2x.jpg" ["size"]=> float(0.5) ["position"]=> string(6) "bottom" } } ["jpeg_quality"]=> NULL ["png_compression_level"]=> NULL ["png_compression_filter"]=> NULL ["format"]=> NULL ["animated"]=> bool(false) ["cache"]=> NULL ["default_image"]=> NULL ["post_processors"]=> array(0) { } }
But the image is stored without the watermark. I really don't know what is happening. |
@anacicconi the url It works only with local files right now, Look at this line: https://github.com/liip/LiipImagineBundle/blob/master/Imagine/Filter/Loader/WatermarkFilterLoader.php#L32 The filter has to be patched to accept urls as water mark images. |
The image must be something like "images/features1.jpg" which is added to rootPath (the root to your app folder, if I remember it correctly) |
Humm... I Also tried it but my images were on the web folder. So I was doing ../web/images/features1.jpg. I will try to move one to the app folder and see if it works. Thanks. |
@makasim, after some time trying, I was able to use the runtimeconfig on Twig. It was a problem of configuration too. However, now I have to the same problem on a controller and I'm not able to make it work. I followed the code you suggested on #313 and I keep getting "Signed url does not pass the sign check for path". The hash seems to be ok. Did I miss something?
|
looks good, maybe a bug |
No, it's not a bug @makasim. Actually, it's not possible to do what I was trying to do (file_get_contents) on the browserPath. I need the filter to be applied before the display so I can get the content. The only solution I found is to do:
Otherwise, for the display, the runtimeConfig works great. |
Hello,
I'm using LiipImagineBundle, KnpGaufretteBundle and AWS SDK for PHP in a project. Everything works fine. However, I want to add a watermark filter and I can't manage to make it work. The path for the image used as watermark must be dynamic and it is stored on S3.
What is the best way to do it?
In the past, with an older version of Liip, I was informing a null path for the image in the configuration and extending the ImagineController to set a new configuration to the filter. Ex:
I was on version v.0.21.1. Now, I updated to the version 1.3.
The text was updated successfully, but these errors were encountered: