module Gif2lgtm::Main
Constants
- LOOP_COUNT
Public Instance Methods
compsite(img_path)
click to toggle source
# File lib/gif2lgtm/main.rb, line 10 def compsite(img_path) gif = Magick::ImageList.new images = Magick::ImageList.new(img_path) orig_size_lgtm = Magick::ImageList.new(File.expand_path('../../images/lgtm.png', __dir__)) lgtm = orig_size_lgtm.resize_to_fit(images.first.columns, images.first.rows) images.each do |image| gif.push( Magick::Image.from_blob(image.to_blob)[0].composite( lgtm, Magick::CenterGravity, Magick::OverCompositeOp)) end gif end
create(gif, img_path)
click to toggle source
# File lib/gif2lgtm/main.rb, line 27 def create(gif, img_path) gif.iterations = LOOP_COUNT result_path = "#{File.dirname(img_path)}/lgtm#{SecureRandom.hex(5)}_#{File.basename(img_path)}" gif.optimize_layers(Magick::OptimizeLayer).write(result_path) puts <<~MESSAGE ======================================================= Lgtm created. path: #{result_path} ======================================================= MESSAGE end
start(img_path)
click to toggle source
# File lib/gif2lgtm/main.rb, line 6 def start(img_path) create(compsite(img_path), img_path) end