keep ratio when image is bigger or smaller

when image is smaller, creates a border around.
when image is bigger, crops the image to keep ratio