Module: Paperclip::Commands::ImageMagick::GeometryParser
- Extended by:
- GeometryParser
- Included in:
- GeometryParser
- Defined in:
- lib/paperclip/commands/imagemagick/geometry_parser.rb
Constant Summary collapse
- FORMAT =
/\b(\d*)x?(\d*)\b(?:,(\d?))?(@>|>@|[><#@%^!])?/i.freeze
Instance Method Summary collapse
-
#detect(file) ⇒ Object
(also: #from_file)
Runs
magick identifyand returns a Paperclip::Geometry. -
#parse(string) ⇒ Object
Parses a "WxH,O" string into a Paperclip::Geometry.
Instance Method Details
#detect(file) ⇒ Object Also known as: from_file
Runs magick identify and returns a Paperclip::Geometry
12 13 14 |
# File 'lib/paperclip/commands/imagemagick/geometry_parser.rb', line 12 def detect(file) parse(fetch(file)) end |
#parse(string) ⇒ Object
Parses a "WxH,O" string into a Paperclip::Geometry
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/paperclip/commands/imagemagick/geometry_parser.rb', line 18 def parse(string) return unless (match = string&.strip&.match(FORMAT)) Paperclip::Geometry.new( width: match[1], height: match[2], orientation: match[3], modifier: match[4] ) end |