Skip to content

Instantly share code, notes, and snippets.

@Eric-Guo
Created March 13, 2017 12:28
Show Gist options
  • Save Eric-Guo/486dca564d820f95e0811fe59d0fd856 to your computer and use it in GitHub Desktop.
Save Eric-Guo/486dca564d820f95e0811fe59d0fd856 to your computer and use it in GitHub Desktop.
Using MiniMagick to add text to a picture
# encoding: utf-8
require 'mini_magick'
image = MiniMagick::Image.open('origin.jpg')
image.combine_options do |c|
c.font '/Library/Fonts/Songti.ttc'
c.pointsize 28
c.gravity 'Center'
c.pointsize '22'
c.draw "text 3,3 'Ruby语言'"
c.fill 'red'
end
image.write('origin_output.jpg')
puts 'ok'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment