Someone on an email list I belong to asked about ways of making a counted cross-stitch pattern from a photo. There are commercial packages that do this, but it seemed like something GIMP could do, and I wanted some Python practice.
Attached is a zip file containing the following files:
- cross-stitch.py - Python script for converting a photo to a cross-stitch pattern
- floss.html - an HTML document listing available cross-stitch floss colours by numbered index, common name, RGB and hex values (culled from http://www.stitchstuff.com/dmcrgb.htm)
I used the Photoshop tutorial found
here as my starting point. The script performs the following operations:
- Pixellates, adjusts brightness & posterises according to user settings
- Scales down the pixellated image to increase performance
- Checks each colour of each mosaic tile, and performs "best matching" colour exchange against the palette of available floss colours
- Scales up pixellated image for next operations and for readability
- Adds grid in new layer
- Adds text labels for each colour with floss' index number
- Creates a text file listing all floss needed, and in what quantities
It appears in the menus under
Filters > Decor > Cross-stitchify... It takes quite some time to run as I need to iterate through each tile of the image twice, and any interruption during the label phase can crash the script, but the output is quite good. The entire image can be printed for use as the pattern, or just the grid if printing in B&W.
I would love some feedback if there are better ways to do what I have done, or any bugs I may have missed. Cheers!
UPDATE: version 2.0 - added creation of text file with list of what colour floss, and how many stitches of each, are used. Also allowed for greater range of mosaic sizes to accommodate wider range of images. New version attached below.