How To Create QR Codes From The Linux Command Line

How To Create QR Codes From The Linux Command Line


Shutterstock/shisu_ka

QR Codes can do a complete lot extra than simply take you to a website. They usually’re straightforward to create on the Linux command line too. We present you ways.

QR Codes

Quick response (QR) codes are having fun with one thing of a resurgence, because of their use within the COVID-19 monitor and hint apps in lots of nations. They’re a handy approach to share info and to elicit a response from folks. Everybody carries a cellphone, so all of us carry an appropriate scanner with us. There are a lot of free QR and barcode scanning software program apps, so there isn’t any additional {hardware} required and no outlay for the software program.

Since its invention in 1994 by a highly commended team at Denso Wave, a subsidiary of Toyota, the QR code has discovered many new makes use of.

The QR code is able to holding way more info than a barcode, and due to its design, it’s potential for the scanner to work out which means up the QR code is, and to routinely orient the picture when it’s learn and decoded.

These traits are what made it so successful in its authentic function of monitoring inventories, assemblies, and elements in manufacturing unit manufacturing services. It doesn’t matter if the QR code or the merchandise it’s hooked up to isn’t completely aligned when it rolls by on a conveyor belt. The QR scanner can detect and skim the code no matter its orientation.

Why not use an internet QR code generator? There are a lot on the market, however a lot of them stipulate they’re allowed to retain and retailer the data you present them, and so they can do what they need with the information. for those who’re going to be creating QR codes with private or delicate info in them, comparable to contact particulars or Wi-Fi connection particulars, this poses a big safety danger.

All of your knowledge stays inside your management for those who use a command-line device like qrencode. It additionally permits you to create scripts and aliases to create QR codes programmatically.

RELATED: Why Threats from QR Codes are Flourishing

Makes use of for QR Codes

Outdoors of factories and manufacturing environments the QR might be most frequently used on promotional literature comparable to flyers, pamphlets, and posters. They’re additionally usually seen on product packaging. In these eventualities, the QR code sometimes accommodates a Uniform Resource Locator (URL) or internet deal with. The scanning app opens the web site for the consumer.

While you scan a QR code together with your cellphone it detects the kind of knowledge that has been encoded and provides to carry out an acceptable motion. For instance, if the information is a calendar occasion you’ll be requested if you wish to add the occasion to your calendar.

The actions that may be triggered by a QR code embrace:

  • Displaying textual content.
  • Navigating to some extent on a map.
  • Making a telephone name.
  • Sending an SMS message.
  • Sending an e-mail.
  • Opening a URL, to show a webpage or obtain a file.
  • Including a contact to your deal with guide.
  • Including an occasion to your calendar.
  • Connecting to a Wi-Fi community.

Putting in qrencode

qrencode is a flexible, quick, and richly-featured QR code generator. It gives a library that can be linked into your own programs to encapsulate the QR era know-how into your personal purposes. It additionally gives a command-line utility that we’re going to utilize.

To put in qrencode on Ubuntu, we kind this:

sudo apt-get set up qrencode

sudo apt-get install qrencode in a terminal window

To put in qrencode on Fedora, use this command:

sudo dnf set up qrencode

sudo dnf install qrencode in a terminal window

On Manjaro we use pacman:

sudo pacman -Sy qrencode

sudo pacman -Sy qrencode in a terminal window

The qrencode Parameters

There are two distinct units of parameters that we might want to go to qrencode. One set pertains to the creation and encoding of the QR codes, and the opposite specifies the information that we want the QR code to include.

The parameters that have an effect on the creation of the QR code resolve things like the dimensions of the QR code, the colour of the checkered sample and the background, and the error-correction settings.

The function of the QR code—whether or not it units up an SMS message for instance, or provides so as to add a contact to your deal with guide—is determined by the data contained in the QR code. It isn’t depending on the way in which the QR code was created. Key phrases and subject names determine the kind of encoded content material and permit the scanning software program to determine what it ought to do with the retrieved info.

Utilizing qrencode

Plain Textual content QR Codes

The only type of QR code accommodates plain textual content. It may be used to go any text-based info to the tip consumer. The qrencode parameters we’re utilizing are:

  • -s 6: This units the dimensions of the blocks within the QR checkered sample. The quantity you present units the dimensions in pixels for the size of 1 facet of a block.
  • -l H: This units the extent of error-correction. The choices we will use are “L” for low, “M” for medium, “Q” for fairly excessive, and “H” for top or highest. The totally different ranges of error-correction can deal with totally different quantities of injury or illegibility when the QR code is scanned. “Low” permits the code to be efficiently scanned if as much as seven % of the code is obscured or broken. “Medium” raises this to fifteen %. “Fairly excessive” can deal with as much as 25 % of the code being broken. The “Excessive” stage can deal with a whopping 30 % of injury or illegibility when the QR code is scanned. The extra error correction you utilize, the bigger the general QR code will likely be. It is because it must retailer redundant info which suggests there are extra blocks within the sample.
  • -o “textual content.png”: The output possibility permits you to set the identify of the generated picture. By default, this can be a Portable Network Graphics (PNG) picture. In the event you use the -t (kind) possibility you may change the output to quite a lot of codecs together with Encapsulated Postcript (EPS), Scalable Vector Graphics (SVG), and many alternative flavors of American National Standard Institute (ANSI) character-based output.

