Using ImageMagick (6.9.10-10) via the command line, I am able to define a stroke width and colour for a caption like so:
Code: Select all
convert -size 300x300 -stroke black -strokewidth 1 -fill white \
-background transparent -gravity center \
caption:"This is a test of the caption feature in ImageMagick" ~/out.png
I am trying to extend Wand to allow this functionality. The code for adding a caption is located in image.py in the Wand library. This file can be found here: Wand GitHub repo.
As far as I can tell, the pertinent piece of code is this:
Code: Select all
with Image() as textboard:
library.MagickSetSize(textboard.wand, width, height)
textboard.font = font
textboard.gravity = gravity or self.gravity
with Color('transparent') as background_color:
library.MagickSetBackgroundColor(textboard.wand,
background_color.resource)
textboard.read(filename=b'caption:' + text.encode('utf-8'))
self.composite(textboard, left, top)
Code: Select all
with Image() as textboard:
library.MagickSetSize(textboard.wand, width, height)
textboard.font = font
textboard.gravity = gravity or self.gravity
with Color('transparent') as background_color:
library.MagickSetBackgroundColor(textboard.wand,
background_color.resource)
with Color('black') as stroke_color:
library.DrawSetStrokeColor(textboard.wand, stroke_color.resource)
library.DrawSetStrokeWidth(textboard.wand, 2)
textboard.read(filename=b'caption:' + text.encode('utf-8'))
self.composite(textboard, left, top)
Code: Select all
Assertion failed: (wand->signature == WandSignature), function DrawSetStrokeColor, file wand/drawing-wand.c, line 5306.
I would be really grateful if someone could hint to me a viable way to solve this problem. I'm not a particularly strong programmer and I feel like I am banging my head against a wall!
Thanks,
Ivan