I have been trying to use Imagemagick to resize images uploaded by a user as a square.
Currently, I am using the ! like so - 640x640!
This works fine if the image i feed it is a resolution of 640x640 or bigger - it resizes and makes it into a square as expected.
The problem is that if either the height or width of the image is smaller than 640, then it wont square it out. For instance if the image is 480x600, it wont do anything to the image. Similarly if the image is 680x456 then it will resize it to 640x456
How can i make it so that it will always square the image to a maximum size of 640x640? If the image is greater than 640x640, then i want it to resize to 640x640. If the image is smaller than 640x640, i.e. 480x600, i want it to resize to 480x480
I'm doing it in rails, within the paperclip attachment definition, like this:
has_attached_file :avatar, :styles => { :medium => "640x640!", :thumb => "150x150!" }, :default_url => "/images/:style/missing.png"
ImageMagick
commands – Richard Peckobject-fit
CSS property. Maybe it's simpler that way and covers your need. – arieljuod