在 ruby on Rails 中调整图像大小
像这样,我目前正在我的 ruby 应用程序中上传一个文件(图像)..我需要在上传后调整图像大小...请帮助调整图像大小
uploaded_io = params[:category][:thumb]
if uploaded_io != ""
name = uploaded_io.original_filename
if(FileTest.exist?("#{RAILS_ROOT}/public/data/#{name}"))
id = Category.maximum('id').to_s
id = id.to_i+ 1
name =id.to_s+"_"+name
end
谢谢
Like this I am currently uploading a file ( image ) in my ruby application .. I need to resize the image after uploading ... please help for resizing the image
uploaded_io = params[:category][:thumb]
if uploaded_io != ""
name = uploaded_io.original_filename
if(FileTest.exist?("#{RAILS_ROOT}/public/data/#{name}"))
id = Category.maximum('id').to_s
id = id.to_i+ 1
name =id.to_s+"_"+name
end
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您已经安装了 imagemagick - 那么请使用 ImageScience 或 MiniMagick,它们都使用更少的资源并且工作速度更快,并且安装就像一个常见的 gem(实际上 imagescience 的安装要多一点)
ImageScience:
MiniMagick:
If you have imagemagick already installed - then use ImageScience or MiniMagick instead, they both use much less resources and work faster, and are installed just as a common gem (actually a little bit more installation for imagescience)
ImageScience:
MiniMagick:
尝试 RMagick!
http://www.imagemagick.org/RMagick/doc/comtasks.html#thumb
Try RMagick!
http://www.imagemagick.org/RMagick/doc/comtasks.html#thumb