Giter Site home page Giter Site logo

shyamkkhadka / dragonfly Goto Github PK

View Code? Open in Web Editor NEW

This project forked from markevans/dragonfly

1.0 2.0 0.0 3.55 MB

An on-the-fly processing/encoding framework written as a Rack application.

Home Page: http://markevans.github.com/dragonfly/

License: MIT License

dragonfly's Introduction

Dragonfly

Dragonfly is a Rack framework for on-the-fly image handling.

Ideal for using with Ruby on Rails (2.3 and 3), Sinatra and all that gubbins.

For the lazy Rails user...

Gemfile:

gem 'rmagick',    :require => 'RMagick'
gem 'rack-cache', :require => 'rack/cache'
gem 'dragonfly', '~>0.7.5'

Initializer (e.g. config/initializers/dragonfly.rb):

require 'dragonfly/rails/images'

Migration:

add_column :albums, :cover_image_uid, :string

Model:

class Album < ActiveRecord::Base
  image_accessor :cover_image            # 'image_accessor' is provided by Dragonfly
                                         # this defines a reader/writer for cover_image
  # ...
end

View (for uploading via a file field):

<% form_for @album, :html => {:multipart => true} do |f| %>
  ...
  <%= f.file_field :cover_image %>
  ...
<% end %>

NB: REMEMBER THE MULTIPART BIT!!!

View (to display):

<%= image_tag @album.cover_image.url %>
<%= image_tag @album.cover_image.thumb('400x200#').url %>
<%= image_tag @album.cover_image.jpg.url %>
<%= image_tag @album.cover_image.process(:greyscale).encode(:tiff).url %>
...etc.

If using Capistrano with the above, you probably will want to keep the cache between deploys, so in deploy.rb:

namespace :dragonfly do
  desc "Symlink the Rack::Cache files"
  task :symlink, :roles => [:app] do
    run "mkdir -p #{shared_path}/tmp/dragonfly && ln -nfs #{shared_path}/tmp/dragonfly #{release_path}/tmp/dragonfly"
  end
end
after 'deploy:update_code', 'dragonfly:symlink'

Using outside of rails, custom storage/processing/encoding/analysis, and more...

Dragonfly is primarily a Rack app, so you can use it as a standalone app, or with Sinatra, Merb, etc.

It's highly customizable, and works with any data type (not just images).

For more info, consult the DOCUMENTATION

Issues

Please use the github issue tracker if you have any issues.

Suggestions/Questions

Google group dragonfly-users

Credits

Copyright

Copyright (c) 2009-2010 Mark Evans. See LICENSE for details.

dragonfly's People

Contributors

olly avatar rykov avatar zach avatar

Stargazers

Shyam Krishna Khadka avatar

Watchers

Shyam Krishna Khadka avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.