liip / liipimaginebundle Goto Github PK
View Code? Open in Web Editor NEWSymfony Bundle to assist in imagine manipulation using the imagine library
Home Page: http://liip.ch
License: MIT License
Symfony Bundle to assist in imagine manipulation using the imagine library
Home Page: http://liip.ch
License: MIT License
Can you have multiple filter?
filters:
#thumbnail: { size: [1142, 650], mode: inbound }
relative_resize: { heighten: 650 }
relative_resize: { widen: 1142 }
I try to scale a picture to fit in a height and width but without crop (one side can be shorter but not longer).
In the docs we have:
formats - optional list of image formats to which images may be converted to.
Right now if this configuration option is not defined, no images will be generated. Instead we will get the following error:
Source image not found in "/images/file-name.jpg"
This is because of https://github.com/liip/LiipImagineBundle/blob/master/Imagine/DataLoader/FileSystemLoader.php#L36-38
Defining liip_imagine.formats
fixes the issue. Is this option required? What's the point of specifying this? If it's a filter to pass only images of specified format to imagine, shouldn't we check this in apply_filter
, instead of generating errors? And support allow-all instead of deny-all setting by default?
Using the same name than AvalancheImagineBundle means that both bundles are exclusive.
Currently when outputting a profile that has no specified format, the bundle uses the file's extension, however it does not check if that extension ins actually a valid format, which causes breaks in the backend and broken images.
The bundle should validate the extension against known and compatible image output formats, and fall back to a specific format if it finda nothing valid. (FilterManager)
it should be possible for a dataloader to read the filter rules out along with the image and dynamically register it with the filter manager
aka one would register a filter set without including all the options. a custom data loader would then need. to have some way to find the config for the given image and dynamically set the filter config.
this means that the filter and data managers would need to have some sort of dependency.
I'm trying to create service that runs all filters on specific images, so the cache is created before a deploy get symlinked to production.
All I want to do is this:
$request = new Request();
$this->imagineController->filterAction($request, $path, $filter);
This works but when I call this on an image that has already cache stored it wants to create a redirect etc.. and it I get the following error :
ErrorException: Warning: strpos(): Empty delimiter in .. vendor/liip/imagine-bundle/Liip/ImagineBundle/Imagine/Cache/Resolver/WebPathResolver.php line 41
Is there a better way to create all cache images from console ?
Hello,
First thank you for this great Bundle.
after installig the bundle i' confronted to a problem that every time i have the exception Route "_imagine_filter" does not exist.
I've debuged and i've seen that in "Liip\ImagineBundle\Imagine\Cache\CacheManager" in the return value of the function "generateUrl" you call genarate router with :
$this->router->generate('_imagine_'.$filter, $params, $absolute)
so the router will search the route imagine_filter (in my case) and he don't find it.
Thank you
Hi I was wondering if it was possible to access the functions of this bundle from other parts of the application instead of just twig templates?
I don't know if it's already possible or not, but if it is could someone write up a quick tutorial?
I have actually been able to create my own service that brings in the cachemanager and uses the same filter function as the twig helper but for some reason it never actually saves the image I input into the cache. I can see it returns a file path and it works normally in a twig template but it doesn't work inside the controller.
Main reason I need this is that I'm uploading files using SWF and I need to generate a file path and also a thumbnail path so I figured I'd hit two birds with one stone and use the same generation profile for returning the thumbnail url via JSON and also on the template.
Any thoughts?
I've the following requirement in our app for image resizing and cropping:
So for example, when the maximum dimension is a rectangle with 250x250 (height/width) and the input image is
300x600, resize it to 250x498, and make it optional where to crop the resized image:
Is this possible with the current available filters?
If not, i'd be happy to send you a PR with this feature.
When a path is matched by ImagineBundle, but the source image does not exist, instead of a 404, an exception is thrown, resulting in a HTTP 500 response. Basically any url that matches the configured imagine prefix does this, which would seem is a bad thing (especially if you like clean error logs).
Should I write a patch for this, or is this intended behaviour?
It would be greate if there is a service methode like deleteImage(OriginalPath);
Which deletes this image from all caches if it exists. Or deleteImage(OriginalPath, 'thumbName');
For deleting a image in a special thumb config. And a Console command for clearing the image cache would be also good (So there is no need to delete the complete cache just the image cache).
aka some filters will want to cache in the web root, others not
I'm still trying to figure out the details on this one. But here is the scenario:
So i looked into this.
/url/to/image.png
which is a real file and a real and valid urlcache/path/to/image.jpg
(this would be the image that should be generated)png
so it never manages to generate a cache fileIf i forcefully switch the url to png
it runs, caches and no longer has any problems.
It seems to me like this force switch of extensions is making the bundle lose the reference to the original and what cache file it should generate. Any ideas on this?
Hi,
I can't manage to keep my pictures outside the web root. As explained in the doc, I overrided the DataLoader service and defined a custom path: %kernel.root_dir%/data/uploads
I changed the config file accordingly, is this correct?
liip_imagine:
driver: gd
web_root: %kernel.root_dir%/data/uploads
data_root: %kernel.root_dir%/data/uploads
cache_prefix: /media/cache
cache: web_path
data_loader: filesystem
controller_action: liip_imagine.controller:filterAction
formats: []
Many thanks for this amazing bundle.
is it posible to get filter from comand line. for example i have command that post images to facebook and i want to appy filters, but i dond know how.
Images should be served via separate host for better front-end performance.
Currently, all services are named imagine.*
, which uses the same name than AvalancheImagineBundle. The first segment should be liip_imagine
according to the best practice and would avoid name clashes between the two bundles (which could lead to unexpected behavior when using them together)
for 2.1 we should use the cache clear hook
Currently in configuration we can specify only one filter in filter set. E.g.:
liip_imagine:
filters:
my_thumb:
type: thumbnail
options: { size: [120, 90], mode: outbound }
We should allow specifiying several filters in one filter set (e.g. resize the image and add watermark). For example:
liip_imagine:
filters:
my_thumb:
thumbnail:
options: { size: [120, 90], mode: outbound }
other_filter: ~
other_filter2: ~
What do you think?
I just noticed that the Bundle now auto-hooks a cache clear on the standard Symfony Cache Clear command.
This is actually not something we want in our code, as images don't really need to be flushed and the overhead of "all" images being re-cached after every deploy is not desirable.
Is it possible to make this a configuration setting? like auto_cache_flush
or something we can set to false and handle the image cache separately from the rest of the application cache?
Using the default configuration example in the documentation, my pictures were not cached on my server.
Removing "cache:true" parameter fixed the issue.
This default value for this parameter should be "cache: my_web_path"
Don't know is it a bundle issue or Imagine lib, recently I've added filter to page witch already had lots of images.
My whole VM with 512MB ram was killed by out of memory, should bundle / lib free resources after each thumbnail generation process ?
To keep URLs short, I need to publicly expose images with only the body part of image filenames (i.e. no file extension in the name). When passing such images to the filter, it complains:
Saving image in "" format is not supported, please use one of the following extension: "gif", "jpeg", "png", "wbmp", "xbm"
It would be great if you could refactor the filter to offer a default output format (e.g. jpg) if none can be obtained from the original image path.
I'm getting this error trying to get image thumb routes using LippImagineBundle. I'm using the base controller as service.
The problem is that it's inside a loop so this code could be executed 1000 times:
$imagemanagerResponse = $this->container->get('liip_imagine.controller')->filterAction($this->getRequest(),$ProjectsArray2[$i]['projectimage'],'thumb_80x80' );
$ProjectsArray2[$i]['projectimage'] = $imagemanagerResponse->headers->get('location');
Is there any option to avoid crash?
Failing test is LiipImagineExtensionTest#testLoadWithDefaults
Take the following scenario :
app/data/foo.png
.app/data/foo.png
.Cached image should be generated based on the hash of the file + filter name for example.
Don't know if it's really an issue or if I should implement my own cache resolver extending WebPathResolver
?
As a quick fix I tried removing cached image after I change content, but I didn't get it : is ResolverInterface::remove()
only callable from within ResolverInterface::resolve()
(because of $targetPath
) ? Isn't there other way to remove cached images one by one using the source path and the filter name ?
For better front end performance on first request, response should be sent with Last-Modified header.
When implementing please add a check for 304 responses (Response#isNotModified
).
the loader to use would ideally be configured optionally as part of the filter set configuration
I'm getting this exception when adding the LiipImagineBundle to my app. I'm on Symfony master, so my first guess would be the bundle is not compatible with master
.
Can you confirm this, or should it also work with the latest Symfony version?
Hi,
I've got a setup where I cannot rely on user uploaded images being on disk, users upload images and I'm storing the file data and mimetype in the database, resizing them and then passing them along to s3.
Have you considered a similar approach?
Cheers
quality
parameter shouldn't be placed in options array.
According to docs and validation rules for configuration this param should be placed on the same level as options
and type
parameters.
I recently updated LiipImagineBundle and this line causes a failure, I have to comment it out to get my site to run:
if ('2' == Kernel::MAJOR_VERSION && '0' == Kernel::MINOR_VERSION) {
this throws the following error:
PHP Fatal error: Undefined class constant 'MAJOR_VERSION' in (my webroot)\vendor\bundles\Liip\ImagineBundle\Depend
encyInjection\LiipImagineExtension.php on line 48
Also, by my read of this code: does this mean that 2.0 users won't get the benefit of the cache clearer? That's really too bad :(
There don't seem to be instructions for installing this bundle using composer so I added
"liip/imagine-bundle": "*",
to my composer.json and updated. Everything went fine until I tried to register the bundle in appKernel.php with the line
new Liip\ImagineBundle\LiipImagineBundle(),
Php gives the error
Fatal error: Class 'Liip\ImagineBundle\LiipImagineBundle' not found in C:\xampp\htdocs\xxxx\Symfony\app\AppKernel.php on line 24
As far as I can see LiipImagineBundle is in the right place in the vendors folder. Anyone have any idea whats wrong? Thanks in advance.
In the configuration file, the following will work:
liip_imagine:
cache: my_custom_cache
But this does not work:
liip_imagine:
filter_sets:
my_special_style:
cache: my_custom_cache
filters:
my_custom_filter: { }
It will cause the following exception:
InvalidConfigurationException: Unrecognized options "cache" under "liip_imagine.filter_sets.liip_rasterize"
Cache cannot be generated for files with cyrillic filename
I am trying to use LiipImagineBundle as a service within a Controller as described here with a local file that has no file extension. This leads to an invalid array access in this line of code as pathinfo()
doesn't return an extension
array index if no extension is present.
Сhange extension of file with modified format, and not just mime-type.
Example:
source file: /uploads/example.jpg
format: png
destination file: /cache/uploads/example.png
I'm trying to load images through Javascript using the routes provided by the bundle. I have
_imagine:
resource: .
type: imagine
In app/routing.yml and I am trying to access the /media/cache/filter_name/{path} route. If I try to access the route through production I get a ResourceNotFoundException. If I access the route through app_dev.php then the image is returned. Once I've accessed the route through the dev environment, it will then work for production for any image passed through {path}, not just the original image. Is there a configuration setting or something that I'm missing?
aka to be able to do foo/{bar}/dong/{path}
@sixty-nine made some changes recently to the cache clearer. are they dependent on Symfony 2.1? I'm on 2.0.12 and am getting the following error.
Fatal error: Interface 'Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface' not found in /xxx/vendor/bundles/Liip/ImagineBundle/Imagine/Cache/CacheClearer.php on line 13
My deps are the following:
[Imagine]
git=http://github.com/avalanche123/Imagine.git
target=imagine
version=v0.2.0
[LiipImagineBundle]
git=http://github.com/liip/LiipImagineBundle.git
target=bundles/Liip/ImagineBundle
Thanks
What about including in the bundle loaders for all image filters (flip, crop, rotate, etc..) ? for common use case (like watermarking) ?
See avalanche123/AvalancheImagineBundle#20
I will try to contribute the code for this later.
The current caching implementation of LiipImagineBundle relies on the web server to possess writable disc space to "cache" processed images. I found some of the issues with this approach to be that there is no cache expiry available in case a filter is modified and that the web server might run out of disc space if many images are filtered.
As remedy, I've hacked up an implementation of 'last-modified' and 'etag' cache headers to be served by LiipImagineBundle. This allows for external caching techniques instead of relying on server-side storage. Feel free to merge this patch if of interest.
https://github.com/advancingu/LiipImagineBundle/commit/bd0f8cecead5da7815f04700410a6daecf3f20a5
Hello i am getting errors because this fix exists in version 3 of imagine bundle.
https://github.com/avalanche123/Imagine/blob/develop/lib/Imagine/Imagick/Image.php
This has the fix. The problem is that Liipimagine bundle doesnt work with version 3.0 for a reason...
Any fix for this ?
Source images does not have to be accessible from web root. There are some use cases when it is not desirable.
E.g. we could have HQ photos and only show medium-sized, watermarked photos.
This will allow us to load from anything (and not just file or stream).
This will also allow reusing of the loader elsewhere (I need it for my WatermarkFilterLoader for exemple)
Is it a correct behaviour to send a redirection in the filterAction ? Images are not shown as the request send a redirect. The problem only happened in dev environment:
In DEV (my image url is redirected):
/app_dev.php/uploads/my_filter/filename.jpg
is not showed as the request is redirectedIn PROD (no problem):
/uploads/my_filter/filename.jpg
(notice the front controller is missing) works.So is it a real bug or does i misuse someting ?
Does this PR has anything related to my problem ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.