I have installed LiipImagineBundle in Symfony 2.1 and I am trying to use it for user profiles' avatars. Liip has some sorts of settings that do not allow you to resize in width and height.

 my_heighten:
            filters:
                relative_resize: { heighten: 60 } # Transforms 50x40 to 75x60
        my_widen:
            filters:
                relative_resize: { widen: 32 }    # Transforms 50x40 to 32x26

This means that If you have an image 100px*2000px, resizing in height to 120px will have a width of more than 2000px. I want to resize both portrait and landscape images to include all possible user interactions with the image upload element. I have tried to use

filters:
       relative_resize: { heighten: 60, widen: 60 }

and

 filters:
           relative_resize: { heighten: 60 }
           relative_resize: { widen: 60 }

but none of them work.

Has anyone tried anything similar ?

EDIT: I forgot to say that I need a square image 60*60 than will not be cropped.

有帮助吗?

解决方案

liip_imagine:
    filter_sets:
        filter_name:
            filters:
                resize:
                    size: [60, 60]

Only this wont crop.

其他提示

Try the thumbnail filter with the inset mode:

liip_imagine:
    filter_sets:
        filter_name:
            filters:
                thumbnail:
                    size: [60, 60]
                    mode: inset

But you should understand that you won't get a square image if the original wasn't itself square. Instead, it will be limited by 60 pixels in width or 60 pixels in height.

If you want to get a square image, you need cropping which you can get by using the outbound mode.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top