GithubHelp home page GithubHelp logo

alexjwayne / fleximage Goto Github PK

View Code? Open in Web Editor NEW
242.0 7.0 53.0 12.16 MB

Rails plugin for uploading images as resources, with support for resizing, text stamping, and other special effects.

Home Page: http://wiki.github.com/Squeegy/fleximage

License: MIT License

JavaScript 0.09% Ruby 87.82% HTML 11.37% CSS 0.72%

fleximage's Introduction

DEPRECATED

This code is being preserved for historical reasons. It’s unmaintained and if it still works at all it’d be a miracle.

Installation

Gem: (Recommended)

gem install fleximage

# in config/environment.rb
config.gem 'fleximage'

Plugin:

./script/plugin install git://github.com/Squeegy/fleximage.git

Fleximage

Overview

Fleximage is a Rails plugin that tries to make image uploading and rendering super easy.

There are 2 pieces involved in making Rails image handling easy.

1. Image Uploads

In this post Rails 2, resource-driven world, Fleximage believes that images should belong directly to a record. So you simply tell your model class to act as Fleximage, and your model effortlessly gains the ability to handle file uploads.

  • Your model gains the ability to interface directly with a file_field form, allowing uploads with zero extra controller or model code.

  • Accept uploads from a web address, pulling in the image from the internet and saving it locally.

  • Image presence validation with customizable form field error messages.

  • Image format validation that will not allow the file to be uploaded unless RMagick can parse it into useable image data.

  • Image pre-processing to keep uploaded images under a certain size, or other on-upload image processing tasks.

2. Image Rendering

The other half of the problem comes from the need to send the uploaded images back to the web browser. Most of the time, you need to display the image in different sizes or formats in different places on your site. For example, a product image in a store may need a square thumbnail image, a medium image for its focus page, and a large image for an “enlarge this photo” popup.

Fleximage uses a simple templating engine that allows you to re-render images exactly how you need them. Using the same “master image,” many images can be rendered from the same source. You can even go beyond resizing; there is support for image overlays, text drawing, drop shadows, borders and more. The rendering engine is flexible and extensible to whatever your dynamic image needs are.

  • Renderer implemented as template engine, which fits in perfectly with Rails 2 RESTful style format-sensitive views.

  • Does not need to have everything resized on upload allowing your site layout the change later on, and all images will re-render themselves just right with your new rendering templates.

  • Support for special effects like text, image or logo overlays, borders and shadows.

  • Extensible by adding image operator classes which allow for reusable snippets of direct RMagick code.

  • Requires absolutely zero controller code.

Getting Started

1. Installation

Gem: (Recommended)

gem install fleximage

# in config/environment.rb
config.gem 'fleximage'

Plugin:

./script/plugin install git://github.com/Squeegy/fleximage.git

2. Activating your model

You need to let your model know it should be Fleximage-friendly. Lets say you have a model for photos.

# app/models/photo.rb
class Photo < ActiveRecord::Base
  acts_as_fleximage :image_directory => 'public/images/uploaded_photos'
end

The :image_directory option tells the plugin where to store your master images. This value is relative to your application root, and doesn’t need to be in your public directory if you don’t want it to be. This is where the source images will be that all your templates start with.

There are many other options for your model. Refer to the Fleximage::Model::ClassMethods class in the rdoc for more information on these.

3. The upload form

Your users need a way to upload their images into your site. Here is how we might render a form to create a photo record.

# app/views/photos/new.html.erb

<% form_for @photo, :html => { :multipart => true } do |f| %>
  <p>
    <b>Name</b><br />
    <%= f.text_field :name %>
  </p>

  <p>
    <b>Author</b><br />
    <%= f.text_field :author %>
  </p>

  <p>
    <b>Upload Image</b><br />
    <%= f.file_field :image_file %><br />
    or URL: <%= f.text_field :image_file_url %>
  </p>

  <p>
    <%= f.submit "Create" %>
  </p>
<% end %>

NOTE: The “:html => { :multipart => true }” is VERY IMPORTANT. Without this snippet your browser will not send binary data to the server. If things aren’t working, check to make sure you have this in your form declaration.

The relevant bit of our form code is:

<p>
  <b>Upload Image</b><br />
  <%= f.file_field :image_file %><br />
  or URL: <%= f.text_field :image_file_url %>
</p>

First there is a file upload field, mapping the the “image_file” attribute of our model. When the user browses to a local file and uploads it, the model is waiting to accept an uploaded file on this attribute and will automatically open it and save it to disk for you.

