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.


  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.


  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:

Sample Code

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”.


  • 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.


2 thoughts on “BASH: Certificate Generator

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.