Skip to content
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

Merged
merged 1 commit into from
Apr 8, 2015
Merged

Add image rotate filter #588

merged 1 commit into from
Apr 8, 2015

Conversation

bocharsky-bw
Copy link
Contributor

PR for #587 issue.

@bocharsky-bw
Copy link
Contributor Author

If it's OK, I can add a few usage examples for it

@makasim
Copy link
Collaborator

makasim commented Apr 7, 2015

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.

@makasim makasim added the Level: New Feature 🆕 This item involves the introduction of new functionality. label Apr 7, 2015
@Koc
Copy link
Contributor

Koc commented Apr 7, 2015

Private method and variable looks useless

@bocharsky-bw
Copy link
Contributor Author

@Koc It unload load method and a bit improve readability and understanding in my opinion.
@makasim What do you think, better to refactor code without private method and property in this case?

@makasim
Copy link
Collaborator

makasim commented Apr 7, 2015

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.

@bocharsky-bw bocharsky-bw force-pushed the master branch 2 times, most recently from 2f810be to 520ff9b Compare April 7, 2015 13:26
@bocharsky-bw
Copy link
Contributor Author

@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;
Copy link
Collaborator

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?

Copy link
Collaborator

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;

Copy link
Contributor Author

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 )

Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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);
Copy link
Collaborator

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);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I did it

Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check again, please

makasim added a commit that referenced this pull request Apr 8, 2015
@makasim makasim merged commit 4bf3892 into liip:master Apr 8, 2015
@makasim
Copy link
Collaborator

makasim commented Apr 8, 2015

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Level: New Feature 🆕 This item involves the introduction of new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants