Google Chart API rules for generating QR codes
- Tim Brockman
- @ 3:51 pm
Google Chart API has a number of great tools for data visualization. Check it out at http://code.google.com/apis/chart/ when you have a chance. They also have slick tools for pointers, (like thought bubbles) and easily adding properly formatted equations to the web, (great for awkward things like summations, fractions, etc.) If that wasn't enough, they have the easiest QR encoding you can imagine.. In fact, if you can embed an image in a web page you can embed a QR code.
<-- This square made up of little staticy black squares is a QR code. For those of you wondering.. QR stands for Quick Response. It is an easier to scan 2d matrix version of the familiar, omnipresent bar code. You can encode text, numbers, binary, Kanji, code snippets, URLs or more binary as a QR code. The amount of info you are able to store in the square depends on the amount of staticy pixels. If you need to learn more about what QR codes are about read the Wikipedia entry.
QR codes can be read by almost any mobile phone or device with a camera. If you need to download the reader software http://reader.kaywa.com/ is a good free service, but there are a plethora of other apps.
Now for the easy QR Code Generation step-by-step:
- Decide what you want to encode and if it is possible.. if it is short and simple the answer is likely yes. If not, think URL shortening like t.co or goo.gl.
- Build a proper image tag. It would be a good idea to include title, alt, height, and width but you need src. Here is the img tag for the above QR code with the src value starred out.
<img title="qr_codes" src="****" alt="QR encoded link to Google Chart API QR code documentation." width="120" height="120">
- All of the action happens between the quotes of the src attribute and Google's magical servers. To get things started replace the first star with:
http://chart.apis.google.com/chart?
Which is the URL base you use for public Google Chart API functions.
- Replace the second star(*) with:
cht=qr
Which tells Google Chart API to use the QR Code function.
- Replace the third star(*) with:
&chl=yourURLorWhatever
The & tells Google Chart API to expect the next argument and chl=yourURLorWhatever tells Google Chart API what to data to turn into a QR Code. For the example image, I used &chl=http://code.google.com/apis/chart/infographics/docs/qr_codes.html to remind you where to find the documentation.
- Replace the last star(*) with:
&chs=120x120
This is the last of the 3 required arguments being sent to the Google Chart API when you request a QR Code image. It specifies the size of the png in pixels and the Google servers generate your custom QR Code on the fly.
- If you used the same URL I did in the above image the final result should be identical to mine. Here is the complete image tag. (You may notice an optional "&choe=UTF-8" which, can be investigated at your leisure. )
<img title="qr_codes" src="http://chart.apis.google.com/chart?cht=qr&chl=http://code.google.com/apis/chart/infographics/docs/qr_codes.html&choe=UTF-8&chs=120x120" alt="QR encoded link to Google Chart API QR code documentation." width="120" height="120">
Next time you need a QR Code for a mobile web accessible inventory tracking system or feel the need to lemon party some products at Walmart, Google Chart API makes it all easy. Bobs yer abracadabra.
The 28th of December Google released 21 new fonts for 2011. If you haven’t yet, it is time to check them out. No doubt this will inspire some great web design in 2011. Ubuntu Mountains of Christmas Cabin Merriweather Kristi Just Another Hand Buda Coda Gruppo Lekton Copse Allan Corben Geo Anonymous Pro Vibur Bentham …continue reading…
Can nice fonts really be this simple? Google’s people made some real basic web font stuff. Finally, after over a decade, this may be enough of a push behind good web fonts for the web to start looking designed. Granted you are linking to yet another external file, but better Google’s many servers than mine. …continue reading…
This WordPress template has been redesign using object oriented CSS. It was long past due for a site redesign but my personal blog generally takes a back seat to what I’m working on. All the same I wanted to put a couple things to the test, and for me this is the appropriate place to …continue reading…
Twitter based comments you can embed on almost any site or page seems like a naturally good way to improve the visibility of your content. Every site has share this and bookmark buttons, which is great, but not overly compelling and ignored by the vast majority of your traffic, unless your the stank of linkbait. …continue reading…
Contact PHÓ