Skip to content

YouvenZ/textgen_ink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Text Generator for Inkscape

Inkscape Python License

Generate and transform text in Inkscape using local AI models (Ollama, llamafile)

A powerful Inkscape extension that leverages local Large Language Models to create, modify, translate, summarize, expand, and rewrite text directly within your designs. Privacy-focused with no cloud dependencies.

πŸ“Ί Demo

Watch the Demo

Click to watch the full tutorial on YouTube


πŸ“‹ Table of Contents

  • Features
  • Requirements
  • Installation
  • Quick Start
  • Usage Guide
  • Configuration
  • Examples
  • Troubleshooting
  • Contributing
  • License

✨ Features

  • πŸ€– Multiple AI Providers

    • Ollama: Popular local LLM runner
    • llamafile: Single-file executable LLMs
    • Custom API: Any OpenAI-compatible endpoint
  • πŸ“ Six Operation Modes

    Mode Description
    Create Generate new text from a prompt
    Modify Change selected text based on instructions
    Translate Convert text to another language
    Summarize Condense text to key points
    Expand Add detail and elaboration
    Rewrite Improve grammar, clarity, and style
  • 🎨 Rich Styling Options

    • Font family, size, weight, and style
    • Text color and decorations
    • Background boxes with customizable padding
    • Text alignment and spacing controls
    • Scale multiplier for easy resizing
  • 🎯 Smart Positioning

    • 9 preset positions (center, corners, edges)
    • Cursor/selection-based placement
    • Custom X/Y offsets
  • πŸ”§ Advanced Features

    • Auto-detect available models
    • Temperature and token limit controls
    • 8 tone presets (formal, casual, humorous, etc.)
    • Automatic markdown cleanup
    • Preserve existing text styles

πŸ“¦ Requirements

Core Requirements

Component Version Purpose
Inkscape 1.0+ Vector graphics editor
Python 3.6+ Extension runtime (bundled with Inkscape)

AI Backend (Choose One)

πŸ¦™ Option 1: Ollama (Recommended)

Ollama is the easiest way to run local LLMs.

Installation:

# macOS/Linux
curl -fsSL https://ollama.com/install.sh | sh

# Windows
# Download from: https://ollama.com/download

Pull a model:

# Recommended models
ollama pull llama3.2        # Fast, good quality (2GB)
ollama pull mistral         # Excellent for text (4GB)
ollama pull gemma2          # Google's model (5GB)
ollama pull qwen2.5         # Multilingual (4GB)

Start the server:

ollama serve
# Server runs at http://localhost:11434
πŸ“¦ Option 2: llamafile

llamafile packages models as single executables.

Installation:

  1. Download a llamafile from Mozilla's collection
  2. Make it executable and run:
# Linux/macOS
chmod +x mistral-7b-instruct-v0.2.Q4_0.llamafile
./mistral-7b-instruct-v0.2.Q4_0.llamafile --server

# Windows
# Just double-click the .llamafile or run:
mistral-7b-instruct-v0.2.Q4_0.llamafile.exe --server

Server runs at http://localhost:8080 by default.

βš™οΈ Option 3: Custom API

Any OpenAI-compatible API endpoint works:

  • LM Studio
  • LocalAI
  • Text Generation WebUI (with --api flag)
  • vLLM
  • Any other OpenAI-compatible server

πŸš€ Installation

Step 1: Locate Your Inkscape Extensions Directory

Windows:

C:\Users\[YourUsername]\AppData\Roaming\inkscape\extensions\

macOS:

~/Library/Application Support/org.inkscape.Inkscape/config/inkscape/extensions/

Linux:

~/.config/inkscape/extensions/

πŸ’‘ Tip: In Inkscape, go to Edit β†’ Preferences β†’ System to find your extensions directory.

Step 2: Install the Extension

  1. Create the extension folder:

    mkdir -p [extensions-directory]/text_gen
  2. Copy the files:

    cp text_gen.py [extensions-directory]/text_gen/
    cp text_gen.inx [extensions-directory]/text_gen/
  3. Set permissions (Linux/macOS):

    chmod +x [extensions-directory]/text_gen/text_gen.py
  4. Restart Inkscape

