-
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
[Filter] Add resolution filter loader #941
[Filter] Add resolution filter loader #941
Conversation
481fb8a
to
1d71c29
Compare
The Travis issue mentioned above has been closed and fixed in composer/composer#6342 by @Seldaek. |
c697f12
to
cfa79f2
Compare
)); | ||
|
||
$resolver->setNormalizer('filter', function (Options $options, $value) { | ||
foreach (array('\Imagine\Image\ImageInterface::FILTER_%s', '\Imagine\Image\ImageInterface::%s', '\%s', '%s') as $format) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need leading backslashes here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added them as a very "micro-optimization" as it does remove some opcodes (otherwise it first searches in the defined namespace, followed by the global namespace (right?), the latter of which we want to force for the first two formats, but now that you bring this up, we could likely change:
array('\Imagine\Image\ImageInterface::FILTER_%s', '\Imagine\Image\ImageInterface::%s', '\%s', '%s')
to
array('\Imagine\Image\ImageInterface::FILTER_%s', '\Imagine\Image\ImageInterface::%s', '%s')
Of course, we don't need them anywhere, but I think it adds clarity and acts as a small speedup.
cfa79f2
to
f3e013e
Compare
f3e013e
to
309690d
Compare
@antoligy @cedricziel Pending any objections, I'm going to merge this for inclusion in the |
Last call for comments @antoligy @cedricziel |
Seems like the obvious points have already been made, I'm very happy with this to be merged. Is it possible to process the file with a buffered stream versus buffering it into a file? (I'm actually unfamiliar with the underlying IMagick operation so it may be a limitation there). Also, as a more general point, do we have a given convention for when operations are IMagick only, because if so I think we can possibly start adding filters a little more quickly (I've got a few between projects relying on IMagick only features, including another attempt at DPR adjustment). |
@antoligy Thanks for the quick review. Here is a verbose response. ;-)
The resampling functionality exposed by the
The way I implemented the functional resample test case was confusing. It's not the filter implementation that is I've gone ahead and abstracted the test case a bit to support both As to your question about driver-specific filters, I do not have any particular issue with allowing such implementation, so long as the following conditions are met:
The latest commit (22d874c) enables multiple driver support for the |
cbbc9c4
to
22d874c
Compare
@robfrawley I can't seem to find this code in the current version of this bundle, and yet I can't find any commit / remarks about it's deprecation or removal. Any idea what happened ? |
Many questions have been asked about "retina support" including #123 and #938. While I do not believe this bundle needs to enable any retina-specific functionality, as it already allows users to define any number of "filter sets" to generate any number of variations required, we should expose a filter to properly handle changing the image resolution, or "resampling".
This PR adds a
ResampleFilterLoader
that allows for creating different "filter sets" with different resulting image resolution (not to be confused with dimensions). Included is the ability to setx
andy
resolution integers, a correspondingunit
(one of "inch" or "centimeter"), and an optional resamplingfilter
(one of\Imagine\Image\ImageInterface::FILTER_%s
).This is a first-pass at adding resampling support, and as such I'm looking for comments about the manner in which this is implemented, specifically ResampleFilterLoader.php:45. The
imagine-library
package this bundle leverages for image transformations doesn't offer any means for resampling outside of saving out the file and reading it back in, which isn't the most straightforward manner to handle this operation.Any thought on this implementation or ideas for an alternate?
This PR also introduces the following items intrinsically need for the filter loader implemented:
\Liip\ImagineBundle\Exception\Imagine\Filter\LoadFilterException
Added for exceptions thrown from within filters loader implementations
Utility/OptionsResolver/OptionsResolver:setDefined()
Added to allow for setting optional options that should not have a corresponding default value
Tests for all added functionality have now been implemented, as well.
Additions to the documentation are now yet implemented.