-
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
Add image rotate filter #588
Conversation
If it's OK, I can add a few usage examples for it |
Looks good to me, could you please add some tests for it and fix currently broken ones. Would be good if you can add some docs too. |
Private method and variable looks useless |
There is not much need of private method. The code is pretty simple to understand in one place. 👍 Let's do as @Koc suggested. Same for the property. |
2f810be
to
520ff9b
Compare
@makasim I added some tests and usage example to docs. |
*/ | ||
public function load(ImageInterface $image, array $options = array()) | ||
{ | ||
$angle = isset($options['angle']) ? intval(round(floatval($options['angle']), 0)) : 0; |
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.
intval(round(floatval($x)
is it really should be that complicated?
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.
$angle = isset($options['angle']) ? (int) $options['angle'] : 0;
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.
OK, I want to maintain a good precision in this place, but most probably it's unnecessary because angle in 0.5 degree will not be visible to the naked eye )
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 am thinking we should not do anything here. The angle comes from config? A developer set it? So it is ok if he wants 0.5 angle. Let's just pass it as is to rotate method...
wdyt?
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.
In my case, I use this filter at runtime in my twig templates, and my angle evaluate from several params and can be float
. But Imagine\Image\ManipulatorInterface::rotate
method, that I used in filter loader, expect angle as int
, so you're right, we need to type cast to int
and discard fractional part.
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.
okay
; | ||
|
||
$result = $loader->load($image, array('angle' => 90)); | ||
$this->assertInstanceOf('Imagine\Image\ManipulatorInterface', $result); |
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.
You have to create one more image mock and return it from rotate method. and here you have to check that it is that image, like you did in previous test
$this->assertSame($rotatedImage, $result);
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.
OK, I did it
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 not check for instance of and keep only one load method with image and rotatedImage.
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.
Check again, please
Thanks |
PR for #587 issue.