Resizing to fill a space

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Moosa
Posts: 2
Joined: 2014-09-03T22:56:21-07:00
Authentication code: 6789

Resizing to fill a space

Post by Moosa »

I have thumbnail product images that are in different aspect ratios and sizes. This is a marketplace app so sellers will load images in various sizes. I want to resize to make them fit within the 200x200 thumbnail grid that I have. i.e. if the aspect ratio is not square, fill the blank space so the image is 200x200.

I'm on Rails 4, Paperclip 4.1, Imagemagick 6.8.9

Based on an earlier version of IM, this is the effect I want - http://www.imagemagick.org/Usage/resize/#space_fill - See the problem with alignment on my demo site here - http://mktdemo.herokuapp.com
Can someone help with what convert options I should use below. Here is my rails model code. I tried playing with some options but didn't get it to align as I wanted. The swap+ option as outlined in the link above doesn't work in newer versions.

Code: Select all

has_attached_file :image, 
                  :styles => { :medium => "200x200", :thumb => "100x100" },
                  :default_url => ""
                  :convert_options => {:medium => ???}
Moosa
Posts: 2
Joined: 2014-09-03T22:56:21-07:00
Authentication code: 6789

Re: Resizing to fill a space

Post by Moosa »

Got it from another post.

Here is what worked for me.

Code: Select all

has_attached_file :image, 
						  :styles => { :medium => "250x250", :thumb => "100x100" },
						  :default_url => "",
						  :convert_options => {:medium => '-background white -gravity center -extent 250x250',
						                       :thumb => '-background white -gravity center -extent 100x100' }
Post Reply