Skip to content

Instantly share code, notes, and snippets.

@kkung
Created September 4, 2012 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkung/3619802 to your computer and use it in GitHub Desktop.
Save kkung/3619802 to your computer and use it in GitHub Desktop.
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