in rails, paperclip has a fixed (model-based) definition of image-sizes.
has_attached_file :data,
:styles => { :large => "800x600>", :icon => "50x50#" },
:path => ":rails_root/public/images/files/:id/:style/:basename.:extension",
:url => "/images/files/:id/:style/:basename.:extension",
:convert_options => { :all => "-c开发者_运维技巧olorspace RGB" },
:whiny_thumbnails => true
but this example sets the image-dimensions to 2 types (large, icon) in 2 fixed sizes. this is nice for the most issues but not if you like to show a uploaded picture in a different size e.g. 640x480 …
is there a way to have images scaled on the fly - in rails3 ???
You can look at something like Dragonfly to process your images instead of Paperclip. It puts the sizing in the view instead of the model and utilizes some caching mechanisms to help with performance.
Scale images on the fly could kill your server ;)
If you only want to show picture, maybe you could use width and/or height attributes of html image tag?
精彩评论