Sha256: 19ad7859b1803cdef73b299fe2415a546431423c6851c3064d5a04ca37df2774

Contents?: true

Size: 928 Bytes

Versions: 1

Compression:

Stored size: 928 Bytes

Contents

require "letter_avatar/version"
require "letter_avatar/avatar"
require "letter_avatar/avatar_helper"

module LetterAvatar

  mattr_accessor :cache_base_path
  @@cache_base_path = nil

  mattr_accessor :colors_palette
  @@colors_palette = :google

  mattr_accessor :weight
  @@weight = 300

  mattr_accessor :annotate_position
  @@annotate_position = '-0+5'

  def self.setup(&block)
    yield(self)
  end

  def self.resize(from, to, width, height)
    # NOTE: ORDER is important!
    instructions = %W{
      #{from}
      -background transparent
      -gravity center
      -thumbnail #{width}x#{height}^
      -extent #{width}x#{height}
      -interpolate bicubic
      -unsharp 2x0.5+0.7+0
      -quality 98
      #{to}
    }.join(" ")

    `convert #{instructions}`

    if $?.exitstatus == 0
      true
    else
      false
    end
  end

  def self.generate(username, size)
    Avatar.generate(username, size)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
letter_avatar-0.1.7 lib/letter_avatar.rb