File Exchange

image thumbnail

QR Code Generator 1.1 based on zxing

version 1.1 (153 KB) by Jens Richter
QR Code generator 1.1 can generatre QR-Codes based on the zxing library.


Updated 23 Dec 2016

View Version History

View License

QR Code generator can generate QR-Codes based on the zxing library. All files can be imported on the fly from a maven repository or can be downloaded via a command. Zxing is an open source project so it also possible to include your self-compliled files if you have security issues.
If you like what you see buy me a coffee via:

Cite As

Jens Richter (2021). QR Code Generator 1.1 based on zxing (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (27)

Stefan Rung

Very nice function!

Is it possible to change the barcode formate e.g. to Datamatrix?

Shehan Jayasekera

For everyone that is having issues where it is returning a grey image, please replace the following two lines in qrcode_config.m to fix it:

replace line 11:
qrcode.jar.inet.path = '';
qrcode.jar.inet.path = '';

replace line 13:
qrcode.jar.ver = '3.2.0';
qrcode.jar.ver = '3.4.1';

Note: 3.4.1 is the most recent release of zxing at this time, please check for the most recent version number

Important: You must also run
to save the jar files (there should be two) locally. Running this will save the files to \qrcode_gen\jarfiles (make sure to add this folder to matlab filepath, the Example.m shows you how). For some reason, the dynamic loading of jar files is currently broken (I think because of HTTPS protocol).

If you make the changes in the two lines and run qrcode_gen('DownloadJars',1); you should be able to run Example.m successfully

I am receiving grey images instead of QR codes. Testing in Matlab R2020a. Please Help!!!

I am receiving grey images instead of QR codes. Testing in Matlab 2020a. Please Help!

just receive grey images instead of the QR codes images. help me

Jens Richter

Hey Joris, thanks for providing a fix for newer Matlab versions :-)

Joris Brouwer

Excellent code. However the path to the jar files now has become a https address (change in qrcode_config.m to '' ) and I had to modify the private toolbox function javapathutils as well to understand https://*** is actually an url by adding "|| strncmp(str, 'https://', 8)" on line 15 (Matlab R2019b which requires admin rights).

Lode Bosmans

I have been using this code for a few year now. Very useful! However, since two weeks the code does not produce any QR codes anymore. I just receive grey images instead of the QR codes images. Did anything change with the zxing third party tools? Any help would be appreciated.

Perig Vennetier

Great code and very useful. One question about capacity as I am trying to generate codes as small as possible. As far I can find out, a version 1 code should be able to be 21x21 pixels and hold 25 alphanumeric characters. However, when I use the code and try to create a "Hello Hello World" (two hello) which is only 17 characters, it generates a 25x25 code instead of the expected 21x21. Why is that? Thanks!

nasir hurrah

can this code be used to convert a binary image to QR coded image.

Chester Chai

Emad Abedini

Gabriel Herz

Ziming Zhong

Sorry its me again. I solved my previous problem. But I have another question: the QR code size is changed with the figure window size, right? So could we somehow fix the size of QR code into a specific size? Thanks!

Ziming Zhong

Hi Jens, Thank you very much for this package! It's very helpful! But I have a question for you: if I want generate many QR codes in a loop and combine them by using `subplot`, when should I call `subplot'? My goal is to print out all the QR codes in an A4 paper. Many thanks!


Jens Richter

Hi Kishore,

please check the manual. You can download the jars easily and use them without internet connection. Please feel free to send me an email in case you need a helping hand :-).


kishore siva

output is performd only with the internet to get without connection also?

chengzhe liao

thanks! very useful!

Jens Richter

Hey Ethan,

I dont know if anyone used this within Matlab but it seems not be to complicated. I had a look on the following java implementation I will have a look into this for my next release. If is of benefit I will include it :-)



Do you know whether anyone has done this with other codes in zxing, especially datamatrix codes?

Following your code I was able to get datamatrix codes:

e.g., dm_writer =;

However, my rudimentary abilities keep me from figuring out the different options available in datamatrix codes (except for DATA_MATRIX_SHAPE).

Do you know where I can find a list of encoder options for datamatrix codes in zxing?


Great! Thanks!


Great! Thanks!

Jens Richter

Hey Ethan,

thank you very much for your comment. I will publish a new version of Qr Code Generator in the next days anyway. Because there is also a bug when running it with Matlab2015a. I will also have a look on the quietzone settings.



It looks like the setting for the quiet zone is not implemented in the java. When I change this value in qrcode_config.m, nothing happens. If I try putting it in the hints (qr_hints.put(, qrcodeProps.setting.quietZoneSize)), I get an error. I tried looking at the java source and it likes like this part isn't fully implemented.

Does this seem right to you?


Ligong Han

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: QR Code encoder

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!