Right along side the upload field is a simple text field, which maps to the “image_file_url” property. Your model also listens for assignment to this attribute to automatically fetch the contents of a URL and save it locally as the master image.

You can have just one of these fields, or both. The model will know how to do the right thing either way.

When the user submits the form, all you have to do is assign the form contents to your object in standard Rails fashion, and the image is uploaded and saved for you. Creating a new photo may look like this in your controller:

# app/controllers/photos_controller.rb
def create
  @photo = Photo.new(params[:photo])
  if @photo.save
    redirect_to photo_url(@photo)
  else
    flash[:notice] = 'Your photo did not pass validation!'
    render :action => 'new'
  end
end

4. Linking to the generated images

Rails 2 has amazing support for format driven responses. Given a photo object, by default it would have an HTML view that describes information about that photo. With Fleximage, the JPG or (GIF or PNG) view can be the image data itself.

A photo HTML view may look like this:

# app/views/photos/show.html.erb
# http://mysite.com/photos/123

<p>
  <%= image_tag formatted_photo_path(@photo, :jpg) %>
</p>
<p>
  <b>Name:</b>
  <%=h @photo.name %>
</p>
<p>
  <b>Author:</b>
  <%=h @photo.author %>
</p>

That image tag uses a Rails route as its src. In this case, that route corresponds to the .jpg format of the photo resource, which would give us a URL like:

http://mysite.com/photos/123.jpg

This is the URL where the image will be.

5. Rendering the image

Now it’s time to actually create a template to render the image. This happens through a special view with a .flexi extension. This view template will pull out the master image for you, and send it to the browser as binary data after your processing of it done.

The filename of the template should look like this: action_name.jpg.flexi, where action_name is the controller action that will render this view. The jpg tells the controller to render this view when the jpg format is asked for. The flexi tells Rails to render this view with the Fleximage template engine, rather than erb, builder or other template types.

The syntax of the view is pure ruby, but to process the image the view needs to call operate on the instance of your model.

Here is the view to render a photo record at 320x240:

# app/views/photos/show.jpg.flexi
# http://mysite.com/photos/123.jpg
@photo.operate do |image|
  image.resize '320x240'
end

Calling @photo.operate { |image| .. } prepares the model object for image processing and provides a ruby object that will allow you to perform image transformations. This example just resizes the image to 320x240, however many other operators are included.

Here is a .flexi template that will do much more:

# app/views/show.jpg.flexi
@photo.operate do |image|
  image.resize '640x480', :crop => true
  image.image_overlay 'public/images/logo.png',
    :alignment => :bottom_right,
    :offset => '20x20'
  image.border :size => 10, :color => 'green'
  image.text 'I like Cheese'
  image.unsharp_mask  
  image.shadow
end

This template will:

  • Resize the image to exactly 640x480, cropping off any extra.

  • Add a logo 20 pixels form the lower right corner

  • Add a green 10 pixel border

  • Write “I like Cheese” in the upper left corder

  • Sharpen the image

  • Add a black drop shadow on a white background

For more information on image operators, open up vendor/plugins/fleximage/rdoc/index.html in your installed plugin and check out the full for details about each operator:

  • Fleximage::Operator::Border

  • Fleximage::Operator::Crop

  • Fleximage::Operator::ImageOverlay

  • Fleximage::Operator::Resize

  • Fleximage::Operator::Shadow

  • Fleximage::Operator::Text

  • Fleximage::Operator::Trim

  • Fleximage::Operator::UnsharpMask

Other Useful Information

Image output format

You don’t want to render JPGs? That’s fine. Just link to the format you want (:jpg, :gif or :png) and declare the your template name to match and the image will be rendered properly. For instance, this will render a gif.

# app/views/photos/show.html.erb
<%= image_tag photo_path(@photo, :gif) %>

# app/views/photos/show.gif.flexi
@photo.operate do |image|
  @photo.resize '150x150', :crop => true
end

The Fleximage template engine will automatically detect the format that is being asked for, and render the right type of image.

Converting/Upgrading your master image store

Are you upgrading your live app to the new file store creation date based format? Did you start out with PNG image storage, and later realize you need to store with the more space economic JPG instead? Not problem, Fleximage provides some rake tasks to help you out.

Each conversion rake task requires that you tell it the class for which that you are changing the file store. For example, if you want to change to the new creation date based storage structure, for the class Photo, you can run a rake task like this:

