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

applying "resize" filter #57

Closed
inmarelibero opened this issue Apr 29, 2012 · 13 comments
Closed

applying "resize" filter #57

inmarelibero opened this issue Apr 29, 2012 · 13 comments
Assignees

Comments

@inmarelibero
Copy link

Let's put I want a 200x200 thumbnail starting from an image. So I set the config.yml in this way:

avalanche_imagine:
    web_root:     %kernel.root_dir%/../web
    filters:
        inset_200_200:
            type:    thumbnail
            options: { size: [200, 200], mode: inset }

and everything works well with images bigger than 200x200, because it will resize the original image depending on the max dimension: height or width.

The problem raises when the original image is smaller than 200x200, e.g. 50x50. In this case the image is stretched, until at least one dimension reaches 200. I want that smaller images than 200x200 are not resized at all.

So I tried in config.yml:

avalanche_imagine:
    web_root:     %kernel.root_dir%/../web
    filters:
        resize_200_200:
            type:    resize
            options: { size: [200, 200] }

looking at Imagine documentation page found here: http://imagine.readthedocs.org/en/latest/api/Image/manipulator_interface.html#Imagine\Image\ManipulatorInterface::flipHorizontally

from that document, I understand I can use resizefilter with sizeoption, in the same way I can use thumbnailfilter with sizeand modeoptions.

But this does not work, the thumbnail is not created at all. Anyone already tried to do this? Any suggestions? thanks

@inmarelibero
Copy link
Author

no one?

@avalanche123
Copy link
Owner

You should create your own custom filter for that functionality, it should be easy to do so by looking at the thumbnail filter loader and configuration the bundle comes with, let me know if you're having hard time understanding how to use filter loaders. @jmikola wanna chime in and point out filter loader and custom filter examples, I know you did something similar

@inmarelibero
Copy link
Author

I saw from the source that only thumbnail filter is actually implemented, and it's a little restrictive, because Imagine library has other functionalities to offer.
Also, in the documentation it's not written anywhere that only this filter is supported. If a user reads "ImagineBundle" I think he expects to be able to use all functionalities.
I prepared this PR: #59, what do you think about that?

@jmikola
Copy link
Collaborator

jmikola commented May 17, 2012

Sorry for just arriving to the conversation. @inmarelibero, I'm not sure if you still need help, but I think this is what Bulat was suggesting you use for reference: https://github.com/jmikola/JmikolaImagineBundle

I implemented a custom filter there for resizing with Imagine's heighten, increase, scale, widen modes.

@avalanche123
Copy link
Owner

@jmikola I like the resize filter, would you be interested in adding that to this bundle? along with docs?

@avalanche123
Copy link
Owner

closing the issue

@jmikola
Copy link
Collaborator

jmikola commented Nov 6, 2012

Sorry, I didn't check GitHub for the past two days. I will assign this to myself and work on a PR.

IIRC, the only reason I created JmikolaImagineBundle is because we wanted to encourage people to create their own filters instead of relying on this bundle being bloated :)

@jmikola jmikola reopened this Nov 6, 2012
@ghost ghost assigned jmikola Nov 6, 2012
@avalanche123
Copy link
Owner

thanks Jeremy!

@avalanche123
Copy link
Owner

@jmikola ping, any progress on this? :)

@inmarelibero
Copy link
Author

great, thank you!

Bluestart83 pushed a commit to Bluestart83/AvalancheImagineBundle that referenced this issue Jun 10, 2013
@hellomedia
Copy link

I am confused. so does relative resize only resize down , not up ?

@jmikola
Copy link
Collaborator

jmikola commented Sep 22, 2014

It's been more than a while since I looked at this, but relative resizing shouldn't care about the original size of the image. It simply guarantees that the aspect ratio is preserved.

The documentation examples in https://github.com/jmikola/JmikolaImagineBundle#relativeresize (my old bundle) should explain how this works.

@hellomedia
Copy link

Thanks. I am still a little surprised that small images might be enlarged (blurred) by the resize. I was looking at a way to have bigger images rezied to a max size, with smaller images left untouched. I'll take a deeper look at the code to see how to go about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants