Module: Imgproxy::OptionsCasters::Crop

Defined in:
lib/imgproxy/options_casters/crop.rb

Overview

Casts ‘crop` processing/info option

Class Method Summary collapse

Class Method Details

.cast(raw) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/imgproxy/options_casters/crop.rb', line 13

def self.cast(raw)
  return raw unless raw.is_a?(Hash)
  return unless raw[:width] || raw[:height]

  [
    Imgproxy::OptionsCasters::Float.cast(raw[:width]) || 0,
    Imgproxy::OptionsCasters::Float.cast(raw[:height]) || 0,
    Imgproxy::OptionsCasters::Gravity.cast(raw[:gravity]),
  ].trim!
end