Module: Drakkon::Images::White

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

Overview

General Image Index Helper

Class Method Summary collapse

Class Method Details

.imagesObject



45
46
47
# File 'lib/drakkon/lib/images/white.rb', line 45

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

.process(file) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/drakkon/lib/images/white.rb', line 35

def self.process(file)
  convert = MiniMagick::Tool::Convert.new
  convert << file
  convert.colorspace('sRGB')
  convert.fill('white')
  convert.colorize(100)
  convert << file
  convert.call
end

.promptObject



49
50
51
# File 'lib/drakkon/lib/images/white.rb', line 49

def self.prompt
  TTY::Prompt.new(active_color: :cyan, interrupt: :exit)
end

.run!(_args = []) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/drakkon/lib/images/white.rb', line 5

def self.run!(_args = [])
  puts <<~HELP
    Usage
    - Run in the directory you wish to modify the images
    - Changes the colorspace to 100% white via MiniMagick

    Current Directory;
      #{Dir.pwd.pastel(:yellow)}

    Images:
  HELP

  images.sort.each do |img|
    img_s = img.gsub("#{Dir.pwd}/", '').pastel(:yellow)
    puts "  - #{img_s}"
  end
  puts

  exit unless prompt.yes? "#{'Are you sure?'.pastel(:bright_yellow)} All White!? #{'(Destructive)'.pastel(:red)}"

  start
end

.startObject



28
29
30
31
32
33
# File 'lib/drakkon/lib/images/white.rb', line 28

def self.start
  images.each do |img|
    LogBot.info('Image White', img)
    process(img)
  end
end