kpg - knitting pattern generator

Convert a picture into a knitting pattern.

Table Of Contents


kpg is a free program that can create knitting patterns out of pictures. It can either create straight patterns or illusion patterns that only reveal the picture when viewed at an angle.

The knitting patterns are simple rectangles (squares) that use simple stiches, a regular "knit stitch" and optionally a "perl stitch". The patterns can be used to create large blankets or many smaller patch-work squares suitable for making a large knitted piece. Experienced knitters are able to take the simple square knitting patterns and integrate them into more complex pieces such as jumpers/sweaters.

kpg can take any kind of bitmap image and create a knitting pattern. It is recommended that low colour images/pictures be used to ensure the knitting process is as simple as possible. It is possible to use a black and white picture and create a pattern using only one colour and using different stitches for the picture. Examples below.

kpg is the only free open source tool I know of to create knitting patterns. Essentially a png2knitting_pattern converter. In theory the patterns kpg generates could be used for crochet (with minor modification).


Road map ideas include run as cgi and generating intarsia knitting charts (see and

Screen shots

Screen shot of the wxkpg, the GUI version of kpg.


Screen shot of wxkpg GUI version under Windows


Screen shot of wxkpg GUI version under Linux


Current version is 0.6

Downloads are available from sourceforge

You can check out the latest release in CVS


Example Illusions

Example Logo

The image was created in inkscape as an SVG then exported (as PNG). The GIMP was used to index the image (and remove dithering) then saved as a PNG. kpg was then used to create the pattern, actually wxkpg (an easy to use GUI for kpg) was used to create the pattern). The generated html file was then opened in OpenOffice and printed from there.

If you use kpg I'd love to have a photo of the final item (along with the source image) for this web page. Contact details are here

Good sources of images are low colour count images like logos and cartoons, for example,

Example Usage

Example for command line tool to create a mono (this means one colour but with a "bumpy" visible pattern). This option is not yet available in the GUI version.

./ -m mypicture.png

Example for command line tool to create a smooth colour pattern (that is, no bumps or relief stiches ). This option is not yet available in the GUI version. -s mypicture.png


These requirements are only if you download the source code. Pre-built Windows executables do not have these requirements!


kpg is similar to cross stitch pattern generators:

How To / Tutorial has tutorial on how to prepare images before using this tool to convert to a knitting pattern. The main process is:

  1. Reduce number of colours, ideally for knitting ONLY use a couple of colours as more colours makes the knitting process more complex. When reducing the number of colours try to avoid dithering.
    In the GIMP

  2. Save the image as a indexed image. The recommended format is PNG as you can elect to have palettes with "non-standard" colour counts. For example, three which is not a multiple of 2.

  3. Run kpg with the image as input. Under Windows simply find wxkpg from the Start Menu and click the "Select Image" button to find the bitmap, then click the "Create knitting pattern" button.
    If using the command line version, simply run with the image as an input command line argument, this will (by default) create a HTML file in the same directory as the image. E.g.

           python myimage.png

    Or under Unix like systems:

           ./ myimage.png

    The image can be in any (indexed) bitmap format supported by PIL (e.g. png, gif, etc.).

  4. Print out the pattern, it is recommended to open the HTML pattern file in a word processor for printing to ensure that the colour table is printed correctly and to ensure that row instructions do not get broken across pages. I recommend OpenOffice

Currently kpg creates patterns where the foreground colour is knitted in a different stitch to the background. Simple two colour pictures could be knitted with just one colour thread and still be visible as a pattern in the final knitted material. Simply ignore references to different colour threads and follow the stitch pattern.

Project Page Logo

Locations of visitors to this page