Carrierwave and mini_magick finding widths & height

后端 未结 4 1030
慢半拍i
慢半拍i 2021-02-06 12:30

After a bit of investigation I decided to use Carrierwave and mini_magick on my new rail3 app.

I\'ve set it up and it works perfectly. However I have a one question. I\

4条回答
  •  逝去的感伤
    2021-02-06 12:48

    class Attachment
      mount_uploader :file, FileUploader
    
      def image
        @image ||= MiniMagick::Image.open(file.path)
      end
    end
    

    And use it like this:

    Attachment.first.image['width'] # => 400
    Attachment.first.image['height'] # => 300
    

提交回复
热议问题