Skip to content

Instantly share code, notes, and snippets.

View younthu's full-sized avatar

Andrew Yang younthu

View GitHub Profile
@Eric-Guo
Eric-Guo / add_text_picture.rb
Created March 13, 2017 17:22
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|
@GenjiApp
GenjiApp / NSImage+DrawAttributedString.h
Created December 25, 2011 07:07
NSImage's category for drawing attributed string
#import <AppKit/AppKit.h>
@interface NSImage (DrawAttributedString)
+ (NSImage *)imageWithAttributedString:(NSAttributedString *)attributedString
backgroundColor:(NSColor *)backgroundColor;
+ (NSImage *)imageWithAttributedString:(NSAttributedString *)attributedString;
+ (NSImage *)imageWithString:(NSString *)string;
@end