How to only set the width for a paperclip uploaded image?
Asked Answered
G

2

6

I am uploading a large image to my model using Paperclip. I'd like to only set the width of the image and let it resize the height automatically.

has_attached_file :picture, :styles => { :large => "900", :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"

In the :medium and :thumb sizes I am setting both height and width. In the :large I just want to set the width and let it be as high as it needs to be.

Any suggestions?

Gaucho answered 8/7, 2013 at 16:16 Comment(0)
I
13

Try using :large => "900x". This should resize width to the desired value and keep original aspect ratio.

Insistent answered 8/7, 2013 at 16:27 Comment(0)
C
3

Width only: :large => "900"

Height only: :large => "x900"

More commands: http://www.imagemagick.org/script/command-line-processing.php#geometry

Crotch answered 5/4, 2016 at 23:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.