Sha256: b5962a520400c7865925493a92f9bfdef3a623714e3708fe129b6325ec33d874
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
require 'open3' require 'letter_avatar/version' require 'letter_avatar/configuration' require 'letter_avatar/avatar' require 'letter_avatar/avatar_helper' require 'letter_avatar/colors' module LetterAvatar extend LetterAvatar::Configuration class ExecutionError < StandardError; end def self.setup(&_block) yield(self) end def self.resize(from, to, width, height) execute( # NOTE: ORDER is important! %W( convert #{from} -background transparent -gravity center -thumbnail #{width}x#{height}^ -extent #{width}x#{height} -unsharp 2x0.5+0.7+0 -quality 98 #{to} ).join(' ') ) true rescue false end def self.generate(username, size) Avatar.generate(username, size) end def self.execute(cmd) cmd = cmd.join(' ') if cmd.is_a?(Array) if Gem.win_platform? cmd.tr!("'", '"') end _stdout_str, err = Open3.capture3(cmd) if !err.nil? && !err.empty? raise ExecutionError.new("letter_avatar execution error (when calling '#{cmd}'): '#{err.strip}'") end true end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
letter_avatar-0.3.4 | lib/letter_avatar.rb |
letter_avatar-0.3.3 | lib/letter_avatar.rb |