The problem # Automate compression of web assets. What we need # Get your TinyPNG API key here gem install tinify gem install tiny_png_checker gem install optparse The solution # #!/usr/bin/env ruby # frozen_string_literal: true # tinyficator.rb require 'tinify' require 'optparse' require 'tiny_png_checker' # NOTE: Requires Ruby 2.5 or greater. Tinify.key = '<YOUR_API_KEY_GOES_HERE>' Tinify.validate! def usage puts 'Usage: ' + __FILE__ + ' [options]' \ "\r\nOptions:\r\n" \ " --src DIRECTORY\tSource directory\r\n" \ " --dst DIRECTORY\tDestination directory" exit end def parse_options cwd = File.