├── .github └── workflows │ ├── codeql-analysis.yml │ └── python-app.yml ├── Aryan Raj.png ├── ID Card Generator.py ├── LICENCE.md ├── LICENSE ├── README.md ├── data.csv └── input.jpg /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ main ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ main ] 20 | schedule: 21 | - cron: '21 7 * * 6' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'python' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 37 | # Learn more about CodeQL language support at https://git.io/codeql-language-support 38 | 39 | steps: 40 | - name: Checkout repository 41 | uses: actions/checkout@v2 42 | 43 | # Initializes the CodeQL tools for scanning. 44 | - name: Initialize CodeQL 45 | uses: github/codeql-action/init@v1 46 | with: 47 | languages: ${{ matrix.language }} 48 | # If you wish to specify custom queries, you can do so here or in a config file. 49 | # By default, queries listed here will override any specified in a config file. 50 | # Prefix the list here with "+" to use these queries and those in the config file. 51 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 52 | 53 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 54 | # If this step fails, then you should remove it and run the build manually (see below) 55 | - name: Autobuild 56 | uses: github/codeql-action/autobuild@v1 57 | 58 | # ℹ️ Command-line programs to run using the OS shell. 59 | # 📚 https://git.io/JvXDl 60 | 61 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 62 | # and modify them (or add more) to build your code if your project 63 | # uses a compiled language 64 | 65 | #- run: | 66 | # make bootstrap 67 | # make release 68 | 69 | - name: Perform CodeQL Analysis 70 | uses: github/codeql-action/analyze@v1 71 | -------------------------------------------------------------------------------- /.github/workflows/python-app.yml: -------------------------------------------------------------------------------- 1 | # This workflow will install Python dependencies, run tests and lint with a single version of Python 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions 3 | 4 | name: Python application 5 | 6 | on: 7 | push: 8 | branches: [ main ] 9 | pull_request: 10 | branches: [ main ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Set up Python 3.9 20 | uses: actions/setup-python@v2 21 | with: 22 | python-version: 3.9 23 | - name: Install dependencies 24 | run: | 25 | python -m pip install --upgrade pip 26 | pip install flake8 pytest 27 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi 28 | - name: Lint with flake8 29 | run: | 30 | # stop the build if there are Python syntax errors or undefined names 31 | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics 32 | # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide 33 | flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics 34 | - name: Test with pytest 35 | run: | 36 | pytest 37 | -------------------------------------------------------------------------------- /Aryan Raj.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aryanraj2713/ID-card-generator-using-python/299a0d6557d9c260635086053b4845ef933ac307/Aryan Raj.png -------------------------------------------------------------------------------- /ID Card Generator.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Aug 14 06:39:07 2020 4 | 5 | @author: Aryan raj 6 | """ 7 | 8 | from PIL import Image, ImageDraw, ImageFont 9 | image=Image.new('RGB',(1000,900),(255,255,255)) 10 | draw=ImageDraw.Draw(image) 11 | font=ImageFont.truetype('arial.ttf', size=45) 12 | import random 13 | import os 14 | import datetime 15 | import textwrap 16 | os.system("Title ID Card Generator") 17 | d_date=datetime.datetime.now() 18 | reg_format_date=d_date.strftime("%d-%m-%Y\t\t\t\t\t ID CARD Generator\t\t\t\t\t %I:%M:%S %p") 19 | print('+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') 20 | print(reg_format_date) 21 | print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") 22 | #starting position of message 23 | print('\n\nAll fields are Mandatory') 24 | print('Avoid any kind of Spelling Mistakes') 25 | print('Write Everything in uppercase letters') 26 | (x,y)=(50,50) 27 | message = input('\nEnter your School Name:') 28 | company=message 29 | color='rgb(0,0,0)' 30 | font=ImageFont.truetype('arial.ttf',size=80) 31 | draw.text((x,y),message,fill=color,font=font) 32 | 33 | 34 | 35 | (x,y)=(600,75) 36 | idno=random.randint(1000000,9000000) 37 | message=str('ID'+str(idno)) 38 | color='rgb(0,0,0)' 39 | font=ImageFont.truetype('arial.ttf',size=60) 40 | draw.text((x,y),message,fill=color,font=font) 41 | 42 | 43 | 44 | (x,y)=(50,150) 45 | name='Name' 46 | color='rgb(255,0,0)' 47 | draw.text((x,y),name,fill=color,font=font) 48 | 49 | (x,y)=(50,220) 50 | 51 | message=input('Enter your full Name:') 52 | name=message 53 | 54 | color='rgb(0,0,0)' 55 | font=ImageFont.truetype('arial.ttf',size=60) 56 | draw.text((x,y),message,fill=color,font=font) 57 | 58 | 59 | (x,y)=(45,300) 60 | gen='Branch' 61 | color='rgb(255,0,0)' 62 | draw.text((x,y),gen,fill=color,font=font) 63 | 64 | (x,y)=(50,350) 65 | branch=input('Enter Your School Branch:') 66 | color="rgb(0,0,0)" 67 | draw.text((x,y),branch,fill=color,font=font) 68 | 69 | (x,y)=(300,300) 70 | sem='Term' 71 | color='rgb(255,0,0)' 72 | draw.text((x,y),sem,fill=color,font=font) 73 | (x,y)=(300,350) 74 | 75 | age=input('Enter Your Term:') 76 | color='rgb(0,0,0)' 77 | draw.text((x,y),age,fill=color,font=font) 78 | 79 | 80 | (x,y)=(50,420) 81 | dobir='Date of Birth' 82 | color='rgb(255,0,0)' 83 | draw.text((x,y),dobir,fill=color,font=font) 84 | 85 | (x,y)=(60,470) 86 | dob=input("Enter your DOB:") 87 | color='rgb(0,0,0)' 88 | draw.text((x,y),dob,fill=color,font=font) 89 | 90 | 91 | (x,y)=(50,530) 92 | bd='Blood Group' 93 | color='rgb(255,0,0)' 94 | draw.text((x,y),bd,fill=color,font=font) 95 | 96 | (x,y)=(50,580) 97 | bgrp=input('Enter Blood Group:') 98 | color='rgb(0,0,0)' 99 | draw.text((x,y),bgrp,fill=color,font=font) 100 | 101 | (x,y)=(50,640) 102 | mb='Mobile No' 103 | color='rgb(255,0,0)' 104 | draw.text((x,y),mb,fill=color,font=font) 105 | 106 | (x,y)=(50,690) 107 | mo=input("Enter your Mobile Number:") 108 | temp=mo 109 | color='rgb(0,0,0)' 110 | draw.text((x,y),mo,fill=color,font=font) 111 | 112 | 113 | (x,y)=(50,740) 114 | ad='Address' 115 | color='rgb(255,0,0)' 116 | draw.text((x,y),ad,fill=color,font=font) 117 | 118 | (x,y)=(50,800) 119 | add=input('Enter Your Address:') 120 | color='rgb(0,0,0)' 121 | draw.text((x,y),add,fill=color,font=font) 122 | image.save(str(name)+'.png') 123 | 124 | #save the edited image 125 | 126 | image.save(str(name)+'.png') 127 | 128 | import csv 129 | row=[str(idno),str(name),str(gen),str(age),str(dobir),str(bgrp),str(mo),str(add)] 130 | with open('data.csv','a') as csvfile: 131 | writer=csv.writer(csvfile) 132 | writer.writerow(row) 133 | 134 | csvfile.close() 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Aryan Raj 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ID-card-generator-using-Python 2 | Generates ID card with all details for organization/school and gives png image of ID card and save record in a csv file. 3 | 4 | ![Id Card generator Using Python](https://user-images.githubusercontent.com/75358720/149663713-c46d9049-d777-4842-9591-623f53a4b89c.png) 5 | 6 | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 7 | Some Libraries need to be installed in order to use- 8 | >pip install PIL 9 | > 10 | >pip install random 11 | > 12 | >pip install os 13 | > 14 | >pip install datetime 15 | > 16 | >pip install textwrap 17 | 18 | >pip install csv 19 | 20 | 21 | 22 | usually some of them are preinstalled but we can re-check once 23 | 24 | # Code- 25 | 26 | ## Setting up image boiler-plate - 27 | 28 | ``` 29 | from PIL import Image, ImageDraw, ImageFont 30 | image=Image.new('RGB',(1000,900),(255,255,255)) 31 | draw=ImageDraw.Draw(image) 32 | font=ImageFont.truetype('arial.ttf', size=45) 33 | import random 34 | import os 35 | import datetime 36 | import textwrap 37 | os.system("Title ID Card Generator") 38 | d_date=datetime.datetime.now() 39 | reg_format_date=d_date.strftime("%d-%m-%Y\t\t\t\t\t ID CARD Generator\t\t\t\t\t %I:%M:%S %p") 40 | print('+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') 41 | print(reg_format_date) 42 | print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") 43 | #starting position of message 44 | print('\n\nAll fields are Mandatory') 45 | print('Avoid any kind of Spelling Mistakes') 46 | print('Write Everything in uppercase letters') 47 | (x,y)=(50,50) 48 | message = input('\nEnter your School Name:') 49 | company=message 50 | color='rgb(0,0,0)' 51 | font=ImageFont.truetype('arial.ttf',size=80) 52 | draw.text((x,y),message,fill=color,font=font) 53 | 54 | ``` 55 | ## Giving every ID card a unique number- 56 | 57 | ``` 58 | (x,y)=(600,75) 59 | idno=random.randint(1000000,9000000) 60 | message=str('ID'+str(idno)) 61 | color='rgb(0,0,0)' 62 | font=ImageFont.truetype('arial.ttf',size=60) 63 | draw.text((x,y),message,fill=color,font=font) 64 | 65 | ``` 66 | ## Setting up details on PNG image- 67 | 68 | ``` 69 | (x,y)=(50,150) 70 | name='Name' 71 | color='rgb(255,0,0)' 72 | draw.text((x,y),name,fill=color,font=font) 73 | 74 | (x,y)=(50,220) 75 | 76 | message=input('Enter your full Name:') 77 | name=message 78 | 79 | color='rgb(0,0,0)' 80 | font=ImageFont.truetype('arial.ttf',size=60) 81 | draw.text((x,y),message,fill=color,font=font) 82 | 83 | 84 | (x,y)=(45,300) 85 | gen='Branch' 86 | color='rgb(255,0,0)' 87 | draw.text((x,y),gen,fill=color,font=font) 88 | 89 | (x,y)=(50,350) 90 | branch=input('Enter Your School Branch:') 91 | color="rgb(0,0,0)" 92 | draw.text((x,y),branch,fill=color,font=font) 93 | 94 | (x,y)=(300,300) 95 | sem='Term' 96 | color='rgb(255,0,0)' 97 | draw.text((x,y),sem,fill=color,font=font) 98 | (x,y)=(300,350) 99 | 100 | age=input('Enter Your Term:') 101 | color='rgb(0,0,0)' 102 | draw.text((x,y),age,fill=color,font=font) 103 | 104 | 105 | (x,y)=(50,420) 106 | dobir='Date of Birth' 107 | color='rgb(255,0,0)' 108 | draw.text((x,y),dobir,fill=color,font=font) 109 | 110 | (x,y)=(60,470) 111 | dob=input("Enter your DOB:") 112 | color='rgb(0,0,0)' 113 | draw.text((x,y),dob,fill=color,font=font) 114 | 115 | 116 | (x,y)=(50,530) 117 | bd='Blood Group' 118 | color='rgb(255,0,0)' 119 | draw.text((x,y),bd,fill=color,font=font) 120 | 121 | (x,y)=(50,580) 122 | bgrp=input('Enter Blood Group:') 123 | color='rgb(0,0,0)' 124 | draw.text((x,y),bgrp,fill=color,font=font) 125 | 126 | (x,y)=(50,640) 127 | mb='Mobile No' 128 | color='rgb(255,0,0)' 129 | draw.text((x,y),mb,fill=color,font=font) 130 | 131 | (x,y)=(50,690) 132 | mo=input("Enter your Mobile Number:") 133 | temp=mo 134 | color='rgb(0,0,0)' 135 | draw.text((x,y),mo,fill=color,font=font) 136 | 137 | 138 | (x,y)=(50,740) 139 | ad='Address' 140 | color='rgb(255,0,0)' 141 | draw.text((x,y),ad,fill=color,font=font) 142 | 143 | (x,y)=(50,800) 144 | add=input('Enter Your Address:') 145 | color='rgb(0,0,0)' 146 | draw.text((x,y),add,fill=color,font=font) 147 | 148 | ``` 149 | ## Saving PNG image- 150 | 151 | ``` 152 | image.save(str(name)+'.png') 153 | 154 | ``` 155 | ## Saving Data in a csv file 156 | 157 | ``` 158 | import csv 159 | row=[str(idno),str(name),str(gen),str(age),str(dobir),str(bgrp),str(mo),str(add)] 160 | with open('data.csv','a') as csvfile: 161 | writer=csv.writer(csvfile) 162 | writer.writerow(row) 163 | 164 | csvfile.close() 165 | 166 | ``` 167 | # Taking Input from User- 168 | 169 | ![Input from user](https://github.com/aryanraj2713/ID-card-generator-using-python/blob/main/input.jpg) 170 | 171 | # Generated Example ID card- 172 | 173 | ![Id card](https://github.com/aryanraj2713/ID-card-generator-using-python/blob/main/Aryan%20Raj.png) 174 | 175 | *Input details are saved in data.csv also for further reffrence* 176 | 177 | ## Contribution 178 | 179 | Contributions are always welcome! You can contribute to this project in the following way: 180 | - [ ] Adding feature to add image to ID card 181 | - [ ] Bug fixes 182 | - [ ] hosting using application 183 | 184 | ## Author 185 | 186 | * Aryan Raj 187 | 188 | [![ForTheBadge built-with-love](http://ForTheBadge.com/images/badges/built-with-love.svg)](https://GitHub.com/Naereen/) by [Aryan Raj](https://www.linkedin.com/in/aryan-raj-3a68b39a/) 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /data.csv: -------------------------------------------------------------------------------- 1 | B+ 2 | 6609268,Aryan Raj,Branch,2020-2021,13-12-2003,B+,xxxxxxxx91,"Delhi, India" 3 | -------------------------------------------------------------------------------- /input.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aryanraj2713/ID-card-generator-using-python/299a0d6557d9c260635086053b4845ef933ac307/input.jpg --------------------------------------------------------------------------------