If I interpret the question correctly:
for a portrait image (say 480px wide, 640px high) you would want to scale it down to 220px wide, then crop it down to 220px high, resulting in a square image.
for a landscape image, you would want to scale it down to 220px wide (the height would therefore be less than 220px).
If that's right, you want a two-step process:
- Resize to 220px wide, preserving the aspect ratio
- Crop to 220px high (if portrait)
You can do so by writing your own processor using the manipulate!
command (see CarrierWave's own for some inspiration).
I think this is roughly what you're after
process :resize => [220, 220]
protected
def resize(width, height, gravity = 'Center')
manipulate! do |img|
img.combine_options do |cmd|
cmd.resize width.to_s
if img[:width] < img[:height]
cmd.gravity gravity
cmd.background "rgba(255,255,255,0.0)"
cmd.extent "#{width}x#{height}"
end
end
img = yield(img) if block_given?
img
end
end