Module: CatpixMini
- Defined in:
- lib/catpix_mini.rb,
lib/catpix_mini/private.rb,
lib/catpix_mini/version.rb
Overview
Copyright © 2015 Radek Pazdera <[email protected]> Distributed under the MIT License (see LICENSE.txt)
Constant Summary collapse
- VERSION =
Version of the gem
"0.1.1"
Class Method Summary collapse
-
.print_image(path, options = {}) ⇒ Object
Print an image to the terminal.
Class Method Details
.print_image(path, options = {}) ⇒ Object
Print an image to the terminal.
All formats supported by ImageMagick are supported. The image’s colours will be mapped onto the extended 256 colour palette. Also by default, it will be scaled down to fit the width of the terminal while keeping its proportions. This can be changed using the ‘options` parameter.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/catpix_mini.rb', line 51 def self.print_image(path, ={}) = .merge! if [:resolution] == 'auto' [:resolution] = can_use_utf8? ? 'high' : 'low' end @@resolution = [:resolution] img = load_image path resize! img, [:limit_x], [:limit_y] margins = get_margins img, [:center_x], [:center_y] margins[:colour] = [:bg_fill] ? [:bg] : nil if high_res? do_print_image_hr img, margins, else do_print_image_lr img, margins, end end |