<commit_before>require "wf-barcodereader/version"
require 'RMagick'
require 'zbar'
module Wf
  module Barcodereader
    class Base
      # include FileUtils
      class << self
        def sharpen
          puts system 'which ls'
        end
        def process(io)
          # cmd = system 'which convert'
          # raise "Could not find convert command. Have you installed imagemagick?" unless cmd
          # begin
          #   system  "#{cmd} -unsharp 10x3+10+0 #{io} "
          # rescue Exception => e
          #   puts 'Could not process you image'
          # end

          input = Magick::Image.read(io).first
          # convert to PGM
          input.format = 'PGM'

          # load the image from a string
          image = ZBar::Image.from_pgm(input.to_blob)

          image.process.each do |result|
            puts "Code: #{result.data} - Type: #{result.symbology} - Quality: #{result.quality}"
          end
        end
      end
    end
  end<commit_msg>some stuff<commit_after>require "wf-barcodereader/version"
require 'RMagick'
require 'zbar'
module Wf
  module Barcodereader
    class Base
      # include FileUtils
      class << self

        def sharpen(io)
          extension = File.extname(io)
          File.basename(io).gsub(extension, '') + '_conv' + extension
        end
        
        def process(io)
          sharpened_file = sharpen(io)
          cmd = system 'which convert'
          raise "Could not find convert command. Have you installed imagemagick?" unless cmd
          begin
            system  "#{cmd} -unsharp 10x3+10+0 #{io} #{converted_name}"
          rescue Exception => e
            puts 'Could not process you image'
          end

          input = Magick::Image.read(sharpened_file).first
          # convert to PGM
          input.format = 'PGM'

          # load the image from a string
          image = ZBar::Image.from_pgm(input.to_blob)

          image.process.each do |result|
            puts "Code: #{result.data} - Type: #{result.symbology} - Quality: #{result.quality}"
          end
        end
      end
    end
  end
{'fraction_non_alphanumeric': 0.09346685741535526, 'fraction_numerical': 0.005722460658082976, 'mean_word_length': 1.8274932614555257, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1744043', 'n_tokens_mistral': 617, 'n_tokens_neox': 603, 'n_words': 178}