简体   繁体   English

如何在Ruby on Rails中裁剪图像

[英]How to crop images in Ruby on Rails

I want to allow user to crop his profile picture on a registration FORM. 我想允许用户在注册表格上裁剪自己的个人资料图片。 I see Railscast they use Jcrop for this but issue is that they allow to crop after saving the form submission. 我看到Railscast他们为此使用了Jcrop ,但问题是保存表单提交后它们允许裁剪。

I want to allow user to crop image on form immediately. 我想允许用户立即在窗体上裁剪图像。

If you're trying to crop the image on form (read : in the browser) you'll need to use javascript for that, and not rails, rails doesn't run on the browser, 如果您要在表格上裁剪图像(在浏览器中阅读:),则需要使用javascript而不是rails,rails不会在浏览器上运行,

as I said in the comment, I urge you to read more on the flow of browser-server interactions in the context of a webapp, 正如我在评论中说的,我敦促您阅读更多有关Webapp上下文中浏览器-服务器交互流程的信息,

as for cropping the image on rails, that's after receiving it (what I would recommend) is to install imagemagick and make use of the related ruby gem (Rmagick) , the documentation explains how to this in details 至于在轨道上裁剪图像,那是在收到图像之后(我建议)是安装imagemagick并利用相关的ruby gem(Rmagick),文档详细说明了如何做到这一点。

http://www.rubydoc.info/gems/rmagick/Magick/Image http://www.rubydoc.info/gems/rmagick/Magick/Image

as for cropping it on the client side, you would make use of something like this : 至于在客户端进行裁剪,您将使用以下方法:

https://fengyuanchen.github.io/cropper/ https://fengyuanchen.github.io/cropper/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM