WordWeave Artist is a desktop application designed to transform raster images into a unique "Word-Weave" / "Crossword Texture" ASCII art style. Instead of single characters, it uses user-defined words or predefined ASCII character sets, densely placed based on the source image's tones, creating a textual representation of the image.
The application follows this general data flow:
- Image Import: The user imports a raster image (
original_image). Displayed in "Input Image" preview. - Image Processing: All user-selected adjustments (Brightness, Contrast, Saturation, Grayscale, Invert, Sharpness, Threshold, Edge Detect) are applied sequentially by
image_processor.apply_image_processing. Edge detection results are inverted (black edges on white). The single resulting image (processed_image) is generated. This represents the final state after all user adjustments. - Processed Preview: The final
processed_imageis displayed in the "Processed Image" preview pane, giving direct visual feedback on the source for mapping. - Gradient Source: The user selects either a "Custom Word List" or a predefined "ASCII Character Set".
- Brightness Mapping:
render_engine.update_brightness_mapcreates a mapping (brightness_map) based on the selected gradient source. It calculates the brightness of pixels in theprocessed_image(converting to grayscale 'L' mode internally if needed) and assigns words/characters to brightness ranges (0-254). Pure white (255) maps toSKIP_RENDER_VALUE. - Placement Generation:
render_engine.generate_grid_placementuses theprocessed_image(ensured to be 'L' mode) andbrightness_map.- The image is divided into a grid based on
word_density. - The average brightness of each grid cell is calculated from the
processed_image. - The
brightness_mapdetermines the word/character (item) for that brightness. - If
itemis notSKIP_RENDER_VALUE, its target position (cell center) is stored.
- The image is divided into a grid based on
- Rendering:
render_engine.render_word_gridcreates a new blank canvas.- It iterates through the placement data.
- For each
itemand position, it loads the selected font (with fallbacks) usingrender_engine.try_load_font. - The
itemis drawn onto the canvas.
- Output Preview: The final rendered image is displayed in the "Output Image" preview pane.
The processing and rendering pipeline (trigger_processing_and_render -> _apply_image_processing -> trigger_render -> generate_grid_placement -> render_word_grid) is executed whenever relevant UI controls are changed.
src/main.py(MainWindow):- Manages the main application window, UI layout (using
_create_left_panel,_create_right_panel), and widgets (PreviewLabel, sliders, checkboxes, etc.). - Holds the application state (image objects, processing settings, styling settings).
- Connects UI signals (button clicks, slider changes) to slots.
- Orchestrates the overall workflow by calling functions in helper modules.
- Handles file dialogs (
open_image_dialog,load_words_from_file). - Updates preview panes (
_update_single_preview).
- Manages the main application window, UI layout (using
src/image_processor.py:apply_image_processing(): Takes the original image and all processing settings, applies them sequentially (color/tone -> grayscale -> effects -> threshold/edge), and returns the single final processed image used for preview and mapping.
src/render_engine.py:update_brightness_map(): Creates the brightness-to-item mapping dictionary.get_item_for_brightness(): Looks up an item in the map based on brightness.try_load_font(): Loads fonts with fallbacks.generate_grid_placement(): Calculates average brightness from the processed image cells and determines item placements.render_word_grid(): Draws the items onto the final output canvas.
- Constants: Defined in respective modules (
main.py,render_engine.py).
- Prerequisites: Python 3.x,
pip. - Clone/Download: Get the project files.
- Navigate: Open a terminal in the
WordWeaveArtistproject directory. - Virtual Environment (Recommended):
- Create:
python -m venv venv - Activate (Windows):
.\venv\Scripts\activate - Activate (macOS/Linux):
source venv/bin/activate
- Create:
- Install Dependencies:
pip install -r requirements.txt - Run:
python src/main.py(Ensure the virtual environment is active).
See requirements.txt (PySide6, Pillow).
See ROADMAP.md.