This guide explains how to implement various creative sticker features for the Printit project. Each section covers a specific feature idea, including implementation approach, code structure changes, and integration with the existing architecture.
Before implementing new features, understand the existing structure:
- Main Application (
printit.py): Streamlit app with tab management - Tab Modules (
tabs/): Each feature tab is a separate module - Image Utilities (
image_utils.py): Image processing functions - Printer Utilities (
printer_utils.py): Printer handling and job queue - Configuration (
config.toml,config_manager.py): App settings - Job Queue (
job_queue.py): Async print job processing
New features are typically implemented as new tab modules. The pattern:
- Create
tabs/feature_name.pywith arender()function - Add the tab to
config.tomlunder[tabs].enabled - Import and render in
printit.py(already handles dynamic tab loading)
Concept: Create stickers that appear as 3D half-cubes when assembled, with isometric projection.
Implementation Approach:
# tabs/isometric_cube.py
def create_isometric_cube_faces(label_width, cube_size_mm):
"""
Generate 3 faces of a half-cube in isometric projection.
Returns a list of PIL Images for each face.
"""
# Calculate isometric projection coordinates
# Generate front, top, and side faces
# Apply shading for 3D effect
pass
def render(printer_info, preper_image, print_image):
# UI for cube size, rotation, shading options
# Preview of assembled cube
# Option to print all faces at once
passRequired Changes:
- New file:
tabs/isometric_cube.py - Add to
config.toml:"Isometric Cube"to enabled tabs list - Extend
image_utils.pywith isometric projection helper functions
Integration Points:
- Uses existing
preper_image()for dithering - Uses existing
print_image()for printing - Follows same parameter pattern as other tabs
Creative Applications:
- Architectural models
- Package design prototypes
- Educational geometry tools
Concept: Break a large image into multiple stickers that assemble into a mosaic.
Implementation Approach:
# tabs/mosaic.py
def create_mosaic_tiles(image, grid_size, overlap_pixels):
"""
Split image into grid of tiles with overlap for alignment.
Returns list of (tile_image, position_x, position_y).
"""
# Calculate tile dimensions
# Create overlapping regions
# Add alignment marks (crosshairs in corners)
pass
def render(printer_info, preper_image, print_image):
# Upload image
# Grid size selector (2x2, 3x3, 4x4, etc.)
# Overlap adjustment
# Preview of assembled mosaic
# Option to print all tiles or selected ones
passRequired Changes:
- New file:
tabs/mosaic.py - Add mosaic utilities to
image_utils.py:split_image_to_grid()add_alignment_marks()
- Update
config.tomlwith"Mosaic"tab
Integration Points:
- Leverages existing image loading from
sticker.py - Uses
job_queue.pyfor batch printing - Could integrate with
history.pyfor mosaic project tracking
Creative Applications:
- Large wall art from small stickers
- Collaborative art projects
- Puzzle-style promotions
Concept: Print continuous strips by aligning multiple labels, creating effectively infinite dimensions.
Implementation Approach:
# tabs/continuous_strip.py
def create_continuous_strip(image, strip_direction, label_width, max_labels=10):
"""
Create a continuous strip across multiple labels.
direction: "horizontal" or "vertical"
Returns list of images for each label segment.
"""
# Calculate segmentation based on label dimensions
# Add continuation marks (arrows, numbers)
# Handle partial segments
pass
def render(printer_info, preper_image, print_image):
# Direction selector (horizontal/vertical)
# Length in labels or millimeters
# Preview of assembled strip
# Print sequence guidance
passRequired Changes:
- New file:
tabs/continuous_strip.py - Extend
printer_utils.py:- Add
print_sequence()for ordered batch printing - Add alignment validation
- Add
- Update
config.tomlwith"Continuous Strip"tab
Integration Points:
- Uses
job_queue.pywith sequence tracking - Could extend
history.pyto track multi-label projects - Shares image processing with
sticker_pro.py
Creative Applications:
- Timeline visualizations
- Continuous barcodes/QR codes
- Border decorations
- Measuring tapes/rulers
Concept: Add dashed or dotted lines to indicate where to cut with scissors, plus registration marks.
Implementation Approach:
# tabs/cutting_guides.py
def add_cutting_guides(image, guide_type, guide_spacing, label_width):
"""
Add cutting guides around image perimeter.
guide_type: "dashed", "dotted", "scissors_icon"
Returns image with guides.
"""
# Calculate guide positions
# Add different guide styles
# Include registration marks for alignment
pass
def render(printer_info, preper_image, print_image, apply_threshold):
# Guide style selector
# Spacing adjustment
# Registration mark options
# Preview with and without guides
passRequired Changes:
- New file:
tabs/cutting_guides.py - Extend
image_utils.py:add_cutting_guides()add_registration_marks()
- Update
config.tomlwith"Cutting Guides"tab
Integration Points:
- Can be combined with any existing tab (adds guides to output)
- Uses same printing pipeline
- Could be a post-processing option in
sticker.pyandsticker_pro.py
Creative Applications:
- DIY craft projects
- Paper model templates
- Puzzle pieces
- Gift tags with tear-off portions
Concept: Enhance the existing label tab with creative text layouts and effects.
Implementation Approach:
# tabs/creative_text.py (or enhance tabs/label.py)
def create_text_effects(text, font, effect_type, label_width):
"""
Apply creative effects to multi-line text.
effect_type: "wave", "spiral", "perspective", "gradient"
Returns styled text image.
"""
# Parse text into lines
# Apply geometric transformations
# Add visual effects
pass
def render(printer_info, get_fonts, preper_image, print_image):
# Enhanced version of label.py with:
# - Text effect selector
# - Line-by-line formatting
# - Visual preview with real-time updates
# - Save/load text templates
passRequired Changes:
- Option A: Enhance
tabs/label.pywith new features - Option B: Create
tabs/creative_text.pyfor advanced features - Add text utilities to
image_utils.pyor newtext_utils.py:apply_text_effect()create_text_layout()
Integration Points:
- Builds on existing
label.pyfoundation - Uses same font loading system
- Shares printing pipeline
Creative Applications:
- Poetry with visual formatting
- Concrete poetry (text forming shapes)
- Calligraphy practice guides
- Text-based art
- Secret messages (text within text)
Concept: Create stickers where the design is cut out (negative space), showing through to the surface beneath.
Implementation Approach:
# tabs/negative_space.py
def create_negative_space(image, invert_method, border_size):
"""
Convert image to negative space design.
invert_method: "threshold", "edge_detect", "manual_mask"
Returns inverted image with optional border.
"""
# Apply inversion based on method
# Clean up edges
# Add border for structural integrity
pass
def render(printer_info, preper_image, print_image, apply_threshold):
# Image upload
# Inversion method selector
# Threshold adjustment
# Border options
# Preview on different background colors
passRequired Changes:
- New file:
tabs/negative_space.py - Extend
image_utils.py:invert_for_negative_space()apply_edge_detection()
- Update
config.tomlwith"Negative Space"tab
Integration Points:
- Uses
apply_threshold()from existing code - Shares image processing pipeline
- Could integrate with
sticker_pro.pyoptions
Creative Applications:
- Window decals
- Stencils for painting
- Light filters (for lamps, etc.)
- Layered shadow art
- Reverse graffiti templates
Concept: Create layered stickers with registration marks for precise alignment, potentially with transparent layers.
Implementation Approach:
# tabs/multilayer.py
class MultiLayerProject:
def __init__(self):
self.layers = [] # List of (image, offset_x, offset_y, opacity)
self.registration_marks = "crosshair"
def add_layer(self, image, position, opacity=1.0):
# Add layer to project
pass
def preview_assembled(self):
# Composite all layers
pass
def generate_print_sheets(self):
# Create separate images for each layer
# Add registration marks
# Add layer identification
pass
def render(printer_info, preper_image, print_image):
# Layer management UI
# Position adjustment tools
# Opacity controls
# Registration mark style selector
# Print all layers or selected ones
passRequired Changes:
- New file:
tabs/multilayer.py - New module:
multilayer_project.pyfor project management - Extend
image_utils.py:composite_layers()add_registration_marks()
- Update
config.tomlwith"Multi-layer"tab
Integration Points:
- Could integrate with
history.pyto save multilayer projects - Uses
job_queue.pyfor batch printing layers - Shares image processing utilities
Creative Applications:
- Mixed media art (paper + transparency film)
- Color separation for screen printing
- Anaglyph 3D effects (red/blue glasses)
- Interactive layers (flip books, reveal layers)
- Educational models (anatomy, geology)
- Cutting Guides - Simple image processing addition
- Creative Text - Enhancement of existing label.py
- Negative Space - Uses existing threshold functions
- Mosaic Stickers - Requires grid splitting logic
- Continuous Strips - Requires sequence management
- Isometric Cube - Requires 3D projection math
- Multi-layer Stickers - Requires project management system
- Brother QL printers have fixed label widths
- Continuous strips require manual alignment
- Multi-layer requires precise registration
- Consider printer memory limits for complex images
- All new features should use existing
preper_image()pipeline - Add new utilities to
image_utils.pyfor reusability - Consider performance for real-time previews
- Maintain consistent UI patterns with existing tabs
- Provide clear instructions for assembly/use
- Include previews before printing
- Save user settings in session state
- Follow existing tab module pattern
- Use configuration system for defaults
- Add comprehensive logging
- Include error handling for edge cases
- Unit Tests: Test image processing functions in isolation
- Integration Tests: Test tab rendering and user interactions
- Printer Simulation: Test without actual printer using mock
- User Acceptance: Test assembly instructions are clear
To implement any of these features:
- Choose a feature from Phase 1 to start
- Create the tab module following existing patterns
- Add necessary utilities to
image_utils.py - Update
config.tomlto enable the tab - Test thoroughly before moving to next feature
Each feature can be developed independently, allowing for incremental improvement of the Printit system while maintaining backward compatibility with existing functionality.