fbpx

How to Use Google Colab to Create Custom QR Codes for Fundraising

Do you like that custom fundraising QR code above? Making it is easy peasy if you have the right tools, all of which happen to be free.

As you might know, the humble QR code has become a big thing. At one point, it seemed to be on the verge of slowly drifting off into the oblivion of lost technology, but the pandemic resuscitated the tech because it made it easy for businesses, restaurants especially, to share internet links with their customers without any contact. The now-famous Coinbase Superbowl commercial with the floating QR code that crashed their website seems to have solidified the phenomenon.

Fundraisers have jumped on this bandwagon, using QR codes to get donation links to their supporters at events, on business cards, or on business reply envelopes. The only problem with QR codes is that they seem pretty impersonal—a little square with machine-readable information hidden in what looks to the human eye like random television static.

That's why I got excited when I found a Python library that would easily enable me to create custom QR codes overlaid on a color image. I tried it with the food bank's logo and the result is what you see at the top of the post. It looks pretty snazzy if I do say so myself, and it uses the food bank's new logo in a way that makes it feel more personal.

How to make your own custom QR codes using Google Colab. Even if you know nothing about programming.

If you're not a computer programmer, it's unlikely that you've heard about Google Colab. It's a way to do programming in the cloud that gives tremendous flexibility. I'm not going to go into tremendous detail in this post on how to use Colab. What I want to do is teach you enough so that you can use it to create your own custom QR codes for your organization.

Now, this is not the only way to use this Python library to create QR codes, but I think it's easy enough that just about anyone can do it. It will also set you up to create as many QR codes as you need, without having to pay someone to create or activate your QR codes.

If you have a Gmail account (like pretty much every other person on the planet) it's pretty easy. Start by going to https://colab.research.google.com/. Your Gmail account should connect immediately. If you don't have a Gmail account, you'll want to set one of those up first (Google it). You should get an interface that looks something like this:

If the first window that you get has the little beginner's guide to Colab, you can read through that if you like, but you don't really need to for our purposes. Click on the File menu and select New Notebook.

Above the File menu, you'll see something like Untitled4.ipynb, which is the name of your new notebook. Change it to something like QRGenerator.ipynb, or something that you'll remember the next time you're looking for your handy dandy QR code generator.

Next, you're going to look for the open code cell, which is right here:

Copy and paste the following code into this cell:

!pip install amzqr
from PIL import Image
from google.colab import drive
drive.mount('/content/drive')

This code does several things. The first line installs the python library that will be doing the work of converting your logo into a QR code. You can read the full documentation on the library on GitHub here. The second line imports the image library that will assist with the process. The third line imports the Google library that will enable you to download your logo directly from your Google Drive and save your new QR code back to a convenient folder in Google drive. The brilliant thing about Colab is that all of this code is running on Google's cloud. You're not downloading software onto your business or personal computer. And when you close Colab, the program just shuts down, ready for you to fire up again the next time you want to create a QR Code.

Prepping your files.

For the next step, you'll need to open up your Google Drive in another tab or browser. If you've never done that before, click Google Drive. Again, it should automatically connect to your main Google account.

Create a new folder called QRCodes. You'll access this folder from Colab to both get the logo file and save the new custom QR code. Create a png or jpeg of your logo file that is square. I've found using one that is 500px by 500px works nicely. Save it in the QRCodes file using a name that doesn't use any spaces. Use underscores instead of spaces or no spaces at all.

Now you're ready to Colab to Google Drive.

Connect to Google Drive.

Go back to your Colab notebook. You should have one code cell that looks like this:

Now click the little circle with the "play" icon next to the code that you copied and pasted. It should respond by turning into a "doing something" icon. The program will get to the point where it wants to connect to your Google drive and will give you a screen that looks like this:

Click the button that says "Connect to Google drive. This will bring up a second dialogue window asking you to pick which Gmail account you want to use. Choose the one that contains the folder and logo that you just created. The box looks like this:

After you pick the account, scroll to the bottom and give permission to connect. And don't worry. As soon as you close Colab, this connection will be closed. Colab will ask you to reestablish this connection every time you start a new session.

If you look on the left side of the Colab window, you'll see a folder icon that you can click. When you click it, it will open a nested file system that you now have access to. If you click "Drive," you should now see "MyDrive" as an option. That's your Google drive. Clicking that should open up the Drive files and allow you to find the "QRCode" folder. If you don't see "Drive" or "MyDrive", then click the refresh button under the file menu. If you open that, you should see your logo PNG.

Create the QR Generator.

Alright, you're almost home free. One more main step. If you hover your mouse over the box that holds the code that you just ran, you'll see two buttons appear saying "code" or "text." Click the code button. It will create a new cell that you can use. Copy and paste the following code into that new cell:

!amzqr https://goldenharvest.org/donate/ -n /content/drive/MyDrive/QRcode/MainDonateQR.png -p /content/drive/MyDrive/QRcode/Icon_Green_Background.png -c

Don't run this yet. You have some changes that you need to make first. This code has three main inputs.
  • The first input (which in the example is https://goldenharvest.org/donate/) is the URL that you want the QR code to target. Change it to whatever you want.
  • After the "-n" (which signifies name), that path ending in a file name is the place you want to put the new QR code and the name you want to give it. In my example, the name of the file will be MainDonateQR.png and it will go in the same folder as the picture of my logo.
  • After the -p(which signifies picture), you'll put the path and name for the picture that you want to use for your QR code. What's nice is that you can use the file system to give you that info very easily. If you hover over a file in the file system, you'll see three dots showing that you can access a menu. When you click on the three dots, you'll get the menu that includes the option shown for "Copy Path". Just find your logo file, copy the path, and paste it after -p.
  • Just so you know, the -c at the end signifies that you want the resulting code in color. If you take it off, it will create the code in black and white, which might look crummy.

Finish it!

Once you've modified the target URL, the destination filename with path, and the photo filename with path, you're ready to go. Just click the play button and wait 2.5 seconds. If you click the refresh button on your files, voila!, there is your new QR code. Just click on the three dots next to the file and download it to your main machine.

This may sound like a lot of work, but you now have a QR code generator that you can use as many times as you want to. Just change the target URL, file name, and photo name, and this little program will crank out QR code after QR code. And it won't cost you a thing.

One final thought. You might want to consider using some kind of redirect manager on your website to make sure that old QR codes point to someplace useful. The codes are supposed to be helpful, but if you have a lot of old and disconnected QR codes floating around, it might become a problem. If you have the QR code pointing to a page on your site that directs them to the target page, you can easily go back and change the redirect to make sure that all of your old QR codes out in the world are still pointing someplace useful.

I hope you found this guide helpful and that this gives you many useful codes!


If you liked this article, check out the new main page for theAlmoner.com. Every day it pulls fresh articles about fundraising from around the web to help keep your fundraising skills sharp and your creative juices flowing.