Step 3: Verify Installation

Open Inkscape and check: Extensions β†’ Text β†’ AI Text Generator


🎯 Quick Start

Generate New Text

  1. Open Inkscape
  2. Go to Extensions β†’ Text β†’ AI Text Generator
  3. In the Mode tab, select Create
  4. In the Prompt tab, enter your prompt:
    Write a catchy tagline for a coffee shop
    
  5. Click Apply

Translate Existing Text

  1. Select a text object in your document
  2. Open Extensions β†’ Text β†’ AI Text Generator
  3. Select Translate mode
  4. Choose target language (e.g., "French")
  5. Click Apply

πŸ“– Usage Guide

Tab Overview

Tab Purpose
Mode Select operation (create, modify, translate, etc.)
Prompt Enter your text generation prompt
Style Configure font, color, and decorations
Layout Set alignment, spacing, and positioning
Background Add optional background box
API Config Configure AI provider and model
Advanced Fine-tune generation parameters

Operation Modes

πŸ†• Create Mode

Generate new text from scratch.

Prompt: "Write a professional bio for a graphic designer"

✏️ Modify Mode

Change selected text based on instructions.

Selected text: "Our product is good"
Prompt: "Make it more enthusiastic and professional"
Result: "Our product delivers exceptional results that exceed expectations"

🌍 Translate Mode

Convert text to another language while preserving meaning.

Selected text: "Welcome to our store"
Target language: Spanish
Result: "Bienvenido a nuestra tienda"

πŸ“ Summarize Mode

Condense long text to key points.

πŸ“š Expand Mode

Add detail and elaboration to short text.

πŸ”„ Rewrite Mode

Improve grammar, clarity, and style.

Style Options

Option Description Default
Font Family Any installed font Arial
Font Size Size in pixels 24
Font Weight normal, bold normal
Font Style normal, italic normal
Text Color Hex color code #000000
Text Decoration underline, overline, line-through none
Text Scale Multiplier (0.5 = half, 2.0 = double) 1.0

Position Modes

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ top_left    top_center    top_right β”‚
β”‚                                     β”‚
β”‚ middle_left   center   middle_right β”‚
β”‚                                     β”‚
β”‚ bottom_left bottom_center bottom_right β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • cursor: Place at selected object's center
  • Custom offsets: Add X/Y offset to any position

Tone Presets

Tone Effect
formal Professional, business language
casual Conversational, relaxed
professional Corporate, polished
friendly Warm, approachable
enthusiastic Energetic, excited
humorous Witty, playful
serious Straightforward, no-nonsense
poetic Artistic, metaphorical

βš™οΈ Configuration

API Configuration Tab

Setting Description Default
Provider ollama, llamafile, or custom ollama
API URL Server address http://localhost:11434
Model Model name (leave empty for auto-detect) (auto)
Auto-detect Automatically find available model βœ“

Advanced Tab

Setting Description Default
Temperature Creativity (0.0 = focused, 1.0 = creative) 0.7
Max Tokens Maximum response length 500
Remove Asterisks Strip markdown bold/italic markers βœ“
Remove Quotes Strip surrounding quotation marks βœ“
Capitalize First Ensure first letter is uppercase βœ—
Preserve Style Keep existing text styling when modifying βœ“

Provider-Specific URLs

Provider Default URL Notes
Ollama http://localhost:11434 Default Ollama port
llamafile http://localhost:8080 Default llamafile port
LM Studio http://localhost:1234 Default LM Studio port

πŸ’‘ Examples

Example 1: Create a Headline

Settings:

  • Mode: Create
  • Prompt: Write a bold headline for an eco-friendly product launch
  • Tone: Enthusiastic
  • Font Size: 48
  • Font Weight: Bold

Result:

🌱 Revolutionize Your World with Sustainable Innovation!

Example 2: Translate for Multilingual Poster

Settings:

  • Mode: Translate
  • Target Language: Japanese
  • Preserve Style: βœ“

Original: "Innovation starts here"
Result: "γ‚€γƒŽγƒ™γƒΌγ‚·γƒ§γƒ³γ―γ“γ“γ‹γ‚‰ε§‹γΎγ‚‹"

Example 3: Professional Bio

Settings:

  • Mode: Create
  • Prompt: Write a 2-sentence professional bio for a UX designer named Sarah
  • Tone: Professional
  • Max Tokens: 100

Result:

Sarah is an award-winning UX designer with over 8 years of experience crafting intuitive digital experiences. Her work spans Fortune 500 companies and innovative startups, where she transforms complex challenges into elegant, user-centered solutions.

Example 4: Expand a Tagline

Settings:

  • Mode: Expand
  • Tone: Friendly

Original: "Fresh coffee daily"
Result: "Every morning, we roast our carefully sourced beans to perfection, ensuring each cup delivers the rich, aromatic experience you deserve. Our commitment to freshness means your coffee is never more than 24 hours from roasting to your cup."


πŸ› Troubleshooting

Common Issues

Extension not appearing in menu

Solutions:

  1. Verify files are in the correct location:
    ls [extensions-directory]/text_gen/
    # Should show: text_gen.py, text_gen.inx
  2. Check file permissions (Linux/macOS):
    chmod +x text_gen.py
  3. View Inkscape error log:
    • Edit β†’ Preferences β†’ System β†’ Open Error Log
  4. Restart Inkscape completely
Cannot connect to Ollama

Error: Cannot connect to Ollama at http://localhost:11434

Solutions:

  1. Ensure Ollama is running:
    ollama serve
  2. Check if a model is installed:
    ollama list
  3. Pull a model if needed:
    ollama pull llama3.2
  4. Verify the URL in API Config tab
Model not found

Error: model 'xyz' not found

Solutions:

  1. List available models:
    ollama list
  2. Pull the required model:
    ollama pull [model-name]
  3. Enable "Auto-detect model" in API Config
  4. Manually enter the exact model name
Text not appearing in document

Solutions:

  1. Check the position mode settings
  2. Zoom out to see if text is off-canvas
  3. Try "center" position mode
  4. Check that the AI generated a response (look for errors)
Slow response times

Solutions:

  1. Use a smaller model:
    ollama pull phi3      # 1.5GB, very fast
    ollama pull tinyllama # 600MB, fastest
  2. Reduce max tokens (150-300 for simple tasks)
  3. Ensure your system has enough RAM
  4. Close other resource-intensive applications
Selected text not detected

Solutions:

  1. Ensure you've selected a text object (not a group or path)
  2. Click directly on the text with the Selection tool
  3. For grouped text, enter the group first (double-click)
  4. Check that the text element has actual text content

Debug Mode

Enable debug output to diagnose issues:

  1. Run Inkscape from terminal:
    inkscape
  2. Debug messages will appear in the terminal
  3. Check the Inkscape error log: Edit β†’ Preferences β†’ System β†’ Open Error Log

πŸ“Š Model Recommendations

Use Case Recommended Model Size Speed
Quick drafts phi3 or tinyllama 1-2GB ⚑⚑⚑
General text llama3.2 or mistral 4GB ⚑⚑
Translation qwen2.5 4GB ⚑⚑
Creative writing llama3.1:8b 8GB ⚑
Best quality llama3.1:70b 40GB 🐒

πŸ“ File Structure

text_gen/
β”œβ”€β”€ text_gen.py          # Main extension code
β”œβ”€β”€ text_gen.inx         # Inkscape extension definition
└── README.md            # This file

🀝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup:

git clone https://github.com/YouvenZ/textgen_ink.git
cd textgen_ink
# Symlink to extensions directory for testing
ln -s $(pwd) ~/.config/inkscape/extensions/text_gen

πŸ“„ License

This project is licensed under the MIT License - see LICENSE file for details.


πŸ“§ Support


πŸ™ Acknowledgments


πŸ”„ Changelog

v1.0.0 (2024)

  • ✨ Initial release
  • βœ… Ollama integration
  • βœ… llamafile support
  • βœ… 6 operation modes
  • βœ… Auto model detection
  • βœ… Rich styling options
  • βœ… 8 tone presets
  • βœ… Background box support
  • βœ… Markdown cleanup

About

Generate text with LLM directly inside inkscape

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages