A tool to parse image files and generate machine knitting instructions for intarsia patterns. It breaks down an image into colored segments and provides row-by-row instructions for knitting.
- Python 3.x
- Pillow (Python Imaging Library)
Follow these steps to set up a virtual environment and install the necessary dependencies:
- Open your terminal.
- Navigate to the project directory:
cd /home/[PROJECT_PATH] - Create a virtual environment (optional but recommended):
python3 -m venv .venv
- Activate the virtual environment:
- On Linux/macOS:
source .venv/bin/activate - On Windows:
.venv\Scripts\activate
- On Linux/macOS:
- Install the required dependencies:
pip install pillow
The script processes an image file and prints instructions for each row. You must provide the path to the image file using the --file argument.
python3 parse_intarsia_optimized.py --file your_image.jpg--file FILE: The path to the image file you want to process.--colors COLOR1 COLOR2 ...: (Optional) Provide names for the colors found in the image. If not provided, colors will be indexed numerically (e.g., "Color 0", "Color 1").
python3 parse_intarsia_optimized.py --file vector.jpg --colors Red Blue WhiteAfter running the script, it will display information about the image and the colors detected. It will then wait for you to press ENTER to display the instructions for each row.
- The script starts from the bottom of the image (Row 1).
- Instructions will tell you whether to start on the left or right.
- For each segment in the row, it will provide the color and the needle range (e.g., "Color 0, 10 to 20").
- Press ENTER to proceed to the next row.
parse_intarsia_optimized.py: The recommended version with improved error handling and updated Python syntax.parse_intarsia.py: The legacy version of the script.