nayuki / QR-Code-generator

High-quality QR Code generator library in Java, TypeScript/JavaScript, Python, Rust, C++, C.

Home Page:https://www.nayuki.io/page/qr-code-generator-library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Optimize library footprint

shahawi-sumup opened this issue · comments

Hello Nayuki,
Thanks for your great work!

I want to ask you, what do you suggest to reduce the library size, i'm using it on an embedded target with a quite limited flash size, so now it uses about ~8K, any ideas how to strip it down ?
Here is the specs of the QRCode i'm gonna generate:

QR Code version = 2, mask pattern = 6, character count = 21,
encoding mode = byte, error correction = level M, data bits = 180.

Thanks,
Mohamed

Good question. I had to optimize the library size for an Bitcoin-on-microcontroller product a number of years ago.

The main thing I would suggest is getting rid of the tables of ECC block sizes and only retaining the single version and ECC level that you want. You have to do this code manipulation manually, of course.

However, ~8 KB of flash is extremely small. I've worked with systems that had maybe 8 KB of RAM and 32+ KB of flash. I'm not sure if QR Code generation is suitable for your small CPU.

Actually the CPU is powerful (ARM Cortex-A8) so generating a qrcode is fast enough, but the limitation is on the storage size we have less than 2MB, that's why I'm looking into optimizing the size.
I will try your suggestion and will let you know how much saving did i achieve.

Thank you.