Ruby-on-rails 使用 Paperclip 进行简单裁剪
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1017509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Simple cropping with Paperclip
提问by collimarco
I would like to crop images on upload using Paperclip to get square thumbs from the center of the original picture. I find out a method in documentation that seems to do exactly what I want:
我想在上传时使用 Paperclip 裁剪图像以从原始图片的中心获取方形拇指。我在文档中找到了一种方法,它似乎完全符合我的要求:
transformation_to(dst, crop = false)
The problem is that I can't figure out where to use this method. It would be great to simply pass something as a parameter here:
问题是我不知道在哪里使用这种方法。在这里简单地将一些东西作为参数传递会很棒:
has_attached_file :picture,
:styles => { :medium => "600x600>", :thumb => "something here" }
回答by collimarco
You only need to use # instead of > as a parameter:
您只需要使用 # 而不是 > 作为参数:
has_attached_file :picture, :styles => { :thumb => "200x200#" }

