Created
September 4, 2012 10:29
-
-
Save kkung/3619802 to your computer and use it in GitHub Desktop.
This file contains 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
from wand.api import * | |
from wand.color import Color | |
import ctypes | |
res = libmagick.NewMagickWand() | |
libmagick.MagickReadImage( | |
res, | |
'test/img/387062_352291954856564_1975342188_n.jpeg') | |
draw = libmagick.NewDrawingWand() | |
libmagick.DrawSetFont( | |
draw, | |
'test/font/SeoulHangangM.ttf') | |
libmagick.DrawSetFontSize( | |
draw, | |
20.0) | |
color = Color("#333333") | |
with color as black: | |
libmagick.DrawSetFillColor(draw, black.resource) | |
result = libmagick.MagickAnnotateImage( | |
res, | |
draw, | |
100, | |
100, | |
0, | |
"Hello Magick!") | |
print ">> %d" % result | |
libmagick.MagickSetImageFormat(res, "JPEG") | |
libmagick.MagickResetIterator(res) | |
length = ctypes.c_size_t() | |
blob_p = libmagick.MagickGetImageBlob(res, ctypes.byref(length)) | |
if blob_p and length.value: | |
blob = ctypes.string_at(blob_p, length.value) | |
libmagick.MagickRelinquishMemory(blob_p) | |
fp = open('hello.jpg', 'w') | |
fp.write(blob) | |
fp.close() | |
print 'Hee ho!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment