lib/two_captcha/client.rb
def load_captcha(options)
      if options[:raw64]
        options[:raw64]
      elsif options[:raw]
        Base64.encode64(options[:raw])
      elsif options[:file]
        Base64.encode64(options[:file].read)
      elsif options[:path]
        Base64.encode64(File.open(options[:path], 'rb').read)
      elsif options[:url]
        Base64.encode64(TwoCaptcha::HTTP.open_url(options[:url]))
      else
        fail TwoCaptcha::ArgumentError, 'Illegal image format'
      end
    rescue
      raise TwoCaptcha::InvalidCaptcha
    end
def load_captcha(options)
      if options[:raw64]
        options[:raw64]
      elsif options[:raw]
        Base64.encode64(options[:raw])
      elsif options[:file]
        Base64.encode64(options[:file].read)
      elsif options[:path]
        Base64.encode64(File.open(options[:path], 'rb').read)
      elsif options[:url]
        Base64.encode64(TwoCaptcha::HTTP.open_url(options[:url]))
      else
        fail TwoCaptcha::ArgumentError, 'Illegal image format'
      end
    rescue
      raise TwoCaptcha::InvalidCaptcha
    end
Load a captcha raw content encoded in base64 from options.

 @param [Hash] options Options hash.
 @option options [String]  :url   URL of the image to be decoded.
 @option options [String]  :path  File path of the image to be decoded.
 @option options [File]    :file  File instance with image to be decoded.
 @option options [String]  :raw   Binary content of the image to bedecoded.
 @option options [String]  :raw64 Binary content encoded in base64 of the
                                  image to be decoded.

 @return [String] The binary image base64 encoded.