Make your own QR Codes

9 Nov

QR Codes are fun – as long as you’re not just taking me to Old Navy to buy a sweater. Want to generate your own? I will show you how in Python.

Note: Python has many modules that make it easy to do almost anything you can think of. Use them. They will make your life easier. To find some go to pypi.

Download and install the QrCode Package. You also need the Python Imaging Library (PIL).

All I did was copy the sample and add a variable to pass the data and a save(). Configure the program to pass a value via the command prompt, QT or the web – give a CherryPy application a shot!

Here is all the code it takes:

import qrcode
import PIL

url=’http://google.com’
mycode=qrcode.make(url)
mycode.show()
mycode.save(‘mycode.png’)

You can do more by using the QR Code Class – change the version and error correction levels. You can drop the show()too.

Here is my QR Code to Google.

Image

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: