Class: WebMagick
Instance Method Summary collapse
Instance Method Details
#create_thumbnail_fit(image_url, width, height, fill = "black") ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/web_magick.rb', line 8 def create_thumbnail_fit(image_url, width, height, fill="black") black_fill = GradientFill.new(0, 0, 0, 0, "#000000", "#000000") back = Image.new(width, height, black_fill) f = open(image_url) photo = Image.from_blob(f.read).first f.close photo = photo.resize_to_fit(width, height) back.composite(photo, CenterGravity, OverCompositeOp) end |