rake fleximage:convert:to_nested FLEXIMAGE_CLASS=Photo

Or if you want to run this on your production database

rake fleximage:convert:to_nested FLEXIMAGE_CLASS=Photo RAILS_ENV=production

IMPORTANT: These tasks manipulate the source files that make up your images. I take no responsibility if these rake tasks delete all your images. It is highly advised you back up you master image directory before running any of these tasks on your production site.

Here are all the conversion tasks:

  • fleximage:convert:to_nested : Converts your master image store from the flat based path/to/images/123.png format to the creation date based format path/to/images/2008/11/12/123.png based format. Use this task if you are upgrading from an older version of Fleximage.

  • fleximage:convert:to_flat : Converts your master image store from the creation date based path/to/images/2008/11/12/123.png format to the flat format path/to/images/123.png format. Note this will leave the date based directories in place, but they will be empty and can be easily manually deleted.

  • fleximage:convert:to_jpg : Converts all your stored master images from PNG format to JPG format. This will compress your previously lossless master images.

  • fleximage:convert:to_png : Converts all your stored master images from JPG format to PNG format.

After you run any of these tasks, make sure to update your model’s class accessors use_creation_date_based_directories and image_storage_format to reflect the state of your image store. Otherwise, the plugin will not find you master images for rendering.


Copyright © 2008 Alex Wayne beautifulpixel.com, released under the MIT license. Special Thanks to Chris Vannoy for intelligent code review, suggestions and contributions to making this plugin awesome.

fleximage's People

Contributors

aa365 avatar alexjwayne avatar bjjb avatar jlsync avatar kou avatar lassej avatar miau avatar moser avatar pixeltrix avatar ralph avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fleximage's Issues

Running Fleximage on Ruby 1.9, got error

The error was something like:

-- C level backtrace information -------------------------------------------
0x10010cd8d 0 libruby.dylib 0x000000010010cd8d rb_vm_bugreport + 77
0x10002b184 1 libruby.dylib 0x000000010002b184 report_bug + 260
0x10002b318 2 libruby.dylib 0x000000010002b318 rb_bug + 200
0x1000b7124 3 libruby.dylib 0x00000001000b7124 sigsegv + 132
0x7fff8151514a 4 libSystem.B.dylib 0x00007fff8151514a _sigtramp + 26
0x5 5 ??? 0x0000000000000005 0x0 + 5
0x103abcaf5 6 libMagickCore.2.dylib 0x0000000103abcaf5 AcquirePixelCache + 309
0x103b664e6 7 libMagickCore.2.dylib 0x0000000103b664e6 AcquireImage + 358
0x103b66fc2 8 libMagickCore.2.dylib 0x0000000103b66fc2 SetImageInfo + 466
0x103ae5ccd 9 libMagickCore.2.dylib 0x0000000103ae5ccd ReadImage + 173
0x101f957ff 10 RMagick2.bundle 0x0000000101f957ff rd_image + 339
0x101f9566f 11 RMagick2.bundle 0x0000000101f9566f Image_read + 36

