feature parity reached
This commit is contained in:
parent
e7d93f6d80
commit
a444377f59
|
@ -1,5 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
# TODO: add recursion support to directories
|
||||||
class DirTermine
|
class DirTermine
|
||||||
|
|
||||||
attr_accessor :save_dir, :source_dir
|
attr_accessor :save_dir, :source_dir
|
||||||
|
@ -30,8 +30,7 @@ class DirTermine
|
||||||
puts 'Please enter directory containing pictures to stickerize (Leave blank for current directory)'
|
puts 'Please enter directory containing pictures to stickerize (Leave blank for current directory)'
|
||||||
dir = gets.chomp
|
dir = gets.chomp
|
||||||
dir = Dir.getwd if dir.empty?
|
dir = Dir.getwd if dir.empty?
|
||||||
puts File.expand_path(dir) + " IS ORIGIN"
|
File.expand_path(dir)
|
||||||
dir
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,11 +20,12 @@ class Stickerizer
|
||||||
image.resize '512x512'
|
image.resize '512x512'
|
||||||
image.format 'PNG'
|
image.format 'PNG'
|
||||||
image.write(save_dir + '/' + stickername(pic_file))
|
image.write(save_dir + '/' + stickername(pic_file))
|
||||||
puts "#{pic_file} | #{save_dir}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def stickername(filename)
|
def stickername(filename)
|
||||||
"#{filename[0..-5]}_sticker.png"
|
file_only = filename.sub %r{/.+/}, ''
|
||||||
|
"#{file_only[0..-5]}_sticker.png"
|
||||||
end
|
end
|
||||||
|
|
||||||
def origin_dir
|
def origin_dir
|
||||||
|
@ -36,6 +37,7 @@ class Stickerizer
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid?(file)
|
def valid?(file)
|
||||||
|
#TODO: Change this to check file types instead of relying on filenames
|
||||||
valid = false
|
valid = false
|
||||||
file_info = file_ext(file)
|
file_info = file_ext(file)
|
||||||
valid = true if file_info.extension == '.png'
|
valid = true if file_info.extension == '.png'
|
||||||
|
@ -48,9 +50,12 @@ class Stickerizer
|
||||||
def convert_images
|
def convert_images
|
||||||
origin = origin_dir
|
origin = origin_dir
|
||||||
destination = dest_dir
|
destination = dest_dir
|
||||||
|
puts "#{origin} is origin"
|
||||||
Dir.children(origin).each do |unstickerized|
|
Dir.children(origin).each do |unstickerized|
|
||||||
|
puts "#{unstickerized} OOA"
|
||||||
next unless valid?(unstickerized)
|
next unless valid?(unstickerized)
|
||||||
stickerize(unstickerized, destination)
|
|
||||||
|
stickerize("#{origin}/#{unstickerized}", destination)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue