Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Resize_to_fill with Mini Magick adds 1 pixel white border #694

jebw opened this Issue · 9 comments

6 participants


When resizing a 680x420px jpeg image to 80x49 using resize_to_fill with mini_magick a 1px white line is added to the left side of the image.

This is caused by the mogrify command actually resizing the image to 79pixels wide - the original command is

"mogrify -resize "80x49" -gravity "Center" -extent "80x45" /var/folders/6w/c3syy8g559g1vmkvcdn39l840000gn/T/mini_magick20120411-996-n6fw17-0.jpg"

This occurs on both Ubuntu 10.04 and Mac OS X (homebrew installed image magick)

Removing the extent and gravity options will actually resize the image to 79 pixels wide.

Changing the original command to only supply either an X resize or Y resize resolves this, retaining the full extent command.


Potential fix at



Care to work up a pull request? I'm not too familiar with MiniMagick, but maybe someone else can have a look before merging.


I wasn't entirely convinced of my logic (though the code seems to be working well enough). I'll have a look back over it and submit a pull request if I think its right.

Are there any code submission requirements (ie tests?) - its manually tested at the moment, since it was a visual defect.


Thanks! If you can come up with a way to test that makes sense, please do. Otherwise, just check your logic carefully and remember lots of people are going to use this, so please be careful! :)


Hi guys, i'm also having this same problem? @jebw did you get a chance to test this out?

If not then I can test this for the images of one of my apps. Would be good to get this into master :P


@jebw awesome; thanks.

@bensie bensie closed this


I've been using v0.6.2 of this gem for a while.
I updated to the last version and found out that resize_to_fill doesn't work as it was working before.
(You can see the difference below)

The problem is that I need to crop images in the old way, without white borders.
For now I reverted to v0.6.2., but I'm curious - How could I have the crop from v0.6.2. using latest carrierwave?

thumb_23740 1


Run into the same issue as @scarfaceDeb
This is what I use to solve it (basically the old code)

module ImageProcessing
    def resize_to_fill(width, height, gravity = 'Center')
      manipulate! do |img|
        cols, rows = img[:dimensions]
        img.combine_options do |cmd|
          if width != cols || height != rows
            scale = [width/cols.to_f,  height/rows.to_f].max
            cols = (scale * (cols + 0.5)).round
            rows = (scale * (rows + 0.5)).round
            cmd.resize "#{cols}x#{rows}"
          cmd.gravity gravity
          cmd.background "rgba(255,255,255,0.0)"
          cmd.extent "#{width}x#{height}" if cols != width || rows != height

# app/uploaders/my_uploader.rb
class MyUploader < CarrierWave::Uploader::Base
  include CarrierWave::MiniMagick
  include ImageProcessing

  version :thumb do
    # ...
    resize_to_fill(100, 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.