class ImageVise::FitCrop

Fits the image based on the smaller-side fit. This means that the image is going to be fit into the requested rectangle so that all of the pixels of the rectangle are filled. The gravity parameter defines the crop gravity (on corners, sides, or in the middle).

The corresponding Pipeline method is `fit_crop`.

Constants

GRAVITY_PARAMS

Public Class Methods

new(*) click to toggle source
Calls superclass method
# File lib/image_vise/operators/fit_crop.rb, line 19
def initialize(*)
  super
  self.width = width.to_i
  self.height = height.to_i
  raise ArgumentError, ":width must positive" unless width > 0
  raise ArgumentError, ":height must positive" unless height > 0
  raise ArgumentError, ":gravity must be within the permitted values" unless GRAVITY_PARAMS.key? gravity
end

Public Instance Methods

apply!(magick_image) click to toggle source
# File lib/image_vise/operators/fit_crop.rb, line 28
def apply!(magick_image)
  magick_image.resize_to_fill! width, height, GRAVITY_PARAMS.fetch(gravity)
end