Photo to string art

An implementation of Petros Vrellis's A New Way to Knit. Each step draws the chord that covers the most remaining darkness from the current peg.

Sample image. Load your own photo.

This is what the solver sees: a square crop, greyscale, inside the circle. Drop an image anywhere on the page to load it.

Lines0
Thread0 m
Peg spacing–

Knitting mode

Generate a pattern first
–

Press Space or → for the next peg and ← to go back.

The pattern

Peg 0 is at the top (12 o'clock). Numbers run clockwise. Tie the thread on the first peg, then wrap it around each listed peg in turn. In color mode, each thread color is its own list. Knit them in the order shown, lightest first and black last.

Your photo, settings, pattern and knitting step are saved in this browser automatically and come back after a refresh. The backup file has the full peg lists in readable form, and loading it restores the pattern and your step on any device.

How the solver works
  1. The photo is cropped square, turned to greyscale, put through your contrast and brightness settings, and inverted so that 1 means "needs thread". Everything outside the circle is ignored.
  2. Pegs are spaced evenly around the circle. From the current peg the solver checks every chord to the other pegs. It skips pegs closer than the minimum skip and pegs used in the last 20 moves.
  3. Each chord gets a score: the average darkness still owed along its pixels. The best chord wins, and the thread's coverage is subtracted along it. Coverage is the thread thickness divided by the width of one solver pixel, which is the rim diameter ÷ 400, so later lines go elsewhere.
  4. The thread is now on the new peg. Repeat until the line budget is used.

Color mode. The photo is first dithered (Floyd–Steinberg) into the board color plus your thread colors, which you can see in the small preview. Each thread color gets a density map of the pixels assigned to it, and the same greedy solver runs on each map. The line budget is split by how much of the image each color covers. Threads sit on top of each other, so the pattern is knitted lightest first with black on top. Raising the saturation pushes more pixels into the colored threads.

Thread thickness is the main setting. Measure your thread or use the maker's figure: all-purpose polyester sewing thread is about 0.2 mm. A thicker thread or smaller rim means fewer, bolder lines. A finer thread or bigger rim means more lines and subtler tones. Real thread is a little fuzzy and not fully opaque, so if your piece comes out lighter than the preview, enter a slightly smaller thickness. Vrellis used about 200 pegs on a 28-inch (71 cm) rim, with 3,000 to 4,000 passes and 1 to 2 km of thread. Faces work best with strong contrast and a plain background.