Any idea what could be wrong? I am using RVM (Ruby Version Manager http://rvm.beginrescueend.com/) and the one on Ruby version 1.8.7 works nicely.

Thanks for such awesome gem!

has_key? issue

Running Rails 2.3.4 and when trying to display an image using

<%= image_tag pictures_path(@picture, :jpg) %>

Getting this error
undefined method `has_key?' for :jpg:Symbol

I can browse to localhost:3000/pictures/8.jpg and the image will show just fine, but not if I try to do it the other way.

Any ideas or help would be appreciated

More than one size image output in same file type (e.g. image is available as both 111.jpg and thumb111.jpg)

Hello everyone, I'm having trouble getting my head around having both an image and thumbnail on the same page, using the same file type.
EG if my image object id is 111,
I can display 111.jpg at a given size using the .jpg.flexi template
I can display 111.png at a different size using the .png.flexi template
OK so far.
What I'd like is to both thumbnail and full image as .jpg.
Before fleximage, I'd have taken an image and generated multiple versions like 111.jpg and thumb111.jpg, I just can't see how to solve that need using fleximage.

If anyone can put me on the right track I'd appreciate it.
Thanks,
Steve

Loading default image is not working

Hi,
I don't know if this is occurring only on my dev-machine, but Fleximage is not loading default images properly.

When fleximage tries to load the image in Model.load_image it doesn't check that if it exists. Rather it tries to load the image with Magick::Image.read, which in turn throws an exception when the file is not found.

Unfortunately that doesn't work anymore for me. Fleximage expects that exception contains string "unable to open (file|image)", but in my environment RMagick always throws exception "no decode delegate for this image format". Because of that, the fleximage fails and exception is raised.

I'm using ImageMagick 6.6.3, RMagick 2.12.2, Rails 2.3.5 with REE 2010.02

Alpha channel being ignored in custom operator

I am seeing this issue on both Windows 7 and Ubuntu:

Here is my custom operator.

class Fleximage::Operator::Snap < Fleximage::Operator::Base
   def operate(caption = nil)
   photo_frame = Magick::Image.read("public/images/frames/snap_master2.png")[0]
    @image = @image.resize_to_fill(150, 180)

    @image = photo_frame.composite(@image, 17, 17, Magick::OverCompositeOp)
  end
end

When this is executed any alpha in "public/images/frames/snap_master2.png" is rendered in black. I have tried to recreate the image in several ways with similar results.

autotest not finding aws/s3 gem

rake test runs tests fine, but autotest complains of this

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -rrubygems -e "require 'redgreen'" -I.:lib:test -rubygems -e "['test/unit', 'test/functional/menuitems_controller_test.rb', 'test/unit/itemcategory_test.rb', 'test/functional/itemcategory_controller_test.rb', 'test/functional/cities_controller_test.rb', 'test/functional/categories_controller_test.rb', 'test/unit/user_test.rb', 'test/unit/helpers/home_helper_test.rb', 'test/functional/sessions_controller_test.rb', 'test/unit/menuitem_test.rb', 'test/unit/helpers/localities_helper_test.rb', 'test/functional/home_controller_test.rb', 'test/unit/helpers/itemcategory_helper_test.rb', 'test/unit/helpers/photos_helper_test.rb', 'test/unit/helpers/categories_helper_test.rb', 'test/unit/venue_test.rb', 'test/unit/helpers/hoods_helper_test.rb', 'test/unit/helpers/venues_helper_test.rb', 'test/functional/users_controller_test.rb', 'test/unit/user_mailer_test.rb', 'test/unit/helpers/menuitems_helper_test.rb', 'test/functional/pages_controller_test.rb', 'test/functional/hoods_controller_test.rb', 'test/unit/city_test.rb', 'test/functional/photos_controller_test.rb', 'test/unit/review_test.rb', 'test/unit/category_test.rb', 'test/unit/hood_test.rb', 'test/functional/localities_controller_test.rb', 'test/unit/locality_test.rb', 'test/unit/page_test.rb', 'test/unit/helpers/reviews_helper_test.rb', 'test/functional/venues_controller_test.rb', 'test/unit/helpers/cities_helper_test.rb', 'test/unit/helpers/pages_helper_test.rb', 'test/functional/reviews_controller_test.rb', 'test/unit/photo_test.rb'].each { |f| require f }" | /Library/Ruby/Gems/1.8/gems/autotest-4.2.9/bin/unit_diff -u
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require': no such file to load -- aws/s3 (MissingSourceFile) from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:inrequire'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:158:in require' from /Users/jerome/Sites/happyhour/vendor/plugins/fleximage/lib/fleximage.rb:4 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:ingem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:158:inrequire'
from /Users/jerome/Sites/happyhour/vendor/plugins/fleximage/init.rb:1:in evaluate_init_rb' from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/plugin.rb:158:inevaluate_init_rb'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/kernel/reporting.rb:11:in silence_warnings' from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/plugin.rb:154:inevaluate_init_rb'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/plugin.rb:48:in load' from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/plugin/loader.rb:38:inload_plugins'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/plugin/loader.rb:37:in each' from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/plugin/loader.rb:37:inload_plugins'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:369:in load_plugins' from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:165:inprocess'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in send' from /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:inrun'
from /Users/jerome/Sites/happyhour/config/environment.rb:9
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:inrequire'
from ./test/test_helper.rb:2
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:inrequire'
from ./test/functional/menuitems_controller_test.rb:1
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:inrequire'
from -e:2
from -e:2:in `each'
from -e:2

No support for Rails 3.2

I've been using fleximage in an app since 2 years and it works like a charm in Rauls 2.2.2. Now I might be forced to go to Rails 3.2 but unfortunately the fixes made by Giovanelli for 3.1 are not sufficient for 3.2.

I'm getting an error
vendor/plugins/fleximage/lib/fleximage/view.rb:4: uninitialized constant ActionView::TemplateHandler (NameError
on initialisation.
which I'm not able to deal with.
Are there plans to adapt fleximage to Rails 3.2 or should I look for a fleximage replacement?
Has anyone used fleximage with a current Rails version?

image_file_url = nil breaks

To allow:
image_file_url = nil

line 395 of model.rb should be

elsif file_url.blank?

not:

elsif file_url.empty?

Problem using fleximage under Snow Leopard

hi,
I upgrade my os to mac ox 10.6 and reinstalled the ImageMagick and RMagick.

I got these exceptions and don't know how to handle:
=> Booting WEBrick
=> Rails 2.3.3 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2009-09-01 23:48:28] INFO WEBrick 1.3.1
[2009-09-01 23:48:28] INFO ruby 1.9.1 (2009-07-16) [i386-darwin10.0.0]
[2009-09-01 23:48:28] INFO WEBrick::HTTPServer#start: pid=45497 port=3000
/Users/arkxu/rprojects/htmless/vendor/plugins/fleximage/lib/fleximage/model.rb:296: [BUG] Segmentation fault
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-darwin10.0.0]

-- control frame ----------
c:0058 p:---- s:0285 b:0285 l:000284 d:000284 CFUNC :read
c:0057 p:0058 s:0281 b:0281 l:000280 d:000280 METHOD /Users/arkxu/rprojects/htmless/vendor/plugins/fleximage/lib/fleximage/model.rb:296
c:0056 p:0084 s:0275 b:0275 l:000265 d:000274 BLOCK /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/base.rb:2740
c:0055 p:---- s:0271 b:0271 l:000270 d:000270 FINISH
c:0054 p:---- s:0269 b:0269 l:000268 d:000268 CFUNC :each
c:0053 p:0078 s:0266 b:0266 l:000265 d:000265 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/base.rb:2736
c:0052 p:0059 s:0259 b:0259 l:000258 d:000258 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/base.rb:2434
c:0051 p:---- s:0254 b:0254 l:000253 d:000253 FINISH
c:0050 p:---- s:0252 b:0252 l:000251 d:000251 CFUNC :new
c:0049 p:0107 s:0248 b:0248 l:000247 d:000247 METHOD /Users/arkxu/rprojects/htmless/app/controllers/p_pic_disp_items_controller.rb:61
c:0048 p:0042 s:0245 b:0245 l:000244 d:000244 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/base.rb:1327
c:0047 p:0047 s:0241 b:0241 l:000240 d:000240 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/filters.rb:617
c:0046 p:0028 s:0234 b:0234 l:000233 d:000233 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/filters.rb:610
c:0045 p:0009 s:0231 b:0231 l:000f78 d:000230 BLOCK /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:68
c:0044 p:0005 s:0229 b:0229 l:0011d8 d:000228 BLOCK /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17
c:0043 p:0024 s:0227 b:0227 l:000226 d:000226 METHOD /usr/local/ruby/lib/ruby/1.9.1/benchmark.rb:309
c:0042 p:0013 s:0221 b:0220 l:0011d8 d:0011d8 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17
c:0041 p:0028 s:0217 b:0217 l:000f78 d:000f78 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:68
c:0040 p:0011 s:0210 b:0210 l:000209 d:000209 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/rescue.rb:160
c:0039 p:0011 s:0206 b:0206 l:000205 d:000205 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/flash.rb:146
c:0038 p:0088 s:0203 b:0203 l:000202 d:000202 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/base.rb:527
c:0037 p:0029 s:0196 b:0196 l:000195 d:000195 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/filters.rb:606
c:0036 p:0021 s:0189 b:0189 l:000188 d:000188 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/base.rb:391
c:0035 p:0097 s:0184 b:0184 l:000183 d:000183 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/base.rb:386
c:0034 p:0054 s:0178 b:0178 l:000177 d:000177 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/routing/route_set.rb:434
c:0033 p:0035 s:0172 b:0172 l:000171 d:000171 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:88
c:0032 p:0017 s:0167 b:0167 l:000166 d:000166 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:111
c:0031 p:0018 s:0163 b:0163 l:001b10 d:000162 LAMBDA /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:82
c:0030 p:---- s:0160 b:0160 l:000159 d:000159 FINISH
c:0029 p:---- s:0158 b:0158 l:000157 d:000157 CFUNC :call
c:0028 p:0014 s:0154 b:0154 l:000153 d:000153 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/head.rb:9
c:0027 p:0150 s:0147 b:0147 l:000146 d:000146 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/methodoverride.rb:24
c:0026 p:0045 s:0141 b:0141 l:000140 d:000140 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/params_parser.rb:15
c:0025 p:0080 s:0136 b:0136 l:000135 d:000135 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/session/abstract_store.rb:122
c:0024 p:0013 s:0124 b:0124 l:000190 d:000123 BLOCK /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:29
c:0023 p:0038 s:0122 b:0122 l:000121 d:000121 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/query_cache.rb:34
c:0022 p:0051 s:0118 b:0118 l:000117 d:000117 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:9
c:0021 p:0019 s:0114 b:0114 l:000190 d:000190 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:28
c:0020 p:0014 s:0110 b:0110 l:000109 d:000109 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:3
c:0019 p:0030 s:0106 b:0106 l:000105 d:000105 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/reloader.rb:29
c:0018 p:0014 s:0099 b:0099 l:000098 d:000098 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/failsafe.rb:26
c:0017 p:0013 s:0094 b:0094 l:000088 d:000093 BLOCK /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/lock.rb:11
c:0016 p:0019 s:0092 b:0092 l:000091 d:000091 METHOD internal:prelude:8
c:0015 p:0052 s:0089 b:0089 l:000088 d:000088 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/lock.rb:11
c:0014 p:0014 s:0084 b:0084 l:000083 d:000083 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:106
c:0013 p:0185 s:0080 b:0080 l:000079 d:000079 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.3/lib/rails/rack/static.rb:31
c:0012 p:0195 s:0073 b:0073 l:000062 d:000072 BLOCK /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:46
c:0011 p:---- s:0068 b:0068 l:000067 d:000067 FINISH
c:0010 p:---- s:0066 b:0066 l:000065 d:000065 CFUNC :each
c:0009 p:0069 s:0063 b:0063 l:000062 d:000062 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:40
c:0008 p:0014 s:0054 b:0054 l:000053 d:000053 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.3/lib/rails/rack/log_tailer.rb:17
c:0007 p:0014 s:0049 b:0049 l:000048 d:000048 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/content_length.rb:13
c:0006 p:0303 s:0041 b:0041 l:000040 d:000040 METHOD /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/handler/webrick.rb:46
c:0005 p:0256 s:0030 b:0030 l:000029 d:000029 METHOD /usr/local/ruby/lib/ruby/1.9.1/webrick/httpserver.rb:111
c:0004 p:0382 s:0020 b:0020 l:000019 d:000019 METHOD /usr/local/ruby/lib/ruby/1.9.1/webrick/httpserver.rb:70
c:0003 p:0123 s:0009 b:0009 l:0001d8 d:000008 BLOCK /usr/local/ruby/lib/ruby/1.9.1/webrick/server.rb:183
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH

