A Python application that generates professional visual family tree diagrams from text input files using Graphviz, with support for member photos across multiple generations.
This project reads family relationship data from text files and generates beautiful, hierarchical family tree visualizations with:
- Automatic hierarchical tree layout (top-to-bottom)
- Professional node styling with colors
- Perfect line connections with Graphviz (red marriage lines, gray distribution lines)
- Support for member photos (automatically converted to passport size)
- Clean, publication-quality output with bold, large names
- Support for unlimited generations
- β Automatic hierarchical tree layout (top-to-bottom)
- β T-shaped family tree structure for clear parent-child relationships
- β Red marriage lines connecting spouses
- β Gray distribution lines from parents to children
- β Professional node styling with photos and colored placeholders
- β Support for member photos with automatic conversion to passport size (300Γ300px)
- β Bold, large names for easy readability
- β Clean, publication-quality output
- β Support for multiple family trees and unlimited generations
- β Automatic photo processing and optimization
FamilyTree/
βββ input/
β βββ people.txt # Family members registry
β βββ FamilyTree.txt # Family relationships
β βββ photo/ # Member photos folder
βββ output/
β βββ FamilyTree.png # Generated family tree diagram
β βββ photos/ # Processed passport photos
βββ main.py # Main application
βββ requirements.txt # Python dependencies
βββ .gitignore # Git ignore rules
βββ README.md # This file
python3 -m venv ftenv
source ftenv/bin/activate # On Windows: ftenv\Scripts\activatepip install -r requirements.txtOn Ubuntu/Debian:
sudo apt-get install graphvizOn macOS:
brew install graphvizOn Windows: Download from https://graphviz.org/download/
Create input/people.txt with format: Level - Full Name - Gender
# Generation A (Grandparents)
A - Raj Kumar Singh - Male
A - Priya Singh - Female
# Generation B (Parents)
B - Arjun Singh - Male
B - Divya Singh - Female
# Generation C (Children)
C - Aditya Singh - Male
C - Shreya Singh - Female
Create input/FamilyTree.txt with relationship statements:
# Marriages
Raj is husband of Priya
Arjun is husband of Divya
# Parent-Child Relationships
Raj is father of Arjun
Priya is mother of Arjun
Arjun is father of Aditya, Shreya
Divya is mother of Aditya, Shreya
Place family member photos in input/photo/:
- Name files:
FirstName.pngorFirstName LastName.jpg - Supported formats: JPG, PNG, BMP, GIF, TIFF
- Any size (automatically converted to 300Γ300px passport size)
input/photo/
βββ Raj.png
βββ Priya.jpg
βββ Arjun.png
βββ Divya.jpg
python main.pyThe generated family tree will be saved as output/FamilyTree.png
Level - Full Name - Gender
- Level: Single letter (A, B, C, D...) representing generation
- A = Grandparents/Ancestors
- B = Parents
- C = Children
- D = Grandchildren (and so on)
- Full Name: Complete name (e.g., "John Smith", "Raj Kumar Singh")
- Gender: Male or Female (for reference, not used in visualization)
Three types of relationship statements:
1. Husband Relationship:
Name is husband of SpouseName
2. Father Relationship:
Name is father of Child1 and Child2
or
Name is father of Child1, Child2 and Child3
3. Mother Relationship:
Name is mother of Child1 and Child2
or
Name is mother of Child1, Child2, Child3 and Child4
people.txt:
# Generation A (Grandparents)
A - Raj Kumar Singh - Male
A - Priya Singh - Female
# Generation B (Parents)
B - Arjun Singh - Male
B - Divya Singh - Female
B - Rohit Singh - Male
B - Anita Singh - Female
# Generation C (Children)
C - Aditya Singh - Male
C - Shreya Singh - Female
C - Vikram Singh - Male
C - Pooja Singh - Female
C - Ravi Singh - Male
# Generation D (Grandchildren)
D - Asha Singh - Female
D - Dev Singh - Male
FamilyTree.txt:
# Generation A to B
Raj is husband of Priya
Raj is father of Arjun, Rohit
Priya is mother of Arjun, Rohit
# Generation B (Couples)
Arjun is husband of Divya
Rohit is husband of Anita
# Generation B to C (Arjun and Divya's children)
Arjun is father of Aditya, Shreya
Divya is mother of Aditya, Shreya
# Generation B to C (Rohit and Anita's children)
Rohit is father of Vikram, Pooja, Ravi
Anita is mother of Vikram, Pooja, Ravi
# Generation C to D
Aditya is father of Asha, Dev
- Photos: Embedded with bold, large names below
- No Photo: Light blue boxes with dark blue borders
- Marriage Lines: Red color (no arrows)
- Parent-Child Lines: Gray color with arrows pointing to children
- Invisible Connector Nodes: Used internally for clean layout
- T-Shaped Family Units: Each married couple forms a T with their children
- Rank=Same Groupings: Siblings at same generation level stay horizontally aligned
- Large Canvas: 20Γ14 inches for excellent readability
- Generous Spacing: 2.0 node separation, 2.5 rank separation
- graphviz (0.20.1+): Python interface to Graphviz
- Pillow (10.1.0+): Image processing for photo conversion
- Python 3.10+
- Graphviz: System package for rendering diagrams
- PIL/Pillow: For image processing (installed via pip)
- Graphviz: Professional diagram generation engine (free, open source)
- Pillow (PIL): Image manipulation for passport photo processing
- Python 3.12: Application language
- DOT Language: Graph description language for Graphviz
- Converts any image format to PNG
- Crops images to square (maintains center)
- Resizes to 300Γ300 pixels (passport standard)
- Converts RGBA to RGB (handles transparency)
- Matches photos by:
- Exact first name match
- Full name match
- First name of full name
- 95% quality PNG compression
- Professional appearance in diagrams
- Consistent sizing across all members
- Marriages:
Name is husband of SpouseName - Fathers:
Name is father of Child1 and Child2 - Mothers:
Name is mother of Child1 and Child2 - Multiple Children: Use commas and "and" (
Child1, Child2 and Child3)
- β Unlimited generations (A, B, C, D, E...)
- β Multiple siblings per parent
- β Multiple spouses (each couple generates separate family unit)
- β Flexible relationship parsing
- β Automatic photo embedding and scaling
- β Professional publication-quality output
- Consistent Naming: Use the same name format in both people.txt and FamilyTree.txt
- Photo Naming: Name photo files matching the first name in people.txt
- Generation Levels: Assign appropriate levels (A, B, C...) to avoid layout issues
- Multiple Families: Create separate .txt files for different family branches
- Photo Quality: Use clear, professional photos for best results
Photos not appearing?
- Ensure file names match names in people.txt (case-sensitive)
- Check supported formats (JPG, PNG, BMP, GIF, TIFF)
- Verify
input/photo/folder exists
Names too small?
- Names are now bold (fontsize 13) for better readability
- Diagram size is 823Γ1344 pixels for large viewing
Graphviz not found?
- Install system Graphviz package (not just Python package)
- On Ubuntu:
sudo apt-get install graphviz
Relationships not parsing?
- Check FamilyTree.txt format matches examples
- Use "and" or commas to separate multiple children
- Verify name spelling matches people.txt exactly
This project is part of the FamilyTree family documentation system.
The system generates professional family tree diagrams showing:
- Multi-generation family structures
- Marriage connections (red lines)
- Parent-child relationships (gray lines)
- Family member photos with names
- Clear hierarchical organization
- Create people.txt β Define all family members with generation levels
- Create FamilyTree.txt β Define relationships between members
- Add photos (optional) β Place photos in
input/photo/ - Run script β
python main.py - View output β Open
output/FamilyTree.png
Happy family tree building! π³