jopen
11年前发布

Ruby 图像上传框架:Dragonfly

Dragonfly 是一个 Ruby gem 用于动态处理 Rails、Sinatra 等框架的图像上传。

示例代码:

如果你想生成缩略图:

class User < ActiveRecord::Base  # model    dragonfly_accessor :photo  end    <%= image_tag @user.photo.thumb('300x200#')  # view  %>

在 Sinatra 下生成文本图像

get "/:text" do |text|    Dragonfly.app.generate(:text, text, "font-size" => 32).to_response(env)  end

生成附件

wav = Dragonfly.app.fetch_url("http://free.music/lard.wav")  # GET from t'interwebs  mp3 = wav.to_mp3  # to_mp3 is a custom processor  uid = mp3.store   # store in the configured datastore, e.g. S3    url = Dragonfly.app.remote_url_for(uid)  # ===> http://s3.amazon.com/my-stuff/lard.mp3

项目主页:http://www.open-open.com/lib/view/home/1386925167184

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1386925167184.html
Ruby开发 DragonFly