c:0001 p:---- s:0002 b:0002 l:000001 d:000001 TOP

-- Ruby level backtrace information-----------------------------------------
/Users/arkxu/rprojects/htmless/vendor/plugins/fleximage/lib/fleximage/model.rb:296:in read' /Users/arkxu/rprojects/htmless/vendor/plugins/fleximage/lib/fleximage/model.rb:296:inimage_file='
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/base.rb:2740:in block in attributes=' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/base.rb:2736:ineach'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/base.rb:2736:in attributes=' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/base.rb:2434:ininitialize'
/Users/arkxu/rprojects/htmless/app/controllers/p_pic_disp_items_controller.rb:61:in new' /Users/arkxu/rprojects/htmless/app/controllers/p_pic_disp_items_controller.rb:61:increate'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/base.rb:1327:in perform_action' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/filters.rb:617:incall_filters'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/filters.rb:610:in perform_action_with_filters' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:68:inblock in perform_action_with_benchmark'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in block in ms' /usr/local/ruby/lib/ruby/1.9.1/benchmark.rb:309:inrealtime'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in ms' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:68:inperform_action_with_benchmark'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/rescue.rb:160:in perform_action_with_rescue' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/flash.rb:146:inperform_action_with_flash'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/base.rb:527:in process' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/filters.rb:606:inprocess_with_filters'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/base.rb:391:in process' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/base.rb:386:incall'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/routing/route_set.rb:434:in call' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:88:indispatch'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:111:in _call' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:82:inblock in initialize'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/head.rb:9:in call' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/head.rb:9:incall'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/methodoverride.rb:24:in call' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/params_parser.rb:15:incall'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/session/abstract_store.rb:122:in call' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:29:inblock in call'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in cache' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:9:incache'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:28:in call' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:incall'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/reloader.rb:29:in call' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/failsafe.rb:26:incall'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/lock.rb:11:in block in call' <internal:prelude>:8:insynchronize'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/lock.rb:11:in call' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:106:incall'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.3/lib/rails/rack/static.rb:31:in call' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:46:inblock in call'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in each' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/urlmap.rb:40:incall'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/rails-2.3.3/lib/rails/rack/log_tailer.rb:17:in call' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/content_length.rb:13:incall'
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.0.0/lib/rack/handler/webrick.rb:46:in service' /usr/local/ruby/lib/ruby/1.9.1/webrick/httpserver.rb:111:inservice'
/usr/local/ruby/lib/ruby/1.9.1/webrick/httpserver.rb:70:in run' /usr/local/ruby/lib/ruby/1.9.1/webrick/server.rb:183:inblock in start_thread'

-- C level backtrace information -------------------------------------------
0x10010866d 0 ruby 0x000000010010866d rb_vm_bugreport + 77
0x100027d64 1 ruby 0x0000000100027d64 report_bug + 260
0x100027ef8 2 ruby 0x0000000100027ef8 rb_bug + 200
0x1000b3664 3 ruby 0x00000001000b3664 sigsegv + 132
0x7fff87ffd14a 4 libSystem.B.dylib 0x00007fff87ffd14a _sigtramp + 26
0x0 5 ??? 0x0000000000000000 0x0 + 0
0x103815f85 6 libMagickCore.2.dylib 0x0000000103815f85 AcquirePixelCache + 293
0x1038bdc06 7 libMagickCore.2.dylib 0x00000001038bdc06 AcquireImage + 358
0x1038be6e2 8 libMagickCore.2.dylib 0x00000001038be6e2 SetImageInfo + 466
0x10383e58d 9 libMagickCore.2.dylib 0x000000010383e58d ReadImage + 173
0x101f83e9b 10 RMagick2.bundle 0x0000000101f83e9b rd_image + 339
0x101f83d0b 11 RMagick2.bundle 0x0000000101f83d0b Image_read + 36
0x1000f8bd1 12 ruby 0x00000001000f8bd1 vm_call_cfunc + 337
0x1000fa480 13 ruby 0x00000001000fa480 vm_call_method + 896
0x1000fb3bc 14 ruby 0x00000001000fb3bc vm_exec_core + 3164
0x1001005ce 15 ruby 0x00000001001005ce vm_exec + 1102
0x1001063b9 16 ruby 0x00000001001063b9 rb_yield + 505
0x10003c857 17 ruby 0x000000010003c857 each_pair_i + 23
0x10003d0d8 18 ruby 0x000000010003d0d8 hash_foreach_iter + 40
0x1000baaaa 19 ruby 0x00000001000baaaa st_foreach + 218
0x10003eefa 20 ruby 0x000000010003eefa hash_foreach_call + 26
0x10002980f 21 ruby 0x000000010002980f rb_ensure + 127
0x10003e2f8 22 ruby 0x000000010003e2f8 rb_hash_foreach + 56
0x10003e8c1 23 ruby 0x000000010003e8c1 rb_hash_each_pair + 81
0x1000f8bd1 24 ruby 0x00000001000f8bd1 vm_call_cfunc + 337
0x1000fa480 25 ruby 0x00000001000fa480 vm_call_method + 896
0x1000fb3bc 26 ruby 0x00000001000fb3bc vm_exec_core + 3164
0x1001005ce 27 ruby 0x00000001001005ce vm_exec + 1102
0x1001024cd 28 ruby 0x00000001001024cd vm_call0 + 621
0x1000f9d78 29 ruby 0x00000001000f9d78 rb_funcall2 + 296
0x10005aba3 30 ruby 0x000000010005aba3 rb_class_new_instance + 51
0x1000f8bd1 31 ruby 0x00000001000f8bd1 vm_call_cfunc + 337
0x1000fa480 32 ruby 0x00000001000fa480 vm_call_method + 896
0x1000fb3bc 33 ruby 0x00000001000fb3bc vm_exec_core + 3164
0x1001005ce 34 ruby 0x00000001001005ce vm_exec + 1102
0x100102013 35 ruby 0x0000000100102013 rb_vm_invoke_proc + 691
0x1000f8bd1 36 ruby 0x00000001000f8bd1 vm_call_cfunc + 337
0x1000fa480 37 ruby 0x00000001000fa480 vm_call_method + 896
0x1000fb3bc 38 ruby 0x00000001000fb3bc vm_exec_core + 3164
0x1001005ce 39 ruby 0x00000001001005ce vm_exec + 1102
0x1001063b9 40 ruby 0x00000001001063b9 rb_yield + 505
0x100004582 41 ruby 0x0000000100004582 rb_ary_each + 82
0x1000f8bd1 42 ruby 0x00000001000f8bd1 vm_call_cfunc + 337
0x1000fa480 43 ruby 0x00000001000fa480 vm_call_method + 896
0x1000fb3bc 44 ruby 0x00000001000fb3bc vm_exec_core + 3164
0x1001005ce 45 ruby 0x00000001001005ce vm_exec + 1102
0x100102013 46 ruby 0x0000000100102013 rb_vm_invoke_proc + 691
0x10010d063 47 ruby 0x000000010010d063 thread_start_func_2 + 835
0x10010d181 48 ruby 0x000000010010d181 thread_start_func_1 + 17
0x7fff87fd606e 49 libSystem.B.dylib 0x00007fff87fd606e _pthread_start + 331
0x7fff87fd5f21 50 libSystem.B.dylib 0x00007fff87fd5f21 thread_start + 13