The textual content to be encoded is supplied final, and wrapped in citation marks.

qrencode -s 6 -l H -o "textual content.png" "Any such QR holds plain textual content. This textual content is proven to the consumer after they scan the QR code. No different motion is routinely triggered."

qrencode -s 6 -l H -o "text.png" "This type of QR holds plain text. This text is shown to the user when they scan the QR code. No other action is automatically triggered." in a terminal window

This command creates this QR code:

A plain text QR code

When it’s scanned the textual content is extracted and displayed within the scanning software program.

Scan results for a plain text QR code

The scanning app will present some solutions that you simply may wish to do. On this case—on this specific app—you may carry out an internet seek for the retrieved textual content or select to share the textual content with others.

Including Color

The --foreground and --background choices allow you to set colours for the QR code sample and background. You may specify the colour within the RGB color model six hexadecimal digit notation or the RGBA color model eight hexadecimal digit notation.

We’re utilizing the RGB notation. There are handy tables to look up color codes on the net. The foreground will likely be a shade of blue and the background will likely be white.

qrencode -s 6 -l H --foregound="3599FE" --background="FFFFFF" -o "blue.png" "This QR code will likely be blue and white."

qrencode -s 6 -l H --foregound="3599FE" --background="FFFFFF" -o "blue.png" "This QR code will be blue and white." in a terminal window

The QR code is generated in our chosen shade of blue.

A QR code in blue and white

It scans identical to some other QR code. In the event you do change the colours guarantee you’ve got sufficient distinction between the foreground and background in order that scanning apps can pick the checkered sample reliably.

Scan results for a colored QR code

Storing a Location in a QR Code

You may retailer the situation of one thing inside a QR code simply.

  • The data we retailer should begin with the key phrase geo.
  • Use a colon “:” to separate the key phrase from the situation knowledge.
  • The placement should be laid out in digital degrees.
  • Don’t go away any areas in the complete string, and use a comma “,” between the latitude and longitude values.

The qrencode choices are the identical as we’ve used earlier than. We’re altering the aim of the QR code just by altering the data saved inside it.

qrencode -s 6 -l H -o "geo.png" "geo:51.185013,-1.859105"

qrencode -s 6 -l H -o "geo.png" "geo:51.185013,-1.859105" in a terminal window

This produces this QR Code. The placement is the doorway to the automobile park at Stonehenge.

A location QR code

When it’s scanned the consumer is obtainable the prospect to take a look at the situation on a map or to get instructions to the situation.

Scan results for a location QR code

Storing a Cellphone Quantity in a QR Code

To retailer a telephone quantity inside a QR code use the tel key phrase, a colon “:“, and the telephone quantity, with no areas. It’s finest to not use hyphens and different punctuation within the quantity as a result of some scanning apps get confused. As an alternative of “(123) 456–7890” use “1234567890.”

qrencode -s 6 -l H -o "telephone.png" "tel:5555555555"

qrencode -s 6 -l H -o "phone.png" "tel:5555555555" in a terminal window

That is the QR code generated by that command:

A phone number QR code

When it’s scanned the app provides so as to add this as a quantity as a contact—you’ll want to offer the identify your self—or to ring the quantity for you.

Scan results for a phone number QR code

Sending an Electronic mail From a QR Code

You may add info to a QR code in order that the scanning app provides to ship an e-mail. You may present the vacation spot e-mail deal with, the e-mail topic, and the physique of the e-mail.

qrencode -s 6 -l H -o "e-mail.png" "mailto:contact@cloudsavvyit.com?topic=Linux&physique=Linux articles are cool."

  • The key phrase to make use of is mailto, with a colon ” : ” separating it from the e-mail deal with.
  • Use “?topic=” to determine the topic line. Don’t put areas earlier than or after the “?topic=” flag.
  • Use “&physique=” to determine the e-mail message contents. Don’t put areas earlier than or after the “&physique=” flag.

That is the ensuing QR code.

An email QR code

When that is scanned the app provides to ship the e-mail or so as to add the e-mail deal with as a contact.

Scan results for an email QR code

A Web site QR Code

To direct the consumer to an internet site or different URL, use the http or https key phrase, a colon ” : “, and the online deal with with no areas.

qrencode -s 6 -l H -o "URL.png" "https://cloudsavvyit.com"

