This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <AppKit/AppKit.h> | |
@interface NSImage (DrawAttributedString) | |
+ (NSImage *)imageWithAttributedString:(NSAttributedString *)attributedString | |
backgroundColor:(NSColor *)backgroundColor; | |
+ (NSImage *)imageWithAttributedString:(NSAttributedString *)attributedString; | |
+ (NSImage *)imageWithString:(NSString *)string; | |
@end |