Created by devag7 (Dev Agarwalla)
Generate beautiful, professional certificates with QR codes in seconds!
This is a complete certificate generation system that automatically creates professional PDF certificates with:
- ๐ Custom text (names, courses, dates, etc.)
- ๐ QR codes for verification
- ๐จ Beautiful design using your template
- โก Fast processing (under 1 second per certificate)
- ๐ PDF output ready for printing or sharing
Perfect for schools, training centers, online courses, or any organization that issues certificates!
Input:
{
"user_name": "John Doe",
"college": "Tech Academy",
"topic": "Python Programming",
"certificate_id": "CERT-2024-001"
}
Output: Beautiful PDF certificate with QR code verification!
# macOS
brew install ffmpeg imagemagick
# Ubuntu/Linux
sudo apt install ffmpeg imagemagick
# Windows (with Chocolatey)
choco install ffmpeg imagemagick
git clone https://github.com/devag7/certificate-generator.git
cd certificate-generator
pip install -r requirements.txt
python producer.py
That's it! Your certificate will be in the certificates/
folder! ๐
certificate-generator/
โโโ ๐ producer.py # Main script to generate certificates
โโโ โ๏ธ tasks.py # Core generation logic
โโโ ๐ ๏ธ utils.py # Helper functions
โโโ ๐งช test_suite.py # Tests
โโโ ๐ requirements.txt # Dependencies
โโโ ๐ณ Dockerfile # Docker setup
โโโ ๐ templates/ # Certificate template images
โโโ ๐ค fonts/ # Font files
โโโ ๐ certificates/ # Generated certificates (created automatically)
- Edit the data in
producer.py
:
cert_data = {
"user_name": "Your Name Here", # Student/recipient name
"college": "Your Institution", # School/company name
"topic": "Course Name", # What the certificate is for
"certificate_id": "CERT-001", # Unique ID
"issued_at": "2024-06-10" # Date issued
}
- Run the generator:
python producer.py
- Find your certificate in the
certificates/
folder!
from tasks import generate_certificate
# Your certificate data
data = {
"user_name": "Jane Smith",
"college": "Digital University",
"topic": "Web Development",
"certificate_id": "WEB-2024-001",
"issued_at": "2024-06-10T15:30:00"
}
# Generate certificate
certificate_path = generate_certificate(data)
print(f"Certificate created: {certificate_path}")
from tasks import generate_certificate
# List of students
students = [
{"user_name": "Alice Johnson", "college": "Tech Academy", "topic": "Python Basics"},
{"user_name": "Bob Smith", "college": "Code School", "topic": "Data Science"},
{"user_name": "Carol Williams", "college": "Dev Institute", "topic": "Web Design"}
]
# Generate certificates for all students
for student in students:
student["certificate_id"] = f"BATCH-{student['user_name'].replace(' ', '-')}"
student["issued_at"] = "2024-06-10"
certificate_path = generate_certificate(student)
print(f"โ
Generated: {certificate_path}")
- Add your template image to the
templates/
folder - Update the path in
tasks.py
:
TEMPLATE_PATH = BASE_DIR / "templates" / "your_template.jpg" # Change this line
Edit the text positions in tasks.py
(around line 100):
filter_chain = (
f"drawtext=text='{esc['name']}':x=90:y=880:fontsize=50:" # Name position
f"fontfile='{font_path}':fontcolor=black,"
f"drawtext=text='{esc['college']}':x=90:y=1050:fontsize=45:" # College position
f"fontfile='{font_path}':fontcolor=black,"
# Adjust x,y coordinates for your template
)
- Add
.ttf
font files to thefonts/
folder - Update font path in
tasks.py
:
FONT_PATH = BASE_DIR / "fonts" / "your_font.ttf" # Change this line
Start Redis and Celery (for processing many certificates):
# Terminal 1: Start Redis
redis-server
# Terminal 2: Start Celery worker
celery -A tasks worker --loglevel=info
# Terminal 3: Generate certificates
python producer.py # Will now use async processing
Create .env
file for custom settings:
# Copy from .env.example and modify
ASYNC_MODE=false # true for async processing
FONT_SIZE_NAME=50 # Name text size
FONT_SIZE_COLLEGE=45 # College text size
OUTPUT_DIR=certificates # Where to save certificates
# Build and run with Docker
docker-compose up -d
# Generate certificates via API
curl -X POST http://localhost:8000/generate \
-H "Content-Type: application/json" \
-d '{"user_name":"Test User","college":"Test College","topic":"Test Course"}'
# Run all tests
python test_suite.py
# Check system health
python -c "from tasks import health_check; import json; print(json.dumps(health_check(), indent=2))"
# Install FFmpeg
brew install ffmpeg # macOS
sudo apt install ffmpeg # Ubuntu
choco install ffmpeg # Windows
# Install ImageMagick
brew install imagemagick # macOS
sudo apt install imagemagick # Ubuntu
choco install imagemagick # Windows
- Make sure
certificate_template.jpg
exists intemplates/
folder - Check the file path in
tasks.py
- Ensure your font file exists in
fonts/
folder - The system will use default font if custom font is missing
# Fix ImageMagick policy for PDF
sudo sed -i 's/rights="none" pattern="PDF"/rights="read|write" pattern="PDF"/' /etc/ImageMagick-6/policy.xml
- โก Generation time: ~200ms per certificate
- ๐ Output size: ~200KB per PDF
- ๐ QR code: High resolution, fast scanning
- ๐พ Memory usage: Minimal (< 50MB)
- Input Validation - Checks that all required data is provided
- QR Code Generation - Creates verification QR code with certificate ID
- Text Overlay - Uses FFmpeg to add text to certificate template
- PDF Conversion - Converts to PDF using ImageMagick
- File Optimization - Compresses output for smaller file size
- Cleanup - Removes temporary files
- ๐ Educational institutions - Course completion certificates
- ๐ข Corporate training - Employee certification
- ๐ Online courses - MOOC/e-learning certificates
- ๐ Events & competitions - Award certificates
- ๐ค Professional development - Skill certification
- Certificate API - REST API for certificate generation
- Web interface - Upload CSV, generate bulk certificates
- Integration - Add to existing LMS/education platforms
- Verification system - QR code verification portal
- White-label solution - Customize for clients
Found a bug? Have an idea? Contributions welcome!
- Fork the repository
- Create feature branch:
git checkout -b feature/awesome-feature
- Make changes and test:
python test_suite.py
- Commit:
git commit -m 'Add awesome feature'
- Push:
git push origin feature/awesome-feature
- Create Pull Request
- ๐ Bug reports: Create an issue
- ๐ก Feature requests: Start a discussion
- ๐ง Email: [email protected]
MIT License - feel free to use in your projects!
Created with โค๏ธ by devag7 (Dev Agarwalla)
Special thanks to:
- FFmpeg team for video/image processing
- ImageMagick for PDF conversion
- Celery for async task processing
- Python community for amazing libraries
โญ Found this useful? Give it a star! โญ
๐ Ready to generate your first certificate? Run python producer.py
now! ๐