Module: PhotoCook::Command
- Included in:
- PhotoCook
- Defined in:
- lib/photo-cook/command.rb
Instance Method Summary collapse
-
#assemble_command(width, height, pixel_ratio, crop) ⇒ Object
NOTE: This method performs no validation.
- #bool_to_crop(crop) ⇒ Object
- #command_regex ⇒ Object
- #crop_to_bool(crop) ⇒ Object
Instance Method Details
#assemble_command(width, height, pixel_ratio, crop) ⇒ Object
NOTE: This method performs no validation
19 20 21 22 23 24 |
# File 'lib/photo-cook/command.rb', line 19 def assemble_command(width, height, pixel_ratio, crop) "width=#{ width == 0 ? 'auto' : width}&" + "height=#{ height == 0 ? 'auto' : height}&" + "pixel_ratio=#{pixel_ratio.ceil}&" + "crop=#{ bool_to_crop(crop)}&" end |
#bool_to_crop(crop) ⇒ Object
30 31 32 |
# File 'lib/photo-cook/command.rb', line 30 def bool_to_crop(crop) crop ? 'yes' : 'no' end |
#command_regex ⇒ Object
Proportional support stackoverflow.com/questions/7200909/imagemagick-convert-to-fixed-width-proportional-height
Device pixel ratio collection dpi.lv/ www.canbike.org/CSSpixels/
9 10 11 12 13 14 15 16 |
# File 'lib/photo-cook/command.rb', line 9 def command_regex @command_regex ||= %r{ width= (?<width> auto|\d{1,4}) & height= (?<height> auto|\d{1,4}) & pixel_ratio= (?<pixel_ratio>[1234]) & crop= (?<crop> yes|no) }x end |
#crop_to_bool(crop) ⇒ Object
26 27 28 |
# File 'lib/photo-cook/command.rb', line 26 def crop_to_bool(crop) crop == 'yes' end |