QR Code Generator – Windows, Linux, MacOS

A QR code generator is an application which creates and stores different types of data in a QR code image file.

A qrencode is a free command line tool for encoding string data in the QR code and saving it as a PNG or an EPS image.

In this note i will show how to install and and how to use (with examples) the qrencode on Windows, Linux and MacOS from the command line.

Cool Tip: How to open a File Explorer from a Windows command prompt (CMD) or PowerShell ! Read more →

QR Code Generator

Install on Window

The qrencode for Windows doesn’t actually require installation – simply download the latest version of the QR code generator, extract the qrencode.exe and open a command prompt in that folder.

To open the command prompt, press the ⊞ Win + R shortcut to open the “Run” dialog, type in cmd and click “OK”, then navigate to the folder with the qrencode.exe, e.g.:

C:\Users\MyName> cd Downloads\QREncode-4.1.1_Win32
C:\Users\MyName\Downloads\QREncode-4.1.1_Win32> qrencode -V
qrencode version 4.1.1
Copyright (C) 2006-2017 Kentaro Fukuchi

Cool Tip: How to open a Windows command prompt (CMD) or PowerShell withing the current folder from a File Explorer! Read more →

Install on Linux & MacOS

To install the qrencode on Linux or MacOS:

# Linux
$ sudo apt install qrencode
# MacOS
$ brew install qrencode

Basic Usage of QR Code Generator

To generate a QR code from a command line use the following format:

$ qrencode -o <filename> "<data>"
- example -
$ qrencode -o qrcode.png "Some text"

By default, qrencode saves the generated QR code in a PNG format, but you can specify the type of the generated image using the -t or --type= options, e.g:

$ qrencode -t EPS -o qrcode.eps "Some text"
$ qrencode --type=ASCII -o qrcode.txt "Some text"

Supported formats:

PNG (default), PNG32, EPS, SVG, XPM, ANSI, ANSI256, ASCII, ASCIIi, UTF8, ANSIUTF8

You can also play with a size, width of the boarders and error tolerance of the QR code. e.g:

$ qrencode -s 3 -l L -m 4 -o qrcode.png "Some text"
Option Description
-s NUMBER, --size=NUMBER Specify module size in dots (pixels). Default 3.
-l {LMQH}, --level={LMQH} Specify error correction level from L (lowest) to H (highest). Default L.
-m NUMBER, --margin=NUMBER Specify the width of the margins. Default 4.

To change a foreground/background color of the generated QR code, set them in a hexadecimal notation using the correspondent options:

$ qrencode --foreground="4285F4" --background="FFFFFF" -o qrcode.png 'Some text'

QR Code Generation Examples

You can generate QR codes that will trigger different actions when scanned by a smartphone, for example:

# Display a text
$ qrencode -o qrcode.png "Some text"
# Open a location on a map
$ qrencode -o qrcode.png "geo:37.234332396,-115.80666344"
# Make a phone call
$ qrencode -o qrcode.png "tel:0123456789"
# Open an URL
$ qrencode -o qrcode.png "https://www.shellhacks.com"
# Send an email
$ qrencode -o qrcode.png "mailto:no_reply@shellhacks.com?subject=Hey&body=What's up?"
# Send an SMS message
$ qrencode -o qrcode.png "smsto:0123456789,The text of the SMS message."
# Connect to a Wi-Fi network
$ qrencode -o qrcode.png "WIFI:T:WPA2;S:box-12345;P:pa$$w0rd;;"

Cool Tip: How to open a File Manager from a terminal in Linux! Read more →

To add a contact using the QR code, create a file called contact.txt with a vCard data:

BEGIN:VCARD
VERSION:4.0
UID:urn:uuid:4fbe8971-0bc3-424c-9c26-36c3e1eff6b1
FN;PID=1.1:J. Doe
N:Doe;J.;;;
EMAIL;PID=1.1:jdoe@example.com
CLIENTPIDMAP:1;urn:uuid:53e374d9-337e-4727-8803-a1e9c14e0556
END:VCARD

… and pass this file to the QR code generator as follows:

$ qrencode -o qrcode.png < contact.txt

To trigger a creation of the event in a calendar, use the similar method, i.e. create a file called event.txt with a vEvent data:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:19970610T172345Z-AF23B2@example.com
DTSTAMP:19970610T172345Z
DTSTART:19970714T170000Z
DTEND:19970715T040000Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR

... and redirect this file to the QR code generator:

$ qrencode -o qrcode.png < event.txt

Leave a Reply