Basic image resizing in Ruby on Rails

前端 未结 5 1747
不思量自难忘°
不思量自难忘° 2020-12-06 01:45

I\'m creating a little photo sharing site for our home\'s intranet, and I have an upload feature, which uploads the photo at original size into the database. However, I also

5条回答
  •  粉色の甜心
    2020-12-06 02:19

    I tried following way. Its working fine. I hope it will help to some one.

    1.add following gem in Gemfile:

    gem "ImageResize", "~> 0.0.5"
    

    2.run bundle

    3.use this in controller function:

    require 'rubygems'
    require 'ImageResize'
    
    #input_image_filename, output_image_filename, max_width, max_height
    Image.resize('big.jpg', 'small.jpg', 40, 40)
    

提交回复
热议问题