Paperclip Resizing options…

Paperclip allows us to specify image dimensions in theĀ  model iteself. This makes life very simple in cases where we only want image resizing.

Here is a list of things we can do to get the best out of it….

Please note : it applies to image magick also.

The basic specification is <width>x<height> in pixels, optionally followed by a modifier. In some cases you can omit either width or height.

    • 256×256
      This specifies the Maximum dimensions for the image, while preserving the aspect ratio of the image. So if your image were actually 512×256 it would be resized to 256×128 in order to fit inside the specified size.
    • 256×256!
      This specifies the Exact image size, so a 512×256 image would be changed into 256×256, losing the aspect ratio.
    • 256x
      This specifies the desired width of the target image, leaving the height to be set so as to preserve the aspect ratio.

 

    • x256
      This specifies the desired height of the target image, while preserving the aspect ratio.
    • 256×256^
      This specifies the Minimum size for the target image, so the resized image may be larger than these dimensions.
    • 256×256>
      This specifies that the image will be resized only if it is Larger than the dimensions.
    • 256×256<
      This specifies that the image will be resized only if it is Smaller than the dimensions.