문제

Using mogrify, you can use the resize function just passing a width:

Width given, height automagically selected to preserve aspect ratio.

I am trying to find the same option with Rmagick, but it seems that the resize method expects both width and height to be provided.

Any ideas?

도움이 되었습니까?

해결책

Quoting the documentation:

Use the change_geometry method to resize an image with constraints such as "maintain the current proportions."

Try this, for example, where you want the new width to be 400px:

image = image.change_geometry("400") {|cols, rows, img| img.resize!(cols, rows)}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top