RoR-回形针-如何设置附件的最小宽度 [英] RoR - Paperclip - How to set minimal width of an attachement

查看:115
本文介绍了RoR-回形针-如何设置附件的最小宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的版式要求是将所有缩略图的高度保持在80px处,而不是更高或更低。在我的模型中,我将样式设置为:thumb => 500x80> ,因此基本上每张不太宽的图片都可以得到80px高度的完美缩影。但是,有时我的图片又窄又高,所以拇指的不可点击尺寸可能是5x80。因此,只要缩略图不会变得狭窄,我就不想裁剪图片,但是我认为,如果拇指的宽度小于25px,我可以做出一些牺牲并将其裁剪。

my layout's requirement is to keep all thumbnails at 80px height, not higher, not smaller. In my model I set the style to :thumb=> "500x80>", so basically almost every picture which is not too wide gets its perfect miniature with 80px height. Sometimes, however, my pictures are narrow and high, so the thumb can have unclickable dimensions of like 5x80. So I dont want to crop pictures as long as thumbnails are not getting crazy narrow, but I think I can make a little sacrifice and crop them if thumb's width is getting smaller than 25px.

所以我的问题是-回形针是否可以设置图片的最小比例,使样式变为 500x80> ,超出该比例,它将变为像 25x80#

So my questions is - is it possible in paperclip to set minimal proportions of a picture by which the style will be "500x80>" and beyond that it will turn to sth like "25x80#"?

推荐答案

我不确定

Paperclip只是在后台使用imagemagick( http://www.imagemagick.org/Usage/resize/#shrink

Paperclip is just using imagemagick in the background (http://www.imagemagick.org/Usage/resize/#shrink) you could cron a job that uses image magic to grow those pesky narrow images on a nightly basis.

这是一个技巧,但我可以提供最好的主意。

It's a hack, but best idea I can offer.

祝你好运。

这篇关于RoR-回形针-如何设置附件的最小宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