<commit_before>require 'fastimage'

module Frameit
  class Editor
    module Color
      BLACK = "SpaceGray"
      SILVER = "Slvr"
    end

    module Orientation
      PORTRAIT = "Vert"
      LANDSCAPE = "Horz"
    end


    def initialize
      FrameConverter.new.run
    end

    def run(path, color = Color::BLACK)
      @color = color

      Dir["#{path}/**/*.png"].each do |screenshot|
        next if screenshot.include?"_framed.png"
        begin
          template_path = get_template(screenshot)
          if template_path
            template = MiniMagick::Image.open(template_path)
            image = MiniMagick::Image.open(screenshot)

            offset_information = image_offset(screenshot)
            raise "Could not find offset_information for '#{screenshot}'" unless (offset_information and offset_information[:width])
            width = offset_information[:width]
            image.resize width

            result = template.composite(image) do |c|
              c.compose "Over"
              c.geometry offset_information[:offset]
            end

            output_path = screenshot.gsub('.png', '_framed.png')
            result.write output_path
            Helper.log.info "Successfully framed screenshot at path '#{output_path}'".green
          end
        rescue Exception => ex
          Helper.log.error ex
        end
      end
    end<commit_msg>Added support for PNG files (upper case)<commit_after>require 'fastimage'

module Frameit
  class Editor
    module Color
      BLACK = "SpaceGray"
      SILVER = "Slvr"
    end

    module Orientation
      PORTRAIT = "Vert"
      LANDSCAPE = "Horz"
    end


    def initialize
      FrameConverter.new.run
    end

    def run(path, color = Color::BLACK)
      @color = color

      Dir.glob("#{path}/**/*.{png,PNG}").each do |screenshot|
        next if screenshot.include?"_framed.png"
        begin
          template_path = get_template(screenshot)
          if template_path
            template = MiniMagick::Image.open(template_path)
            image = MiniMagick::Image.open(screenshot)

            offset_information = image_offset(screenshot)
            raise "Could not find offset_information for '#{screenshot}'" unless (offset_information and offset_information[:width])
            width = offset_information[:width]
            image.resize width

            result = template.composite(image) do |c|
              c.compose "Over"
              c.geometry offset_information[:offset]
            end

            output_path = screenshot.gsub('.png', '_framed.png').gsub('.PNG', '_framed.png')
            result.write output_path
            Helper.log.info "Successfully framed screenshot at path '#{output_path}'".green
          end
        rescue Exception => ex
          Helper.log.error ex
        end
      end
    end
{'fraction_non_alphanumeric': 0.09167842031029619, 'fraction_numerical': 0.0, 'mean_word_length': 2.103938730853392, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4700220', 'n_tokens_mistral': 809, 'n_tokens_neox': 771, 'n_words': 190}