1.安装
在Gemfile中加入gem 'mini_magick'
并运行bundle install命令,安装依赖
2.使用并支持中文
如下:
# -*- coding: utf-8 -*-
require "mini_magick"
image_path="/home/2.jpg"
img = MiniMagick::Image.open(image_path)
@content="支持中文"
img.run_command(%Q{mogrify -strip -quality 80 -font /home/yangjunfeng/fonts/simsun.ttc -fill black -pointsize 24 -draw 'text 260,355 "#{@content}"' }+image_path)