使用回形针轻松裁剪 [英] Simple cropping with Paperclip
本文介绍了使用回形针轻松裁剪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用回形针在上传时裁剪图像,以使原始图片的中心处有方形的拇指。我在文档中找到了一种方法,该方法似乎完全符合我的要求:
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:
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" }
推荐答案
您只需要使用#而不是> as参数:
You only need to use # instead of > as a parameter:
has_attached_file :picture, :styles => { :thumb => "200x200#" }
这篇关于使用回形针轻松裁剪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文