This command creates this QR code.

qrencode -s 6 -l H -o "URL.png" "https://cloudsavvyit.com" in a terminal window

When the code is scanned the app provides to open the hyperlink.

Scan results for a URL QR code

Sending an SMS or MMS Message From a QR Code

The codecs to ship a Short Message Service (SMS) or a Multimedia Messaging Service (MMS) message are an identical. Use the key phrase smsto key phrase, a colon ” : “, the telephone quantity, a comma “,” with no areas, then the physique of the message.


qrencode -s 6 -l H -o "SMS.png" "smsto:5555555555,That is the textual content of the SMS message."

qrencode -s 6 -l H -o "SMS.png" "smsto:5555555555,This is the text of the SMS message." in a terminal window

That command produces this QR code:

An SMS QR code

When it’s scanned the consumer has the choice to ship both an SMS or an MMS message.

Scan results for an SMS QR code

Hook up with a Wi-Fi Community from a QR Code

It’s potential to encode the small print of a Wi-Fi community in a QR code. Guests can scan the QR code to simply hook up with your visitor Wi-Fi.

The key phrase is WIFI, adopted by a colon ” : ” and several other different parameters.

  • T: The kind of safety. This may be WEP, WPA, or WPA2. Be aware there’s a colon between the “T” and the safety worth, and there’s a semicolon ” ; ” after the safety setting.
  • S: The Service Set ID (SSID) of the Wi-Fi community. Be aware there’s a colon between the “S” and the SSID, and there’s a semicolon ” ; ” after the SSID.
  • P: The password or safety key of the Wi-Fi community. Be aware there’s a colon between the “P” and the safety key, and are two semicolons ” ;; ” after the safety key.
qrencode -s 6 -l H -o "wifi.png" "WIFI:T:WPA;S:<SSID>;P:<PSWD>;;"

Put your actual SSID and safety key the place <SSID> and <>PSWD> seem within the command. The QR code seems like this:

A Wi-Fi QR code

When the QR code is scanned, the app provides to hook up with the Wi-Fi community or to repeat the password to the clipboard.

Scan results for a Wi-Fi QR code

Including a Contact With a QR Code

Contact particulars within the vCard format may be added to a QR code and scanned into the consumer’s deal with guide. This removes the chance of mistyping one thing. There’s quite a lot of info that may be saved, so it’s best so as to add the small print to a file and to redirect that file into qrencode.

This textual content was added to a file referred to as “contact.txt.”

BEGIN:VCARD
VERSION:2.1
N:McKay,D
FN:Dave McKay
TEL;TYPE=voice,cell,pref:5555555555
TITLE:Journalist
ORG:CloudSavvyIT
EMAIL:dave@madeupdomain.com
URL:www.cloudsavvyit.com
END:VCARD

We will redirect this file into qrencode like this:

qrencode -s 6 -l H -o "contact.png" < contact.txt

qrencode -s 6 -l H -o "contact.png" < contact.txt in a terminal window

The QR code it produces has many extra blocks within the code sample than we’ve seen up to now. It is because we’ve got extra info encoded within the sample and we’re utilizing the very best stage of error-correction.

A contact details QR code

As you’d count on, the scanning app provides so as to add this as a contact. However as a result of it has detected there’s a telephone quantity within the info it additionally provides to ring the quantity. Equally, it has additionally detected the e-mail deal with and it provides to ship an e-mail.

Scan results for a contact details QR code

Including a Calendar Occasion With a QR Code

Including an occasion to a calendar is similar to including a contact. The information is finest added to a file which is redirected into qrencode.

This textual content was added to a file referred to as “occasion.txt.”

BEGIN:VEVENT
SUMMARY:Works Picnic
DESCRIPTION:Enjoyable, meals, and video games within the solar
LOCATION:Eastwood Park
DTSTART:20210710T103000
DTEND:20210710T154500
END:VEVENT

This was redirected into qrencode like this:

qrencode -s 6 -l H -o "occasion.png" < occasion.txt

qrencode -s 6 -l H -o "event.png" < event.txt in a terminal window

That is the QR containing the calendar occasion:

A calendar event QR code

The scanning app decodes the occasion like this:

Scan results for a calendar event QR code

The consumer can add the occasion to their calendar with a faucet on the “Add occasion” icon.

So Many Makes use of

QR codes may be positioned anyplace: in e-mail signatures, on promotional literature, on posters, flyers, as stickers on {hardware}, on web sites, on product packaging, on product labels, and on and on.

They will ship all types of knowledge or performance. A QR code on a sticker hooked up to a chunk of {hardware} might open the newest model of the service guide or consumer information.

A poster might function a QR code so as to add the occasion to your calendar, and one other QR code to present you instructions to the venue.

All it takes is slightly creativity, some know-how, and qrencode.



Source link

Uncategorized