简体   繁体   English

如何在红宝石上修剪和定位照片?

[英]How do I allow cropping and positioning of photos in ruby on rails?

So on users profiles I will have banner space where they can upload a photo to. 因此,在用户个人资料上,我将拥有横幅空间,他们可以在其中上传照片。 I want the space inside the banner to be filled with the photo. 我希望横幅内的空间充满照片。 Not every user will be good with creating banners in photoshop etc so I'd like to give them some control on how their photo will look in the banner by allowing them to resize it proportionally and position it left, right, up or down until the photo is showing the way they want it to in the banner. 并非每个用户都可以在photoshop中创建横幅,等等,因此我想通过允许他们按比例调整其大小并将其左,右,上或下放置直到用户满意,从而控制他们的照片在横幅中的外观照片在横幅中显示了他们想要的方式。

I'd like some limits however in order to stop users from uploading very small photos that won't look good inside the banner. 不过,我希望有一些限制,以阻止用户上传在横幅内看起来不太好看的非常小的照片。 I've checked out google+ which seems to allow this so a perfect example of what I'm looking to do is what facebook do with their timeline banner photo upload option. 我已经检查了google +,这似乎允许这样做,所以我要执行的一个完美示例是Facebook使用其时间轴横幅照片上传选项进行的操作。

I currently use carrierwave for all photo processing in my app. 我目前在我的应用中将载波用于所有照片处理。

Any advice/solutions to get me started will be much appreciated. 任何帮助我入门的建议/解决方案将不胜感激。

Kind regards 亲切的问候

You will need some kind of client editor for the banner. 您将需要某种客户端编辑器来安装横幅。 I mostly used the Jquery UI Plugin ( JqueryUI ), which helps you with some nice methods. 我主要使用了Jquery UI插件( JqueryUI ),它可以为您提供一些不错的方法。 You can easily add some draggable, resize or position functionality. 您可以轻松添加一些可拖动,调整大小或定位功能。

After the user finished the banner, you can upload the whole banner to the backend. 用户完成横幅后,您可以将整个横幅上载到后端。 For the storage and configuration of photos in rails, I recommend to use the gem 'paperclip' ( Paperclip ). 为了在导轨中存储和配置照片,我建议使用gem'paperclip'( Paperclip )。 You can set a minimum or maximum size in paperclip when pictures are uploaded. 上传图片时,可以在回形针中设置最小或最大尺寸。

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

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