BASH: Certificate Generator

Outline

To go green, this time, we decided to avoid printed certificates for department conference. And from there, came this concept.

Input: Certificate template, NAME, COLLEGE and EMAIL IDs of participants
Output: Generates certificates for each participant, and mails it to them.

Algorithm

  1. Generate NAME, COLLEGE and EMAIL list of participants.
  2. Place NAME, COLLEGE (text) on the certificate template (image) starting at given pixel coordinates.
  3. Fire an email client with EMAIL in to: and addressing NAME in body. I would recommend setting it to manually click send instead of automating it – little time consuming, but I suspect quick, automatic mailing to multiple email IDs may cause provider to blacklist you as a spammer.

Sample implementation

Here is how I implemented it – our conference had 85 participants. I used BASH, imagemagick and Thunderbird to achieve the target.

Reason I Chose:

  1. BASH – cut the codes short to less than 10 lines compared to Java/MATLAB which has its own advantages, but not worth the time.
  2. Thunderbird – Was already installed and configured to my taste and had
  3. convert – I’m on Linux Mint and it’s preinstalled.

Pre-requisites

  1. Any flavour of Linux
  2. “convert” from package imagemagick.
  3. Thunderbird configured with the right email ID.
  4. Certificate template in any common image format.
  5. A file named NameList.txt with NAME, COLLEGE, EMAIL  in one line each. File would look like:
NAME1
COLLEGE1
EMAIL1
NAME2
COLLEGE2
EMAIL2
...

Sample Code

FILE=../NameList.txt
cd Certificates
while read NAME; do
   read COLLEGE
   read MAIL
   convert ../Certificate.png -gravity North -pointsize 20 -annotate +100+318 "$NAME" Certificate.png
   convert Certificate.png -gravity North -pointsize 20 -annotate -200+345 "$COLLEGE" Certificate.png
   thunderbird -compose "from='someone@somedomain.com',subject='Conference Certificate',to='$MAIL',attachment='~/CGAM/Certificates/Certificate.png',format='html',body='Dear $NAME,<br/><br/>&emsp;Please find the certificate attached.<br/><br/>Regards<br/>Organising Secretary'"
done < "$FILE"

This code generates a temporary certificate in the folder Certificates notice that parameter “-annotate +100+318” in line 6 give s x and y coordinates of beginning of NAME text, and similarly in line 7 for COLLEGE text.

Certificate template is placed in the same folder as the script, called Certificate.png. Generated certificates will be placed in subfolder Certificates in  a temporary file “Certificate.png”.

Notes

  • Leave thunderbird closed while running the script else the script fails. (Script will not wait for mail to be send before generating next mail).
  • It’s imperfect enough, if interested, please make a better, neater, simpler app (I am lazy to! :D) so that the world can run it in few clicks.
  • Instead of thuderbird, you can automate mailing using command line utilities like “mail” or “msmtp” etc. Read more here.

Why did I post this stupid code/idea here? I don’t know – what if it helps someone, somewhere in future? I couldn’t find a neat app which does the same online, either! I will try inspire my students to take it up as a personal project and come up with some neat click-to-do codes as well.

Advertisements

House MD: a Gift Idea

A new doctor in friendlist! I didn’t feel like stopping at a mere congratulation, this is a rare event I must celebrate!

But what will I gift her?

A fake “ID” card? Fake prescription template? But what will make them unique?

That’s when my friend, kutti doctor’s sister called her “Lady Greg House”. I had no clue who it was, Google gave me Dr. Greg House from House M.D. Eureka.

That was followed by marathon House MD Season 1, thanks to Christy Varghese.

Then this happened.

ID Card
Front: Plainsboro ID card
Front: Plainsboro ID card
Back: Plainsboro ID card
Back: Plainsboro ID card

I played a bit with bar code and ID number – both translates to “Kutti Doctor”, what I call her. Barcodes can be generated for free online, for example, http://www.barcode-generator.org/ (choose Code-39 for text codes). For ID number, I used same idea as Facebook’s 92FACEBOOK number (typing in a T9 keypad gives their phone number, 9232232665), for the same text. Each item is in a different layer in RAW XCF file, or if you are not a pro, just use the images in this post (are of fairly good resolution for and ID card – actual sizes are 1/4th of what is there in image).

