Module: Drakkon::Images::Biggest

Defined in:
lib/drakkon/lib/images/biggest.rb

Overview

General Image Index Helper

Class Method Summary collapse

Class Method Details

.imagesObject



32
33
34
# File 'lib/drakkon/lib/images/biggest.rb', line 32

def self.images
  Dir["#{Dir.pwd}/**/*.png"]
end

.process(file) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/drakkon/lib/images/biggest.rb', line 22

def self.process(file)
  # LogBot.info('Image Biggest', file)
  img = MiniMagick::Image.open(file)

  {
    w: img.width,
    h: img.height
  }
end

.promptObject



36
37
38
# File 'lib/drakkon/lib/images/biggest.rb', line 36

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

.startObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/drakkon/lib/images/biggest.rb', line 9

def self.start
  index = []
  LogBot.info('Image Biggest Index')
  images.each do |img|
    index.push process(img)
  end

  w = index.max_by(&:w).w
  h = index.max_by(&:h).h

  puts "Largest Size is: { w: #{w}, h: #{h} }"
end