knitout-image-processing

Shaping and colorwork programs to output knitout files based on input images.
For use in conjunction with a machine-specific knitout backend.

InstallationDependenciesUsageCommand-line PromptsTroubleshootingAdditional Resources

Installation

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.

Dependencies

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.

Usage

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’.

Command-line Prompts

Knitify

Motif specs: 1) Colorwork image file2) Piece width (stitches)3) Piece height (rows)4) Machine
Image processing: 5) Color count6) Dithering7) Palette
Knitout extensions: 8) Stitch number9) Speed number10) Waste section settings
Knitting techniques: 11) Back style
Stitch patterns: 12) Stitch patterns 12.a) Image file12.b) Pattern name12.c) Specifications12.d) Include more?12.e) Mapped color12.f) Carrier12.g) Customizations
Carrier assignments: 13) Cast-on carrier14) Waste section carrier
Ribbing: 15) Rib15.a) Top rib15.a.i) Carrier15.a.ii) Row count15.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:

^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]:

Enter the carrier you’d like to use for the ‘' stitch pattern (e.g. 1):

  - <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]:

if y (yes):

  Would you like to add ribbing to the bottom of the piece? [y/n]:


Shapeify

Shape code specs: 1) Shape1.a) Image file1.b) Colorwork knitout file1.c) Alter the shape code
Save: 2) Save as
Shaping specs: 3) Increasing method4) 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:

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

Troubleshooting

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.

Additional Resources

Some helpful/relevant resources that you might use or reference alongside this program: