Module: Dragonfly::GeometryBridge
- Defined in:
- lib/dragonfly/geometry_bridge.rb
Overview
Translates legacy ImageMagick geometry strings (e.g. "300x300#c",
"300x300^", "640x>") into libvips/Dragonfly option hashes so
historical cached URLs continue to render after the move to libvips.
Class Method Summary collapse
-
.translate(geometry, opts) ⇒ Array(String, Hash)
Converts an ImageMagick fill geometry into libvips crop options.
Class Method Details
.translate(geometry, opts) ⇒ Array(String, Hash)
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dragonfly/geometry_bridge.rb', line 33 def translate(geometry, opts) return [geometry, opts] unless geometry.is_a?(String) match = geometry.match(/\A(?<dims>\d*x\d*)(?:#[A-Za-z]*|\^)\z/) return [geometry, opts] unless match new_opts = opts.dup = new_opts.fetch(:thumbnail_options, {}).dup [:crop] ||= :centre new_opts[:thumbnail_options] = [match[:dims], new_opts] end |