kirpi.it > Notes > Culture > Technology

 
0

 

Barcode


 


Tux


HAPPY LINUX



Both barcode and Latin alphabet bear the same content: 'Bill Gates'

Straightforward use of an obscure code

Barcodes are ubiquitous today.1
Nearly any item on earth bears its own barcode, and our eyes see tenths of barcodes everyday. The idea behind barcodes is, in its core, not too distant from the well known Morse code; nevertheless barcodes still look rather cryptic to most of us.

How easy is it to create them? Is is possible to generate barcodes from a wiki?
In other words, can I type something into a wiki page and have a barcode print on the fly, along with the rest of the page?

Yes.
It is quite possible, and not so hard.
This page describes the whole thing. You’ll learn:

  • how to create a barcode of your choice, given a certain value (example “Elephant”) and save it as an image;
  • how to have your barcode displayed on the same page where its url is set;
  • how to let the barcode url fetch values from some other wiki page, thus allowing for good flexibility.

It’s just a basic primer, but would suffice for most uses, hopefully.2


Barcode-enabled wikis

Creating and displaying barcodes within wiki pages is rather trivial.
Although it might seem a tough task at first, thank to the excellent work done by those who coded the barcode-generating scripts and made them available to the community, it all ends up being a 5 to 10 minutes job.

The first step is to download one of those scripts. They come in many flavours. Here you’ll find two referenced, both in PHP and open-sourced by their authors.

Installing them is usually just a matter of downloading and moving the unpacked folders into your server. They (mainly) work out of the box.3

You can then call the scripts and type your parameters directly into the url. Any browser will do (but Lynx, obviously).
http://www.kirpi.it/c/barcode/barcode.php?code=1234456694147&mode=png&scale=3
Barcode as a static .png image The example above (please, click on it) will generate a rather big (scale=3) .png image (mode=png) of a standard EAN-13 numeric barcode (the one you’ll find on any item in any shop on earth, from books to canned fruits).4
A (smaller) image of such a kind of code is shown here at right.
Not all barcodes, and not all scripts, are equal: you can generate something different by using an alphanumeric standard (…and a different script).

There’s a small issue here, though.
It all runs nice when you generate an image, grab it, upload it into your server and paste it into your web page.
Just it does not work, instead, as you try to generate your barcode image dynamically within your page.
Which is all you want to do, for sure: create your image on the fly with the data you just typed into your wiki page, and publish it in that very page.

An url like http://www.kirpi.it/c/barcode/barcode.php?code=876445669414&mode=png&scale=2 is an image, a dynamically generated one.
But wikis do not understand that, as they expect an image to end with .gif, .jpg or .png so all you have to do is to fool your wiki: add one more parameter to the url, something like “&.png” and make your url look like an image. That odd parameter will be ignored by the barcode script, and the resulting url will be properly processed. You might also want to add some comments, something like:
http://www.kirpi.it/c/barcode/barcode.php?code=876445669414&mode=png&scale=2&.png"Wiki generated dynamic image"
and your url will show as

Wiki generated dynamic image

More on the subject you’ll find in the images page of Pmwiki.5


Dynamic barcodes with variables

Dynamic barcode (value fetched from Notes/Barcode-Data-Source)
Dynamic barcode (value fetched from Notes/Barcode-Data-Source)



Ticket test

  • Ticket is created on the fly from this very wiki page.
  • Variables are fetched from another wiki page (Barcode-Data-Source).
  • The resulting ticket could easily be shown on screen, referenced as a link on an email, sent as a .pdf,…

www.kirpi.it

ENTRATA SINGOLO

Concerto di Vivaldi

Dynamic barcode (value fetched from Notes/Barcode-Data-Source)

11 Luglio 2007

La Fenice
20.30

Intero € 37.00

  • More than one code can be used at the same time. Here we added a sort of (fake) check code on the ticket.

www.kirpi.it

ENTRATA SINGOLO
(Fake) check code fetched from Notes/Barcode-Data-Source

Concerto di Vivaldi

Dynamic barcode (value fetched from Notes/Barcode-Data-Source)

11 Luglio 2007

La Fenice
20.30

Intero € 37.00

  • Example of a real-world ticket featuring a barcode for a quick and smooth check-in
Allianz Arena - München - Germany

Badge test

  • Variable is fetched from Barcode-Data-Source and set as …text={Notes/Barcode-Data-Source$:Name}… in the url
Tux


HAPPY LINUX



Both barcode and Latin alphabet bear the same content: 'Bill Gates'


A few words on reading barcodes

Reading barcodes is just as simple as using a mouse. Once you get your barcode scanner tool unpacked, all you have to do is plug it gently into a usb port of your pc: from that point on, whenever you’ll trigger the button your barcode (its alphanumeric source, that is) is printed right at the cursor position, just like typing from keyboard.
It couldn’t be easier.

For reading Data Matrix and QR Barcodes, as well as a bunch of other barcodes, from your mobile phone, see below


So, what more?

Thanks for reading till here!

You have certainly seen bi-dimensional square barcodes around, called QR Codes.
They are readable by any mobile phone equipped with a camera and the suitable scanning software, and can currently store more than 4000 alphanumeric characters.
The one at right here encodes: “Thanks for reading till here!”
Google has a free charts service which includes QR Codes: you might want to explore and give it a try.
Alternatively, QRifier.com is an online free QR-code generator with extra services like PayPal instant payment/donation button encoding to QR in order to let people pay easier, and more.

www.millenuvole.org

QR codes can store different kind of data, such as plain text, url, phone number, SMS, email, vcard, and a lot more.
The example here at right contains the web home page (url) of an association I closely cooperate with: www.millenuvole.org.

There are other similar codes, like the Data Matrix code, and a few more, actually.

Reading such two dimensional codes is usually done via mobile phones.
In case your own device is not ready for it, you might want to try and download one of the most widely used mobile barcode reader in the world: just browse to www.i-nigma.mobi with your mobile phone in order to install it.
Available alternatives might be NeoReader, UpCode, QuickMark, Semacode and the Nokia Barcode Reader.

Note that most of the websites here above allow you to also easily create and export your own two-dimensional codes.



 

1 Please enjoy this funny hoax from Fatal Farm on a (fake) 7-digit code in U.S. snail mail service. (↑)

2 You might also want to read http://www.pmwiki.org/wiki/Cookbook/BarCode (↑)

3 The www.ashberg.de script did not, actually. It does not include the True Type font you need for Linux (damned legal issues, I guess), so all you have to do is grab it from any Windows machine at hand (you’ll find it under c:\windows\fonts) and place it into your barcode script folder. Detailed documentation comes with the script, anyway. (↑)

4 How such a coding standard work, and why the numbers in the url slightly differ from those in the barcode is not a matter we feel like covering here; please google for EAN-13 in case you want to delve into that. (↑)

5 And here http://wiki.splitbrain.org/wiki:images#dynamic_images as well. (↑)



Share this page with your friends on your favorite social bookmarking site...