Introduction: Cross Stitch Pattern Generator

My mother loves to cross-stitch and crochet. Her biggest problem is finding the right patterns for what she needs to do. I've seen her buy dozens of books with patterns as well as have my brother draw on grid paper a unique design. Many of the images are easy to find with a quick Google search, so I set out to take a jpeg from a Google Image search and turn it into a cross-stitch of crochet pattern for my mother!

The way I did this is with a JAVA program, however, besides reading/writing the image, I used all basic primitives so anyone could easily take what I've done and do it in their own language. The full source code is available here to download and use or translate.

Step 1: Take the Input Parameters

This is meant to take in a jpeg. This part has some fairly JAVA specific methods, but to port it to your language of choice should be trivial. Here we receive the input parameters, verify the input image exists and make sure we can create the output file.

Step 2: Example Image

For our testing, we will be making a cross-stitch ready pattern of the Instrucable mascot!

Step 3: Scaling the Image Down

The above code will take our rather large image of the mascot and resize it to the user specified dimensions. This results in a very tiny image. This very tiny image isn't very useful, but this is the resolution that we want. To make it useful, we now have to size it back up but make it seem as we're staying at this low resolution!

Step 4: Scale the Image Back Up

Now we take our very small image, and we're going to re-produce each pixel 10 times in the X and Y direction. Then in between each of these 10x10 scaled up versions of our pixel, we're going to put a black line. This will give us our cross-stitch template effect!

Once that is done, you can write your image out and use it!

Step 5: Example Cross-stitch Pattern!

And here are some example patterns that I've made!

Step 6: A Note on Aspect Ratio

To use this effectively, when inputting your output dimensions try to preserve the aspect ratio or width / height as close as possible. Sometimes to fit a specific template, you're forced to smush a bit, but try to stay close.


For example, the input Batman image is 200 pixels wide, and 120 pixels height. It's wider than taller. So, when re-scaling it, I chose 50 pixels wide, by 30 pixels height. I just divided both sides by the same amount, and the result looks great. However, above you can see when I choose 50x50, changing the aspect ratio, makes the symbol looked squish compared to the original!

Coded Creations

Participated in the
Coded Creations