Skip to content

MainakJSR/FamilyTree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

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

Repository files navigation

FamilyTree Project

A Python application that generates professional visual family tree diagrams from text input files using Graphviz, with support for member photos across multiple generations.

NOTE : BEST TO SHOW ONLY 2 GENERATION OF SIBLINGS FROM BOTTOM. OTHERS SHOULD BE IN SEPERATE TREE.

πŸ“‹ Project Overview

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

✨ Features

  • βœ… 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

πŸ“‚ Project Structure

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

πŸš€ Quick Start

1. Setup Virtual Environment

python3 -m venv ftenv
source ftenv/bin/activate  # On Windows: ftenv\Scripts\activate

2. Install Dependencies

pip install -r requirements.txt

3. Install System Graphviz

On Ubuntu/Debian:

sudo apt-get install graphviz

On macOS:

brew install graphviz

On Windows: Download from https://graphviz.org/download/

πŸ“ How to Use

Step 1: Create people.txt (Family Members Registry)

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

Step 2: Create FamilyTree.txt (Relationships)

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

Step 3: Add Photos (Optional)

Place family member photos in input/photo/:

  • Name files: FirstName.png or FirstName 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

Step 4: Generate the Family Tree

python main.py

The generated family tree will be saved as output/FamilyTree.png

πŸ“– Input Format Specifications

people.txt Format

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)

FamilyTree.txt Format

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

Example Data

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

🎨 Visualization Details

Color Scheme

  • 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

Layout Structure

  • 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

πŸ“¦ Dependencies

Python Packages (in requirements.txt)

  • graphviz (0.20.1+): Python interface to Graphviz
  • Pillow (10.1.0+): Image processing for photo conversion

System Requirements

  • Python 3.10+
  • Graphviz: System package for rendering diagrams
  • PIL/Pillow: For image processing (installed via pip)

οΏ½οΏ½ Technology Stack

  • 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

πŸ“Έ Photo Processing

PhotoProcessor Features

  • 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:
    1. Exact first name match
    2. Full name match
    3. First name of full name

Photo Quality

  • 95% quality PNG compression
  • Professional appearance in diagrams
  • Consistent sizing across all members

🎯 Supported Relationship Types

  1. Marriages: Name is husband of SpouseName
  2. Fathers: Name is father of Child1 and Child2
  3. Mothers: Name is mother of Child1 and Child2
  4. Multiple Children: Use commas and "and" (Child1, Child2 and Child3)

πŸ“Š Diagram Features

  • βœ… 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

πŸ’‘ Tips and Best Practices

  1. Consistent Naming: Use the same name format in both people.txt and FamilyTree.txt
  2. Photo Naming: Name photo files matching the first name in people.txt
  3. Generation Levels: Assign appropriate levels (A, B, C...) to avoid layout issues
  4. Multiple Families: Create separate .txt files for different family branches
  5. Photo Quality: Use clear, professional photos for best results

πŸ› Troubleshooting

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

πŸ“„ License

This project is part of the FamilyTree family documentation system.

οΏ½οΏ½β€πŸ‘©β€πŸ‘§β€πŸ‘¦ Example Output

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

πŸ”„ Workflow

  1. Create people.txt β†’ Define all family members with generation levels
  2. Create FamilyTree.txt β†’ Define relationships between members
  3. Add photos (optional) β†’ Place photos in input/photo/
  4. Run script β†’ python main.py
  5. View output β†’ Open output/FamilyTree.png

Happy family tree building! 🌳

About

Will create a Family Tree Picture based on inputs provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages