Register now and start sharing your code snippets.
-->

How to add a text caption to an image with MiniMagick and Ruby

Ruby posted 5 months ago by christian

   1  require 'rubygems'
   2  require 'mini_magick'
   3  
   4  img = MiniMagick::Image.from_file("jpeg.jpg")
   5  
   6  img.combine_options do |c|
   7    c.gravity 'Southwest'
   8    c.draw 'text 10,10 "whatever"'
   9    c.font '-*-helvetica-*-r-*-*-18-*-*-*-*-*-*-2'
  10    c.fill("#FFFFFF")
  11  end
  12  
  13  img.write("new.jpg")

Tagged mini_magick, ruby, caption, text