Mani
Mani

Reputation: 2563

Carrierwave resize_to_fit not working as expected

Hi i'm trying to resize an image to a size of width 1135px and auto height(so that i can resize it in css) . and for this i'm adding following line in uploader

  version :large_cover_photo do
      resize_to_fit(1135, 10000)
  end

Same goes for .

  version :large_cover_photo do
      resize_to_fit(1135, 0)
  end

  version :large_cover_photo do
      resize_to_fit(1135, nil)
  end

Even if i specify to 300px height in uploader. it does not work This is resizing image to width 1135px but height not working accordingly . and if i try to resize height through css , it's making significance difference on width too . kindly have a look on images attached enter image description here

This second image is when i resize it through inline css(not touching widht in css)

enter image description here

Upvotes: 1

Views: 1559

Answers (3)

Mani
Mani

Reputation: 2563

  version :large_cover_photo do
    process resize_to_fill: [1135,300]
  end

Note the key word process it will do the trick

Upvotes: 1

Tan Nguyen
Tan Nguyen

Reputation: 3376

Did you try: resize_to_fill instead of resize_to_fit

Upvotes: 0

Moataz Zaitoun
Moataz Zaitoun

Reputation: 727

According to carrierwave's documentation here, I think you should use Square Brackets [ ] instead of usual brackets () when defining versions, So your code should be like...

version :large_cover_photo do
  resize_to_fit: [1135, 10000]
end

Upvotes: 0

Related Questions