Subscribe to RSS feed

splitbrain.org - electronic brain surgery since 2001

PHP Semacode Encoder

This post's URL encoded as Semacode A few days ago Gina Haeussge (aka. foosel) blogged about QR Codes which are currently used by the State Theater of Darmstadt to advertise their mobile services.

QR Codes and the similar Datamatrix are so called 2D barcodes. They are different from the traditional barcodes in that they store data in two dimensions and thus can hold much more information. The ones mentioned here can store up to 3kb of data.

As already said, there are two different patent free 2D standards in the wild1). The QR code which Gina talked about is very popular in Japan, Semacode is the second one and based on a US created standard called Datamatrix. Both codes have similar capabilities. Nokia seems to favor the Semacode one, while the Wikipedia related project Semapedia uses QR code (despite the name).

So what's so special about those codes? The cool thing is that you may already have a barcode reader for them. If your cell phone has a camera you most probably can use it to decode these codes. Nokia even preinstalls such a reader software on some of their newer phones. If you need such a software I can really recommend the Kaywa Reader. It's free but you need to register at their site2).

A Semapedia Tag So these codes make it simple to transfer data to your mobile phone. This data could be an URL, a phone number or even a VCard. The afore mentioned Semapedia uses it to “link” real world places to Wikipedia articles for example.

I was more interested in Semacode, because it looks somehow cooler than QR in my opinion. Unfortunately I wasn't able to find any free (beer and speech) PHP library to create these codes. But I did find a JavaScript port of a C library, used in the SemaFox Firefox extension. What I did in the last two evenings, was porting the JavaScript code to PHP. The library can create a simple HTML table, an SVG or a PNG image of the code.

Unfortunately the source code is very complicated and parts of it seem to be broken in the JavaScript port. I was able to get it running and it seems to produce correct codes, but there are probably still some bugs left. There also seem to be some unused code parts left in it. You have been warned ;-).

The code is available from a git repository or you can just get the library directly. If you squash any bugs, please send a patch.

If you like to try it first, use the following form:

Embedded graphic One nice thing about those 2d barcodes is the built in error correction which makes the code still decodable when part of it are missing. This makes it possible to embed small graphics into the code (See smiley image to the right). Of course you shouldn't overdo it ;-). It is also recommended to keep the stored data small, because the more data you store, the more complex the code gets and the harder it is to decode. I also found 2D barcodes better working on a white background, so if you have trouble decoding the codes in this blog entry, open the images in a separate window.

photo by akaalias

Tags:
semacode, php, cellphone
Similar posts:
1) I'm no pro on this topic I may be wrong or imprecise here
2) yeah that sucks, but the software is great
Posted on Tuesday, June the 12th 2007 (7 years ago).

Comments?

blog comments powered by Disqus