Giter Site home page Giter Site logo

asibhossen897 / certificategenerator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tusharnankani/certificategenerator

0.0 0.0 0.0 1.48 MB

A blazing fast mass certificate generator script for the community ⚡

Home Page: https://tusharnankani.github.io/CertificateGenerator

Python 100.00%

certificategenerator's Introduction




A simple mass certificate generator script for the community ⚡


Source Code   ·   Docs   ·   Raw Script


Docs

All you need

  • Certificate
  • Logo
    • If you want to add your logo to the template, get a transparent .png file of your logo like this.
  • Font
    • A .ttf (True-Type Font) file like this, can simply be downloaded from here.
  • Names
    • Finally, a list of names in a .txt format or a .csv format.

Pillow module

Using the pillow module to make changes.

  • Calculating and declaring default values.
from PIL import Image, ImageFont, ImageDraw

'''Global Variables'''
FONT_FILE = ImageFont.truetype(r'resources/font/GreatVibes-Regular.ttf', 180)
FONT_COLOR = "#FFFFFF"

template = Image.open(r'resources/templates/template.png')
WIDTH, HEIGHT = template.size

  • Placing the name on the certificate and saving to a different directory.
def make_certificates(name):
  '''Function to save certificates as a .png file
  Finding the width and height of the text. 
  Placing it in the center, then making some adjustments.
  Saving the certificates in a different directory.
  '''

  image_source = Image.open(r'resources/templates/template.png')
  draw = ImageDraw.Draw(image_source)
  name_width, name_height = draw.textsize(name, font=FONT_FILE)
  draw.text(((WIDTH - name_width) / 2, (HEIGHT - name_height) / 2 - 30), name, fill=FONT_COLOR, font=FONT_FILE)

  image_source.save("./out/" + name + ".png")
  print('Saving Certificate of:', name)

Logo

  • Setting up the logo file to place in the template
# Adding the logo
logo = Image.open(r'resources/logo/logo.png')
logo_width, logo_height = logo.size

# Placing it in the top middle
logo_position = ((WIDTH - logo_width) // 2, (HEIGHT - logo_height) // 12)
image_source.paste(logo, logo_position, logo)

Names

  • Using readlines() method with a .txt format.
names = []

with open('names.txt') as f:
    content = f.readlines()
    for item in content:
        names.append(item[:-1].title())

import pandas
names = pandas.read_csv('names.csv', sep='#')

Script in action


Without placing the logo

Template Result

With placing the logo

Template Result

Design Courtesy @GauravRaj


Future Scope?

  • More customisations
  • Directly e-mail as certificates are generated
  • A web interface?



Authors

Tushar Nankani

Asib Hossen

certificategenerator's People

Contributors

tusharnankani avatar asibhossen897 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.