Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QR code compression

Is it possible to store about 20 000 characters in QR code? (Or even more? http://blog.qr4.nl/page/QR-Code-Data-Capacity.aspx)

I would like to store only ascii simbols (chars and numbers with extra dash and so on).

As far as I know it's possible to compress not complext text with ratio 80-98% which sound promissing: http://www.maximumcompression.com/index.html

Do you have some more experience? Thanks for sharing!

like image 362
Holy Sync Avatar asked Jun 14 '12 11:06

Holy Sync


People also ask

How do I resize a QR code without losing quality?

Press the Ctrl+R hotkey to open the Resize/Resample window. Enter your desired dimensions in pixels or percentages to resize the QR code without losing quality.

Does a QR code work if you shrink it?

You can resize as much as you want. The information is encoded in the pattern of the data, not in the size of the dots themselves. As long as a scanner can resolve properly between light/dark, the QR code should be readable at any size.

Why is QR code blurry?

The QR Code Is Blurry or Crooked Any optical device that scans QR codes requires precise sharpness and definition of the code. Any blurry squares or, crooked rows or columns, or otherwise shoddy formatting or arrangement will wreck the whole thing.


3 Answers

If your question is: "Is it possible to store 20K characters in QR Code?", then the answer is yes, it is possible.

If your question is: "Is it possible to guarantee you'll always be able to store 20K characters in QR Code to compression?", the answer is no. There is no way to guarantee that, due to pigeonhole principle.

If your question is: "Is there a "comfortable zone" where it is highly likely that a text input, whose maximum size is 20K, will most probably fit into a QR Code?", the proper answer is: it depends on your input data. And a more risky answer is: if you're dealing with "normal text" data, such as a book content, you're probably asking for too much.

The 80-90% compression ratio you refer to is possible because input data is extremely large (several MB), and decompression algorithms are very slow. For a "small" input data, such as 20K characters, the compression ratio for a "normal text" will more likely be in the 50-70% range, depending on algorithm strength (PPM for example, is very suitable for such input data).

Obviously, if your input data is a kind of "log file", with a huge lot of repetitions, then yes, compression ratio > 95% is easily accessible.

But compression ratio is not the only thing to take into consideration. For "real-life" usage, you'll also have to consider the QR size, and a reasonable level of correction for the QR print to survive. Betting on "max capacity with lowest possible correction" is a fairly wrong bet, at least for real life scenarios. You'll have to ask around you to know what are the "reasonable limits" of your QR Code. Most probably, printing capabilities will get into the way, and you'll have to settle for something less than maximum.

Last point, don't forget that compressed data are "binary", not "alphanumeric". As a consequence, the final capacity of your QR Code is into the last column. Which is much less than the column "alphanumeric".

like image 152
Cyan Avatar answered Oct 18 '22 15:10

Cyan


QR codes have a special encoding mode for alphanumeric data (upper-case only, plus digits and a few symbols). It uses less than 8 bits per character and can store 4,296 characters at most in this mode.

This ought to be close to optimal. For simpler data (like, all alpha), a compression algorithm like gzip might be able to achieve fewer bits per byte. Of course, no standard reader would interpret the gzipped payload as such. Only a special reader would be able to.

Can you get 5x more data into a QR code this way? No, almost surely not, unless it's a trivial case like 20,000 "a"s.

Even if you could, it would create a large complex QR code. Anything holding over a few hundred bytes gets hard to scan in practice. Version 40, the largest, is useless in the real world. Even version 20 is.

like image 25
Sean Owen Avatar answered Oct 18 '22 16:10

Sean Owen


In practice, when you want to use a QR to store huge ammounts of data, you simply store a URL pointing to the location of the data.

What is theoretically possible is very different to what is actually possible when you have to support real-life devices. Good luck scanning anything above version 10 (57x57 modules) with a low-end smartphone camera.

like image 34
NiloVelez Avatar answered Oct 18 '22 15:10

NiloVelez