Rails Paperclip插件 - 调整大小的样式选项

Jon*_*der 25 ruby-on-rails imagemagick paperclip

所以,我想将图像调整为FIXED宽度,但比例高度.

我一直在尝试各种各样的运营商:

380x242#380x242> 380!x242 380x242 <

它们都没有达到预期的效果.有帮助吗?我希望它填充或调整宽度为380,然后调整高度/缩小高度所用的相同因子,将图像缩小或调整为380宽.

Slo*_*vic 56

尝试使用380x

这应该将宽度调整为380px并保持原始宽高比.

有关调整图像大小的所有可用选项,请访问:http://www.imagemagick.org/script/command-line-processing.php? ImageMagick = lj6pre8q2iautc3ch6nuph1fc2 #geometry

  • 如果可以的话,我会给你两个赞成票.完全节省我的一天,而不是玩:covert_options.干杯 (2认同)

0x4*_*672 39

"#"是Paperclip使用的参数,用于了解您是否期望裁剪图片.使用"100x100#"将缩放并将图片精确地裁剪为该尺寸.%@!<>是ImageMagick使用的Geometry String中的参数.可以使用以下ImageMagick几何字符串来调整图像大小:

  • 忽略纵横比('!')
  • 只收缩('>')
  • 仅放大较小('<')
  • 填充给定区域('^')
  • 调整百分比('%')
  • 像素数限制('@')

根据Image Geometry的ImageMagick文档,几何参数可以是

scale%              Height and width both scaled by specified percentage 
scale-x%xscale-y%   Height and width individually scaled by specified percent
width               Height automagically selected to preserve aspect ratio 
xheight             Width automagically selected to preserve aspect ratio 
widthxheight        Maximum values of height and width given, ratio preserved
widthxheight^       Minimum values of width and height given, ratio preserved
widthxheight!       Width and height emphatically given, ignore original ratio 
widthxheight>       Change only if an image dimension exceeds a specified dim. 
widthxheight<       Change only if both image dimensions exceed specified dim.
Run Code Online (Sandbox Code Playgroud)


小智 7

你可以使用,:show =>'786> x447'来确定固定宽度和高度