Shaping and colorwork programs to output knitout files based on input images.
For use in conjunction with a machine-specific knitout backend.
Installation | Dependencies | Usage | Command-line Prompts | Troubleshooting | Additional Resources |
In the command line, type:
git clone https://github.com/gabrielle-ohlson/knitout-image-processing
See the github documentation on cloning a repository if you need assistance with installation.
The following dependencies will automatically be installed by running the command npm install
after the repo has been cloned.
Packages to install with npm (package manager included with node.js):
To install these dependencies, first open your terminal and change into the directory in which you installed the repo (e.g. if you installed it in home/user/code
and kept the default repo name, you’d type: cd home/user/code/knitout-image-processing
):
cd <whatever-folder-you-installed-the-repo-in/the-repo-name>
npm install
The dependenices will appear in a newly created folder called ‘node_modules’.
NOTE: ensure that all dependencies have been installed before running the program.
Place the image file (.png or .jpg) that you would like to process in the ‘in-colorwork-images’ folder.
From your terminal, cd to the parent directory ‘knitout-image-processing’ (if you have not already done so) and run the command npm run knitify
.
Respond to the prompts as they appear in the terminal.
When the program has finished running, a knitout file will be written to the sub-directory ‘knit-out-files’. A visual depiction of the knitting machine instructions will also be written to the parent directory (under the name ‘knit_motif.png’).
To then add shaping to the file:
Place an image (.png or .jpg) in the ‘in-shape-images’ folder (note: the graphic should include a white background and a shape with a completely black fill.)
From your terminal, run the command npm run shapeify
and respond to the prompts.
The program will then output a knitout file to the sub-directory ‘knit-out-file’.
Motif specs: | 1) Colorwork image file | 2) Piece width (stitches) | 3) Piece height (rows) | 4) Machine | ||||
Image processing: | 5) Color count | 6) Dithering | 7) Palette | |||||
Knitout extensions: | 8) Stitch number | 9) Speed number | 10) Waste section settings | |||||
Knitting techniques: | 11) Back style | |||||||
Stitch patterns: | 12) Stitch patterns | 12.a) Image file | 12.b) Pattern name | 12.c) Specifications | 12.d) Include more? | 12.e) Mapped color | 12.f) Carrier | 12.g) Customizations |
Carrier assignments: | 13) Cast-on carrier | 14) Waste section carrier | ||||||
Ribbing: | 15) Rib | 15.a) Top rib | 15.a.i) Carrier | 15.a.ii) Row count | 15.b) Bottom rib | |||
Save: | 16) Save as |
(press Enter to skip if using only stitch pattern) Colorwork image file:
^1. Enter the name of the image to base the colorwork on (including the extension– .png or .jpg). The image should exist in the ‘in-colorwork-images’ folder.
If you are planning to create a piece that only includes a stitch pattern (i.e. no colorwork/motif), hit the Enter key to skip this prompt.
e.g. stars.png
How many stitches wide?
^2. The image’s width (in pixels) will be scaled to the number of stitches you’d like the piece to be (not to exceed the maximum needle count of the machine [e.g. for kniterate, 252]). Enter a number.
e.g. 252
How many rows long? (press enter to scale rows according to img dimensions)
^3. The same will occur for the image’s height (in pixels), in accordance with the row count you specify.
Note that the knitted piece will likely produce a squashed or stretched version of the image, depending on stitch size and yarn thickness. Scale the image accordingly.
Also note that if you are using only a stitch pattern and skipped the Colorwork image file
prompt, answering this prompt is required.
e.g. 300
What model knitting machine will you be using?
^4. Enter the company that produces the machine you will be using.
e.g. kniterate
How many colors would you like to use?
^5. The program will reduce the number of colors in the image in accordance with the number you input.
Keep in mind the maximum number of carriers your machine has (e.g. for kniterate, 6).
e.g. 5
Would you like to use dithering? (dithering is recommended for detailed/naturalistic images, but not for graphics/digital artwork.) [y/n]:
^6. This determines how the program processes the image–dithering will create the illusion of a more colorful/detailed motif (with adjacent pixels in different colors optically blended to immitate another color). Opting out of this option will produce colors with hard edges. Key-in either y
(yes) or n
(no).
e.g. y
Would you like to use a predefined palette? [y/n]:
^7. This option is useful for when there are certain colors you would like to prioritize in the image, such as when a color is low in occurrence but high in importance.
If you opt to use a predefined palette, you will be met with the prompt Enter hex-code for color #<n>:
for the n
-number of colors you indicated that you will be using. Enter the hex-code e.g. #FF0000
.
e.g. n
(OPTIONAL: press enter to skip this step) What would you like to set the stitch number as?
^8. Enter a number to set the stitch size (knitout extension: x-stitch-number
) in the main body of the piece. For example, on kniterate machines, there are 16 valid values, with single digit values represented by a number (0 - 9) and double-digit values represented by a letter (A - F, with A being 10 and F being 15). Lower number produce smaller/tighter stitches.
e.g. 6
(OPTIONAL: press enter to skip this step) What would you like to set the carriage speed number as? (valid speeds are between <0-600>)
^9. Enter a number to set the knitting speed for the piece (knitout extension: x-speed-number
). Faster speeds are more efficient, but may increase the chances of dropped stitches/broken yarn on lower-level machines.
e.g. 300
Would you like to change any of the default settings for the waste section? (DEFAULT stitch number: 6, speed number: 400, roller advance: 150) [y/n]:
^10. Optionally, you can alter the default knitout-extension settings for the waste section at the beginning of the piece, or just stick with the defaults.
e.g. y
[1] Default
[2] Birdseye
[3] Minimal
[4] Secure
[0] CANCEL
^What style back would you like to use? (note: this doesn't matter if you're using *only* stitch patterns)
=> 'Default' is a freeform option that is similar to Birdseye in performance, but more suitable for pieces containing up to 5 colors.
=> 'Birdseye' is not recommended for pieces that use more than 3 colors due to the build up of extra rows the method creates on the back bed.
=> Alternatively, 'Minimal' creates a reasonably even ratio of front to back rows, resulting in the least amount of build up on the back.
=> 'Secure' is the 'Minimal' option, with additional knits on the side needles for extra security. [1...4 / 0]:
^11. Key-in select the style that you’d like the program to produce for the back of the knit.
Note that this prompt will not appear if you are using solely a stitch pattern.
e.g. 1
Would you like to include any stitch patterns in your motif? [y/n]:
^12. Indicate whether or not you’d like to include stitch patterns in the piece (either having the whole piece comprised of stitch patterns, or including sections of stitch patterns within the motif). If yes, you will specify the path to an image that has blobs of color that will be mapped to a specific stitch pattern (overlayed on the rest of the motif).
Note that the image should only include a white background and the colors denoting stitch patterns.
e.g. y
if y
(yes):
(press Enter to skip if using only *one* stitch pattern that *comprises the whole piece*) Stitch pattern image file:
stitch-pattern.png
```console
[1] Rib
[2] Bubbles
[3] Seed
[4] Lace
[0] CANCEL^Select a stitch pattern to use in your motif. [1…4 / 0]:
- <a id="knitify12b"></a>**^12.b)** Key-in select the stitch pattern that you'd like to use in the piece (repeat for however many stitch patterns you'd like to include).\
*e.g. `1`*
- <a id="knitify12c"></a>**12.c)** A number of prompts *might* follow to give you a chance to indicate specifications for the particular stitch pattern you chose. (e.g. `Which type of rib?`)
```console
Would you like to include another stitch pattern? [y/n]:
y
) or to just use the one n
.Stitch pattern image file
prompt.
Enter the hex-code (or color name) for the color you used to denote the '<your-stitch-pattern>' stitch pattern (e.g. #0000FF or blue):
Enter the carrier you’d like to use for the ‘
- <a id="knitify12f"></a>**^12.f)** You will be prompted to assign a particular carrier to the given stitch pattern (it can either be one you already used in the piece [all of those will be listed with carrier number and the hex-code you assigned it] or a new carrier, if enough are leftover).
```console
Would you like to add any other customizations for the '<your-stitch-pattern>' stitch pattern? [y/n]:
y
), you’ll be met with a number of additional prompts specific to the given stitch pattern.
(OPTIONAL: press Enter to skip this step and use the default carrier [background color]) Which carrier would you like to use for the cast-on?
^13. Option to indicate a specific carrier you’d like to use for the cast-on. If unspecified (skipped with Enter key), the default carrier will be used for the cast-on, which is whatever color is detected by the program as the background.
e.g. 2
(OPTIONAL: press Enter to skip this step and use the default carrier [1]) Which carrier would you like to use for the waste section?
^14. Option to indicate a specific carrier you’d like to use for the waste section. If unspecified (skipped with Enter key), the default carrier will be used to knit the waste section, which is carrier ‘1’.
e.g. 3
Would you like to add rib? [y/n]:
^15. Option to add 1x1 ribbing to the top and/or the bottom of the piece.
e.g. y
if y
(yes):
Would you like to add ribbing to the bottom of the piece? [y/n]:
y
or n
.y
(yes):
[1] #hexcode1
[2] #hexcode2
[3] #hexcode3 (...continued for # of colors)
[4] new carrier
[5] new carrier
[6] new carrier
[0] CANCEL
^Which carrier would you like to use for the bottom rib? (the corresponding hex code is listed next to each carrier number) [1...6 / 0]:
2
How many rows?
30
Would you like to add ribbing to the top of the piece? [y/n]:
y
or n
.y
(yes), prompts listed about for bottom rib will repeat, this time for top rib.
Save as:
^16. Enter a name for the output knitout file. The file with be saved to the ‘knit-out-files’ folder.
e.g. stars.k
Shape code specs: | 1) Shape | 1.a) Image file | 1.b) Colorwork knitout file | 1.c) Alter the shape code |
Save: | 2) Save as | |||
Shaping specs: | 3) Increasing method | 4) Transfer speed |
[1] Custom Shape
[2] Template
[0] CANCEL
^Would you like to input an image for a custom shape, or use a pre-made template? [1, 2, 0]:
^1. To determine the shaping to apply to the colorwork file you produced, you can choose to either use a custom shape image (represented by a black graphic [.jpg or .png] with a white background) that you’ve placed in the ‘in-shape-images’ folder, or to base the shaping off of a pre-made template.
NOTE: option [2] ‘Template’ is still in progress. Please use only option [1] for now.
e.g. 1
if option [1] ‘Custom Shape’ is selected:
Shape image file:
shape.jpg
What is the name of the file that you would like to add shaping to?
stars.k
```console
WRITING ‘SHAPE-CODE.txt’ FILE IN WORKING DIRECTORY.
If you would like to edit the shape in the .txt file, please do so now.
Valid characters are: 0 [white space] and 1 [shape]Are you ready to proceed? [y/n]:
- <a id="shapeify1c"></a>**^1.c)** The shape will be processed into a .txt file (titled 'SHAPE-CODE.txt') with '1' characters represented the shape (black graphic) and '0' characters representing the white space (white background). This file is editable, in case the shape doesn't turn out exactly as you'd like (but it must remain only 1s and 0s, the same number of lines, and the same number of characters in each line). Key-in 'y' when you are done editing the file or if you don't want to make any changes.\
*e.g. `y`*
```console
Save new file as:
^2. Enter a name for the output knitout file. The file with be saved to the ‘knit-out-files’ folder.
e.g. stars-shape.k
if increasing exists in the shape:
[1] xfer
[2] twisted-stitch
[3] split
[0] CANCEL\
^Which increasing method would you like to use? [1, 2, 3, 0]:
^3. The program is capable of using three different methods of increasing–the first (‘xfer’) will increase by transfer stitches on the edge to adjacent empty needles and then knitting twisted stitches (different direction than the other stitches in a given pass) on the new empty needles. The second (‘twisted-stitch’) will simply knit twisted stitches on adjacent empty needles to increase. The third and final method (‘split’) will increase by splitting (a technique that involves transferring a loop from one needle to another while knitting a new loop on the first needle).
e.g. 1
What carriage speed would you like to use for transfer operations? (press enter to use default speed, 100.)
^4. Distinct from the knitting speed, a speed for transfer operations can be specified.
e.g. 200
If you have any trouble, discover a bug, or want to provide feedback, do not hesitate to use the Issues page.
For example files, see the in-colorwork-images and in-shape-images folders.
Some helpful/relevant resources that you might use or reference alongside this program: