Module: Drakkon::Images::Trim
- Defined in:
- lib/drakkon/lib/images/trim.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
46 47 48 |
# File 'lib/drakkon/lib/images/trim.rb', line 46 def self.images Dir["#{Dir.pwd}/**/*.png"] end |
.process(file) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/drakkon/lib/images/trim.rb', line 36 def self.process(file) LogBot.info('Image Trim', File.basename(file).to_s) MiniMagick::Tool::Convert.new do |convert| convert << file convert.trim convert << '+repage' convert << file end end |
.prompt ⇒ Object
50 51 52 |
# File 'lib/drakkon/lib/images/trim.rb', line 50 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 27 28 |
# File 'lib/drakkon/lib/images/trim.rb', line 5 def self.run!(_args = []) puts <<~HELP Usage - Run in the directory you wish to modify the images - Trim/Repage the images 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 unless prompt.yes? "#{'Are you sure?'.pastel(:bright_yellow)} Scale Images!? #{'(Destructive)'.pastel(:red)}" exit end start end |
.start ⇒ Object
30 31 32 33 34 |
# File 'lib/drakkon/lib/images/trim.rb', line 30 def self.start images.each do |img| process(img) end end |