我想将图片调整到固定宽度,但高度要等比例缩放。
我尝试了许多操作符:
380x242# 380x242> 380!x242 380x242<
但都没有达到预期的效果。请问有什么方法吗?我希望图片可以填满或调整到380像素宽,然后按照同样的比例缩小高度。
我想将图片调整到固定宽度,但高度要等比例缩放。
我尝试了许多操作符:
380x242# 380x242> 380!x242 380x242<
但都没有达到预期的效果。请问有什么方法吗?我希望图片可以填满或调整到380像素宽,然后按照同样的比例缩小高度。
尝试使用380x
这将把宽度调整为380像素并保持原始宽高比。
有关调整图像的所有可用选项,请访问此处:http://www.imagemagick.org/script/command-line-processing.php?ImageMagick=lj6pre8q2iautc3ch6nuph1fc2#geometry
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.
调整大小选项有限,但您也可以使用纸夹自定义处理器动态调整图像大小。
Railscasts有一个很好的例子,使用纸夹自定义处理器,尽管他的例子允许用户裁剪图像。 http://railscasts.com/episodes/182-cropping-images