0

I have model with user-uploaded images which can vary in dimensions. On an index page, there's a space for each image (70px height max and 100px width max).

I want to use Paperclip to resize to these restrictions without losing the aspect ratio.

Scenarios:

A) 140px height, 60px width would resize to 70px height 30px width

B) 40px height and 200px width would resize to 100px width and 20px height

How do I do this with paperclip? I'm assuming this is better practice to optimize the file size rather than controlling a larger image with css.

MZaragoza
  • 10,108
  • 9
  • 71
  • 116
UserDuser
  • 461
  • 4
  • 18

1 Answers1

0
  class User < ActiveRecord::Base
    has_attached_file :avatar, :styles => { :small => "70x100>" }
  end

take a look at the > at after the 100 this set it at max

I hope that this helps

Happy Hacking

MZaragoza
  • 10,108
  • 9
  • 71
  • 116