There are many good and bad things about QR Codes, they have cropped up everywhere from billboards to water bottles, and have become a must have for some marketers. The opinion about whether these codes are good or not, i'll leave it to your own opinion. Most of the QRCodes that you will see are very tipical, black and white and therefore boring which ends up with little atention from the customer.
Be original and create a fabulous (or maybe creepy) QR Code merging an image on it using the JavaScript library Qart.js
Download and include qart.js
Qart.js is an awesome QR Code generator with a custom functionality that allows you to merge an image into the QR Code. In this way the generated QR Codes will have an original and artistic touch.
To install qart.js, you will need to download a copy of the source code. You can install the plugin directly with NPM executing the following command in your terminal:
Or if you are willing to the test the plugin, use it from the CDN:
Alternatively, if you don't use a package manager, get a copy of the qart.min.js file from the repository in the dist folder and include it with a script tag in your document. Once the plugin is included in your project with any of the mentioned ways, you will be able to access or require the plugin in your code as follows:
With this plugin, you will say NO to the boring QR Codes that you see everyday and everywhere. For more information about the plugin, please visit the official repository in Github here.
Create QR Code with an image
The QArt function expects an object with the properties shown in the following table:
FIELD | TYPE | DESCRIPTION | DEFAULT |
---|---|---|---|
value | String | The data of the QR code. | Required |
imagePath | String | The path of the combined image. | Required |
filter | String | Define an image filter. threshold or color | threshold |
version | Integer | QRCode version (1 <= version <= 40) | 10 |
The QArt function returns an object, from the returned object you need to use the make method to append it into a DOM element (preferably a div). See the following example:
Or if you're working with EcmaScript 2016:
Using qart.js with famous frameworks
If you use a framework like React, Angular or Vue, then you don't need to create a custom component for qarts as they already exist:
React
The React component of qart.js is available as a NPM module written by @BatuhanK. To install it in your project, execute the following command in your terminal:
And you can use it like:
Angular
The Angular directive of qart.js is available as a NPM module written by @isonet. To install it in your project, execute the following command in your terminal:
And use it like:
Vue.js
The Vue.js component of qart.js is available as a NPM module written by @superman66. To install it in your project, execute the following command in your terminal:
Then, import the component:
Once the component is loaded, you can use it in your template:
Don't forget to add the required data:
Limitations
Till the date of publication of this article, you cannot change the size of the generated qr. The dimensions of the generated canvas will be always of 195x195.
From the usage of the plugin, you will obtain a totally readable QR Code for any app or device that allows to read QR Codes. You can see a live example of how qart.js works in the browser here. The demo allows you to select any image from your computer or mobile device and it will immediately convert it into an artistic QR Code with or without colors
Comments
Post a Comment