[NOTE]
You may encounter a bug of Ruby interpreter. Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Abort trap

Can't render Image

Hello,

i just installed fleximage and i was able to upload the images to my directory. but there ist a problem:

i can display the images.

i got this error:

NoMethodError in Pictures#mini

Showing /media/psf/rails/mobile_designer/app/views/pictures/mini.png.flexi where line #1 raised:

undefined method `template' for #PicturesController:0x7f4c5014f0c0

i an using rails 3.0.9

[PATCH] image_directory doesn't prepend RAILS_ROOT to an absolute path

image_directory always prepends RAILS_ROOT to passed path.
It forces that image directory should be under RAILS_ROOT.

But there are some cases to save images outside RAILS_ROOT.
For example, capistrano deployment case is one of the cases. Capistrano deploys an application to /.../releases/20XXXXXX/ and create symbolic links to /.../current/. Deployed applications, /.../releases/20XXXXXX/*, should share its image directory outsize its RAILS_ROOT. (e.g. /.../shares/images/)

In the case, we want to use absolute path not relative path from RAILS_ROOT for image directory.

I have a solution that image_directory doesn't prepend RAILS_ROOT for passed path that is absolute path.
Here is a patch:
http://github.com/kou/fleximage/commit/a73bf4640bab20e9e894bbebaf33fa76b1843707

GraphicsMagick 1.1.11

ActionView::TemplateError (the `strip!' method is not supported by GraphicsMagick 1.1.11)

Example for using Fleximage as association

Hi,
thanks for this great plugin. I currently try to get this to work with the fleximage model class in a relation / association.

I have a User model and a Image model.
class User < ActiveRecord::Base
belongs_to: image
end

class Image < ActiveRecord::Base
acts_as_fleximage :image_directory => 'public/images/uploaded_photos'
end

Can you please give an example of how the Upload form (view) for this should look like for this scenario?
Maybe this is something obvious, but I would love to see something about associations in the documentation.

I would like to reuse the Image model in a generic way for other objects too.

Thanks
Christoph

JPEG mime registration generates warning when used as a gem

When using fleximage as a gem a warning is generated by the registration of the image/jpeg mime type and its alias image/pjpeg. I think this warning is also generated when installed as a plugin but its swallowed during the initial plugin loading. Also looking at the code for register_alias it's the wrong method - it should be registered as a mime type synonym. My fault since I added it in the first place.

Anyway a fix for this can be found in this commit.

Migrate from legacy system to fleximage via image urls

Hi,
is it possible to migrate from a legacy system to fleximage by importing all images via full urls to the images?

Actually I thought about putting the full url of the image into the image_filename column of my users table and that Fleximage would render that image also remotly...maybe fetching the image on the first hit.

Or is there maybe a rake task for this?

What process would you suggest for applications where you don't start from scatch and already have a bunch of images for your model object?

Thanks
Christoph

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.