class ImageParadise::ToPng

Public Class Methods

new( i = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/image_paradise/toplevel_methods/to_png.rb, line 26
def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_input(i)
  run if run_already
end

Public Instance Methods

input?() click to toggle source
#

input?

#
# File lib/image_paradise/toplevel_methods/to_png.rb, line 81
def input?
  @input
end
reset() click to toggle source
#

reset (reset tag)

#
# File lib/image_paradise/toplevel_methods/to_png.rb, line 38
def reset
end
run() click to toggle source
#

run

#
# File lib/image_paradise/toplevel_methods/to_png.rb, line 88
def run # (run tag)
  run_everything
end
run_everything() click to toggle source
#

run_everything

This method contains the main logic of the file.

#
# File lib/image_paradise/toplevel_methods/to_png.rb, line 63
def run_everything
  @input.each {|this_file|
    store_where = store_where?(this_file)
    opn; e 'Next converting '+simp(this_file)+' to '+sfile(store_where)
    _ = 'convert '+this_file+' '+store_where
    esystem _
    if File.exist? store_where
      opn; e 'We will next try to optimize '+sfile(store_where)
      opn; e 'The old file size is: '+sfancy(File.size(store_where).to_s)
      ::ImageParadise::Optimizer[store_where]
      opn; e 'The new file size is: '+sfancy(File.size(store_where).to_s)
    end
  }
end
set_input(i = '') click to toggle source
#

set_input

#
# File lib/image_paradise/toplevel_methods/to_png.rb, line 44
def set_input(i = '')
  i = [i].flatten.compact
  @input = i
end
store_where?( i = @input ) click to toggle source
#

store_where?

#
# File lib/image_paradise/toplevel_methods/to_png.rb, line 52
def store_where?(
    i = @input
  )
  i.gsub(File.extname(i),'')+'.png'
end