Prescription
Prescription Model, Concept from House MD
Prescription: Size: 1/2 A4

It had to be a bit “Indianised”, specially prescription, moving away from small square chit in House MD. (The prescription is shown in one of the episodes when elderly lady comes to return the prescription to House). There are two pages in file – print it as two pages in one page A4 for correct dimensions.

The paper folder
Folder and Prescription Printed

Now instead of binding the prescription papers, I made a folder, when folded, will give you half A4 size. I hope you will figure out where to fold/cut and stick. Also, little care should be taken to make sure that the prescription papers fit into the folder well before sticking. I also cut it along the border on top and it looked better than a square folder.

Copyright

You are free to use it as you wish. The logo of Princeton Placeboro et al should be the copyright of studios making House MD, so please don’t use it for mass printing. Raw files are in GIMP’s xcf format (I use GIMP), I can convert it for you if you want (leave a comment below). I’d be glad if you leave a word here in comments if you used the template, it’s really encouraging to know that it came to use for someone!

Raw Files:

Check out Google Drive Folder

On Selling Hobbies

Must confess I’ve been in a mood to brag about my works since morning, thanks to the radiation from Christy, who launched his website christyvarghese.in which I designed. And this forest of blogs is the best place to brag long as I don’t publish it on my facebook, and no one would notice it. This is the catalogue of the works I’ve done so far – so I think I can direct those who want to know more about my works/experience to this post.

Programming

  • Stock Market Simulation Game v. 1 (with C++), v. 2 (with Excel) (Lost the files and formulas)
  • ABASHGUI – A BASH GUI for Abinit, a DFT simulator with BASH and zenity (Files with me, can send to anyone who wants it)
  • Centipede Game (Java) – GPLv3, find code here.
  • Certificate Generator – BASH, Read more about it here.

Apps

Websites

  • Arabian Link, Saudi Arabia – http://www.arabianlk.com (I disown the content in the website :P)
  • Mpower App website – mpower.provisionasia.org
  • Christy Varghese, author – http://www.christyvarghese.in
  • proVISION ASIA blog (blog.provisionasia.org)
  • Santhosha Vidhyalaya Alumni Association (SVAA, svaa.org.in)

Graphic Design

T-Shirts

  • Department of Earth Sciences, Pondicherry University (GIMP)T_1.png
  • Department of Ecology, Pondicherry University (GIMP)Allignment.jpg
  • (3 more, can’t be published openly)

Brochures and Invites

  • DSS, Lady Doak College, Madurai (Brochure, MS Word)DSS1.PNG

Invitation (I lost the final copy with borders et al, MS Word)

20160629_114044.jpg

  • A wedding invite for a friend of mine who loved the colours of 70s and 80s: (leave a comment if you want it’s template, I can mail it to you – it’s in MS Word, so anyone can edit.)Invite-design.png
  • Cornerstone Trainers (Brochure)
  • Honesta Fashion, Singapore (Logo)
    fin-1.1.jpg

Random Stuff

Editing/Writing

Teaching

  • Hawkseye Academy, Eranakulam and Kannur (General Aptitude Trainer for UGC-NET Aspirants)
  • UV Physics Academy, Hyderabad (General Aptitude Trainer for CSIR-NET Aspirants)
  • Assisted Christy for a session at SB College, Changanacherry.
  • And programming, and mathematics

Art

Only picture I have – and it’s in the safest hands in the whole wide world now!

Image.jpg

…… and a lot of stuff I don’t remember/that cannot be published openly! Then there’s an array of handicraft (dolls, chalk carvings, random stuff with papers, recycled plastic, threads et al)/drawings (random designs) that I sold/gave away to the one who bid for it first, I think I deleted all those pictures. Listed them out here because later, if someone asks for my experience in any field, I can just point them to this post! Hope this list will keep increasing!