Class: UserapiAi::Tool

Inherits:
Object
  • Object
show all
Defined in:
lib/userapi/tools.rb

Class Method Summary collapse

Class Method Details

.crop(url: nil, result: nil) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/userapi/tools.rb', line 3

def self.crop url: nil, result: nil
    url = result["url"] if url.nil?
    image = MiniMagick::Image.open url
    image.crop "50%x50%"
    arr = image.path.split(".")
    (0..3).map{ |i|
      arr.dup.insert(-2, "-#{i}.").join("")
    }
end