Module: Dragonfly::GeometryBridge
- Defined in:
- lib/dragonfly/geometry_bridge.rb
Overview
Translates legacy ImageMagick geometry strings (e.g. "300x300#c",
"640>x") into libvips/Dragonfly option hashes so historical cached
URLs and older callers continue to render correctly after the move
to libvips. See the file header for the full mapping.
Class Method Summary collapse
Class Method Details
.translate(geometry, opts) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dragonfly/geometry_bridge.rb', line 23 def translate(geometry, opts) return [geometry, opts] unless geometry.is_a?(String) match = geometry.match(/\A(?<dims>\d*x\d*)#(?<gravity>[A-Za-z]+)?\z/) return [geometry, opts] unless match new_opts = opts.dup new_opts[:thumbnail_options] ||= {} new_opts[:thumbnail_options][:crop] ||= :centre [match[:dims], new_opts] end |