Skip to content

Instantly share code, notes, and snippets.

@Eric-Guo
Created March 13, 2017 17:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Eric-Guo/a30e9bbe2bfeabf9c9597a192aec9d0a to your computer and use it in GitHub Desktop.
Save Eric-Guo/a30e9bbe2bfeabf9c9597a192aec9d0a to your computer and use it in GitHub Desktop.
Add Chinese text and logo as overlay picture via mini_magick
# 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 38
c.draw "text 360,145 'Ruby语言'"
c.fill 'red'
end
outimage = image.composite(MiniMagick::Image.open('overlay.jpg')) do |c|
c.compose 'Over'
c.geometry '+246+90'
end
outimage.write('origin_output.jpg')
puts 'ok'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment