Developer Wiki

In-depth guide for developers to create stencils and templates

Drawing Images

A Pencil shape may contain some bitmap images. This tutorial will show how to embed an image to a stencil.

Suppose that we have a bitmap image of a hand and we would like to create a stencil of the hande image with an editable name text.

The first thing you have to do is to convert the image into BASE64 format which is supported by Pencil for embedding binary data. There are many ways for converting an image into BASE64, the method shown below is for the case you are working on a GNU/Linux box:

$ base64 --wrap=0 hand.png 

After doing the conversion, you can copy the output and use it as in the below XML code:

<Shape id="image" displayName="Image" icon="Icons/image.png">
      <Property name="box" type="Dimension" p:lockRatio="true">36,45</Property>
    <PropertyGroup name="Text">
      <Property name="name" displayName="Name"
                type="PlainText">Hello World</Property>
      <Property name="textColor" displayName="Color"
      <Property name="textFont" displayName="Font"
    <For ref="image">
    <For ref="name">
        <Arg>new Bound(0, $box.h + 13, $box.w, 13)</Arg>
        <Arg>new Alignment(1, 1)</Arg>
  <p:Content xmlns:p="" xmlns="" xmlns:xlink="">
    <image id="image" x="0" y="0"
      xlink:href="data:image/png;base64,iVBORw0KGgo... (BASE64 content of the image)" />
    <text id="name" />

Note that the BASE64 content of the image is here used in the xlink:href attribute of SVG image as a URL in the form of Data URL scheme.