Module: Drakkon::Images::Biggest
- Defined in:
- lib/drakkon/lib/images/biggest.rb
Overview
General Image Index Helper
Class Method Summary collapse
- .images ⇒ Object
- .process(file) ⇒ Object
- .prompt ⇒ Object
- .run!(_args = []) ⇒ Object
- .start ⇒ Object
Class Method Details
.images ⇒ Object
34 35 36 |
# File 'lib/drakkon/lib/images/biggest.rb', line 34 def self.images Dir["#{Dir.pwd}/**/*.png"] end |
.process(file) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/drakkon/lib/images/biggest.rb', line 23 def self.process(file) # LogBot.info('Image Biggest', file) img = MiniMagick::Image.open(file) { file: File.basename(file), w: img.width, h: img.height } end |
.prompt ⇒ Object
38 39 40 |
# File 'lib/drakkon/lib/images/biggest.rb', line 38 def self.prompt TTY::Prompt.new(active_color: :cyan, interrupt: :exit) end |
.run!(_args = []) ⇒ Object
5 6 7 |
# File 'lib/drakkon/lib/images/biggest.rb', line 5 def self.run!(_args = []) start end |
.start ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/drakkon/lib/images/biggest.rb', line 9 def self.start LogBot.info('Image Biggest Index') index = images.map do |img| process(img) end img_w = index.max_by(&:w) img_h = index.max_by(&:h) puts "Largest Sizes: { w: #{img_w.w}, h: #{img_h.h} }" puts " Width: #{img_w}" puts " Height: #{img_h}" end |