简体   繁体   English

如何只设置回形针上传图片的宽度?

[英]How to only set the width for a paperclip uploaded image?

I am uploading a large image to my model using Paperclip. 我正在使用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. :medium:thumb size我设置高度和宽度。 In the :large I just want to set the width and let it be as high as it needs to be. :large我只想设置宽度,让它尽可能高。

Any suggestions? 有什么建议么?

Try using :large => "900x" . 尝试使用:large => "900x" This should resize width to the desired value and keep original aspect ratio. 这应该将宽度调整为所需的值并保持原始宽高比。

Width only: :large => "900" 仅宽度:large => "900"

Height only: :large => "x900" 仅高度:large => "x900"

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM