Skip to main content

Automatic certificate generator with OCR-based placeholder detection (no external dependencies)

Project description

⭐ If you find CertiGen useful, consider starring the repo!

CertiGen 🎓

Automatic certificate generator with OCR-based placeholder detection. Generate hundreds of personalized certificates in seconds!

Features

  • 🔍 Auto-detect placeholder - Uses OCR to find "John Doe" or any placeholder text
  • 🎨 Auto-detect colors - Automatically extracts font and background colors
  • 📏 Smart text sizing - Automatically resizes text for long names
  • 📄 Multiple exports - PNG, PDF, or ZIP
  • ☁️ Cloud upload - S3 and Google Drive support
  • 📧 Email - Send certificates directly via email
  • 🚀 No external dependencies - OCR works out of the box, no Tesseract needed!

Installation

pip install certigen

That's it! OCR is included and works offline. No external software required.

For cloud upload features:

pip install certigen[cloud]

Quick Start

Python API

from certigen import CertificateGenerator

# Basic usage - auto-detects everything
gen = CertificateGenerator(
    template_path="template.png",
    excel_path="names.xlsx",
    name_column="Name",
    font_path="arial.ttf",
    placeholder="John Doe"
)
gen.generate_all()

# Export options
gen.export_as_pdf()
gen.zip_certificates()

Command Line

# Basic usage
certigen -t template.png -e names.xlsx -f arial.ttf

# With options
certigen -t template.png -e names.xlsx -f arial.ttf -p "John Doe" --pdf --zip

# Find coordinates interactively
certigen -t template.png --find-coords

How It Works

  1. OCR Detection - Scans your template to find the placeholder text (e.g., "John Doe")
  2. Color Extraction - Automatically detects text color and background color
  3. Font Matching - Estimates the font size from the placeholder
  4. Generation - Replaces placeholder with each name, auto-scaling for long names

Advanced Usage

Manual Position Override

If OCR doesn't detect the placeholder correctly:

gen = CertificateGenerator(
    template_path="template.png",
    excel_path="names.xlsx",
    name_column="Name",
    font_path="arial.ttf",
    manual_position=(800, 600),  # (x, y) center point
    font_color=(0, 0, 0),        # RGB black
    bg_color=(255, 255, 255),    # RGB white
)

Cloud Upload

# AWS S3
gen.upload_to_s3(
    bucket="my-bucket",
    access_key="...",
    secret_key="...",
)

# Google Drive
gen.upload_to_drive(
    credentials_path="service_account.json",
    folder_id="..."
)

Email Certificates

gen.email_certificates(
    smtp_server="smtp.gmail.com",
    smtp_port=587,
    sender_email="you@gmail.com",
    sender_password="app_password",
    recipient_emails=["recipient@example.com"]
)

Parameters

Parameter Description Default
template_path Path to certificate template image Required
excel_path Path to Excel/CSV file with names Required
name_column Column name containing names Required
font_path Path to .ttf font file Required
placeholder Text to find and replace "John Doe"
output_dir Output directory "output"
font_color RGB tuple for text color Auto-detected
bg_color RGB tuple for background Auto-detected
manual_position (x, y) to override OCR None
base_font_size Starting font size 180
min_font_size Minimum font size 60
verbose Print progress True

CLI Options

Option Description
-t, --template Template image path (required)
-e, --excel Excel/CSV file with names (required)
-f, --font Font file path (required)
-c, --column Column name for names (default: "Name")
-o, --output Output directory (default: "output")
-p, --placeholder Placeholder text (default: "John Doe")
--font-color Font color as R,G,B
--bg-color Background color as R,G,B
--position Manual position as X,Y
--pdf Create combined PDF
--zip Create ZIP archive
--find-coords Interactive coordinate finder

Changelog

v1.1.0

  • Replaced Tesseract with RapidOCR (no external dependencies!)
  • OCR now works out of the box with just pip install
  • Removed tesseract_path parameter

v1.0.0

  • Initial release

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

certigen-1.1.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

certigen-1.1.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file certigen-1.1.0.tar.gz.

File metadata

  • Download URL: certigen-1.1.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for certigen-1.1.0.tar.gz
Algorithm Hash digest
SHA256 9be18d70e272d04cc42be2bd5c7d9d566bb6abab95918d24481a1d5270805383
MD5 e90ea67b5dbce3a49a93a3ddc6b83d2f
BLAKE2b-256 bb0a7edaffc5b4cdeed33f05446af594297124117f6cc4f3c8aa7dae9dff4e36

See more details on using hashes here.

File details

Details for the file certigen-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: certigen-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for certigen-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e7e01d0c8d8c5180e6f1fb8173687b6be46f26d239397588f6b20d0bbbb8825
MD5 61a6d97b0a650c1044cf3a86cb436f6f
BLAKE2b-256 234566ed3a2e4cb51856c91f34b068ce17c8df9fb9bf869e9bc5cdaae47852f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page