{"_id":"qr-code-styling-node","_rev":"2-d72cc4fef0d1b60f4d36a3ea65c7e94a","name":"qr-code-styling-node","dist-tags":{"latest":"1.5.0"},"versions":{"1.3.4":{"name":"qr-code-styling-node","version":"1.3.4","description":"Add a style and an image to your QR code","main":"lib/qr-code-styling.js","types":"lib/index.d.ts","dependencies":{"qrcode-generator":"^1.4.3"},"devDependencies":{"@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","canvas":"^2.6.1","clean-webpack-plugin":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-loader":"^4.0.2","eslint-plugin-jest":"^24.1.3","eslint-plugin-prettier":"^3.3.1","html-webpack-plugin":"^4.5.1","jest":"^26.6.3","jest-environment-jsdom-fifteen":"^1.0.0","prettier":"^2.2.1","ts-jest":"^26.4.4","ts-loader":"^8.0.14","typescript":"^4.1.3","webpack":"^5.12.3","webpack-cli":"^4.3.1","webpack-dev-server":"^3.11.1","webpack-merge":"^5.7.3"},"scripts":{"build":"webpack --mode=production --config webpack.config.build.js","build:dev":"webpack --mode=development --config webpack.config.build.js","test":"jest","start":"webpack serve --open --config webpack.config.dev-server.js"},"repository":{"type":"git","url":"git+https://github.com/ducminhquan/qr-code-styling.git"},"keywords":["qr","qrcode","qr-code","js","qrjs","qrstyling","styling","qrbranding","branding","qrimage","image","qrlogo","logo","design"],"author":{"name":"Denys Kozak","email":"kozak.denys.dev@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/ducminhquan/qr-code-styling/issues"},"homepage":"https://qr-code-styling.com","gitHead":"4cac713e4cfb7c7e0e829227b140287addbf9d42","_id":"qr-code-styling-node@1.3.4","_nodeVersion":"14.17.0","_npmVersion":"6.14.13","dist":{"integrity":"sha512-hBzR0b1YwK5FfrcYTCkxDltvKOP1c5Jr4asjK/KCnAr1pH+2yHTJhuc1Sd1GPyb0ABGVcJSPh3No2kXiUBeNNg==","shasum":"9be833753f630819400810349c54be806171097c","tarball":"https://registry.npmjs.org/qr-code-styling-node/-/qr-code-styling-node-1.3.4.tgz","fileCount":26,"unpackedSize":233790,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCCq9CRA9TVsSAnZWagAAMRwP/0SATPGWqqCPmvlN5k/h\nxE9e4Yat7sCP53bqXEG/uMvCRJ8pJf2gcKnv/ip9wclhg9zUJVNhzaHAWUfE\nRX1zA+a21DSQZuPI/HUAxx89f/jW812wjqo9Gu2Y/dMDw2QXfqRiafovTRej\nimBPwe1p5jPAeHFmXl3UpJrWhXFCVwPRx8oKUXFz6PDnHbcL86MQR+q11mG1\nhDEp6YA4V/Rvsp/Y+G580lsvoJH+vcq2UvNtMxd4PsMnTEYSkPtPFNVMBZk+\nFX+4XG4udX/XJ5rWJZJzSNTRy8vxpsc9XxSR942CmLgaZXZ558n5pu7hC+U0\nRl1qqf2xpSUD0T4uI+G40BjWxFqr0EVrToHVoYE88VU0t+5hT723TQakSQx7\nHZIjayHocjl2ig38UYoyA0QA7aZSMkawHDTp94JMCEVz0sJEMxfLS40bw3jT\nFw3iGBRl7WFlBeNMINZ8kYFasv9ycyf8aDamEZcvzZgLFymvwu8NTqFcu72v\neE3k8SMTLBDDhLfRA2FiJULGUWq5/uPtVvEExMDXwXfgns4WoldMe2m2WMyj\nyMYfhILLrptUx4TS6IYaaSsh4QCPkks8U65sN45ZSa+KtN4jklyUeAIJtJYZ\nIrNX/GpXtb619g3Tw+fpm3DMTL1Wp6cpWfSdAe/Ec++kjepWELt5Nxv2Hfox\nsxZm\r\n=WX6r\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICBoUVBWAbGqdN9e4EA+8l+Bqi7HSHxitDdEbFREj0kZAiEA78z4CCo3zHn7fl/bren/cdGmq6RJLrQ5TNn4nNcxBQ4="}]},"_npmUser":{"name":"ducminhquan","email":"ducminhquan@gmail.com"},"directories":{},"maintainers":[{"name":"ducminhquan","email":"ducminhquan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/qr-code-styling-node_1.3.4_1627925181830_0.8405816308152041"},"_hasShrinkwrap":false},"1.5.0":{"name":"qr-code-styling-node","version":"1.5.0","description":"Add a style and an image to your QR code","main":"lib/qr-code-styling.js","types":"lib/index.d.ts","dependencies":{"qrcode-generator":"^1.4.3"},"devDependencies":{"@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","canvas":"^2.7.0","clean-webpack-plugin":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-loader":"^4.0.2","eslint-plugin-jest":"^24.1.3","eslint-plugin-prettier":"^3.3.1","filemanager-webpack-plugin":"^4.0.0","html-webpack-plugin":"^4.5.1","jest":"^26.6.3","jest-environment-jsdom-fifteen":"^1.0.0","jsdom":"^16.6.0","prettier":"^2.2.1","ts-jest":"^26.4.4","ts-loader":"^8.0.14","typescript":"^4.1.3","webpack":"^5.12.3","webpack-cli":"^4.3.1","webpack-dev-server":"^3.11.1","webpack-merge":"^5.7.3"},"scripts":{"build":"webpack --mode=production --config webpack.config.build.js","build:dev":"webpack --mode=development --config webpack.config.build.js","prepare":"npm run build","test":"jest","start":"webpack serve --open --config webpack.config.dev-server.js"},"repository":{"type":"git","url":"git+https://github.com/ducminhquan/qr-code-styling.git"},"keywords":["qr","qrcode","qr-code","js","qrjs","qrstyling","styling","qrbranding","branding","qrimage","image","qrlogo","logo","design"],"author":{"name":"Denys Kozak","email":"kozak.denys.dev@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/ducminhquan/qr-code-styling/issues"},"homepage":"https://qr-code-styling.com","gitHead":"382eefc705663c35a66a032006043e4aaaf8d58b","_id":"qr-code-styling-node@1.5.0","_nodeVersion":"14.17.0","_npmVersion":"6.14.13","dist":{"integrity":"sha512-Wqy2k/04XJzuFBb/gljBBZn2SoA5U5yGLq457LWWduR4iFx3ifNXLeEg+kBu5mvwaaCAie3oy5KcWftRxgMIDQ==","shasum":"80826b57884fc4ccd97c90b5681154a46155769e","tarball":"https://registry.npmjs.org/qr-code-styling-node/-/qr-code-styling-node-1.5.0.tgz","fileCount":34,"unpackedSize":171269,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCC1PCRA9TVsSAnZWagAA+NUP/2SdOA6Kz8EQ8HopkFZY\nEYlRYJpGJuS+DaHT7IiS0U1OF5ARNRdLAlJVSMvIAtS6CkGUo8HFtApoqrkH\ndwsaBN6iEIUODAg0jzEt/RxJYJAfuvA63be4V6OxGCeboO9JpjoPY0+qCxWz\nmmV6HsdJNgpQ9SV11pVcjUukeie7x91JUiNz+0kyPo7mNYMUTEO9xmI0cgwB\nVxjBnuWn7RFk6pTOoCF2CogRTK/eTQckKR8Y2ZteeIqPqLWShzYA0YC2DCM0\nkMBxuKgBd7BuhLR5g9I/sr925c6OYssK/6UfNE3H+s5RDkLHnPjvLx7XTRh4\nZbNDeYAosdwFwF560oEaiFqI1w7Vo2VBQlIvTR1s6VurQ0qirG2JM2tdNN2Y\nOT59YpUi2cltf9fnq1UjriZvkWsVx3EdgXhR1N9p7STHgIahwp3+/eflgMjw\nl/0AklHhF6wOer99nwp7ZSX64VuMj43ZQQMfQj6gNRqYmtW9wNhW1tMm7FM7\njy+n6DctiqdtBU0Gt0iohWrYmDxG3vMgC00/g1cACISHL2SANKiYvKmKQG0i\nCBa279b7xd+cjIzFVshlkrYt7rkl5XJL+cojZlZGvsW4wf8CrpC3IarmCjA7\nUeDPzCtuMpQ9ksFuyWjxw3BH+kIUHsIFbK8KsmsrFva4OD/2MWMRpdpqWPf0\nn0+V\r\n=dAoP\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCB73DBhfvL1KJxYYsuWTy2/j7bvhjslCFZSJC945lnMAIhAMJoGPSXkw3JT1RlOO3/IBa+IWp3ZbU/n/eIXHYB1Ca1"}]},"_npmUser":{"name":"ducminhquan","email":"ducminhquan@gmail.com"},"directories":{},"maintainers":[{"name":"ducminhquan","email":"ducminhquan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/qr-code-styling-node_1.5.0_1627925839060_0.8564668928391881"},"_hasShrinkwrap":false}},"time":{"created":"2021-08-02T17:26:21.829Z","1.3.4":"2021-08-02T17:26:21.959Z","modified":"2022-05-13T21:18:53.456Z","1.5.0":"2021-08-02T17:37:19.264Z"},"maintainers":[{"name":"ducminhquan","email":"ducminhquan@gmail.com"}],"description":"Add a style and an image to your QR code","homepage":"https://qr-code-styling.com","keywords":["qr","qrcode","qr-code","js","qrjs","qrstyling","styling","qrbranding","branding","qrimage","image","qrlogo","logo","design"],"repository":{"type":"git","url":"git+https://github.com/ducminhquan/qr-code-styling.git"},"author":{"name":"Denys Kozak","email":"kozak.denys.dev@gmail.com"},"bugs":{"url":"https://github.com/ducminhquan/qr-code-styling/issues"},"license":"MIT","readme":"# QR Code Styling\n[![Version](https://img.shields.io/npm/v/qr-code-styling.svg)](https://www.npmjs.org/package/qr-code-styling)\n\nJavaScript library for generating QR codes with a logo and styling.\n\nTry it here https://qr-code-styling.com\n\nIf you have issues / suggestions / notes / questions, please open an issue or contact me. Let's create a cool library together.\n### Examples\n<p float=\"left\">\n<img style=\"display:inline-block\" src=\"https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/src/assets/facebook_example_new.png\" width=\"240\" />\n<img style=\"display:inline-block\" src=\"https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/src/assets/qr_code_example.png\" width=\"240\" />\n<img style=\"display:inline-block\" src=\"https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/src/assets/telegram_example_new.png\" width=\"240\" />\n</p>\n\n### Installation\n\n```\nnpm install qr-code-styling\n```\n\n### Usage\n\n```HTML\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <title>QR Code Styling</title>\n    <script type=\"text/javascript\" src=\"https://unpkg.com/qr-code-styling@1.5.0/lib/qr-code-styling.js\"></script>\n</head>\n<body>\n<div id=\"canvas\"></div>\n<script type=\"text/javascript\">\n\n    const qrCode = new QRCodeStyling({\n        width: 300,\n        height: 300,\n        type: \"svg\",\n        data: \"https://www.facebook.com/\",\n        image: \"https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg\",\n        dotsOptions: {\n            color: \"#4267b2\",\n            type: \"rounded\"\n        },\n        backgroundOptions: {\n            color: \"#e9ebee\",\n        },\n        imageOptions: {\n            crossOrigin: \"anonymous\",\n            margin: 20\n        }\n    });\n\n    qrCode.append(document.getElementById(\"canvas\"));\n    qrCode.download({ name: \"qr\", extension: \"svg\" });\n</script>\n</body>\n</html>\n```\n---\n\n[**React example (Codesandbox)**](https://codesandbox.io/s/qr-code-styling-react-example-l8rwl?file=/src/App.js)\n\n[**Angular example (Codesandbox)**](https://codesandbox.io/s/agitated-panini-tpgb2?file=/src/app/app.component.ts)\n\n---\n\n[**React example (source)**](https://github.com/kozakdenys/qr-code-styling-examples/tree/master/examples/react)\n\n[**Angular example (source)**](https://github.com/kozakdenys/qr-code-styling-examples/tree/master/examples/angular)\n\n[**Vue example (source)**](https://github.com/kozakdenys/qr-code-styling-examples/tree/master/examples/vue)\n\n---\n\n### API Documentation\n\n#### QRCodeStyling instance\n`new QRCodeStyling(options) => QRCodeStyling`\n\nParam  |Type  |Description\n-------|------|------------\noptions|object|Init object\n\n`options` structure\n\nProperty               |Type                     |Default Value|Description\n-----------------------|-------------------------|-------------|-----------------------------------------------------\nwidth                  |number                   |`300`        |Size of canvas\nheight                 |number                   |`300`        |Size of canvas\ntype                   |string (`'canvas' 'svg'`)|`canvas`     |The type of the element that will be rendered\ndata                   |string                   |             |The date will be encoded to the QR code\nimage                  |string                   |             |The image will be copied to the center of the QR code\nmargin                 |number                   |`0`          |Margin around canvas\nqrOptions              |object                   |             |Options will be passed to `qrcode-generator` lib\nimageOptions           |object                   |             |Specific image options, details see below\ndotsOptions            |object                   |             |Dots styling options\ncornersSquareOptions   |object                   |             |Square in the corners styling options\ncornersDotOptionsHelper|object                   |             |Dots in the corners styling options\nbackgroundOptions      |object                   |             |QR background styling options\nnodeCanvas             |node-canvas              |             |Only specify when running on a node server for canvas type, please refer to node section below\njsDom                  |jsdom                    |             |Only specify when running on a node server for svg type, please refer to node section below\n\n`options.qrOptions` structure\n\nProperty            |Type                                              |Default Value\n--------------------|--------------------------------------------------|-------------\ntypeNumber          |number (`0 - 40`)                                 |`0`\nmode                |string (`'Numeric' 'Alphanumeric' 'Byte' 'Kanji'`)|\nerrorCorrectionLevel|string (`'L' 'M' 'Q' 'H'`)                        |`'Q'`\n\n`options.imageOptions` structure\n\nProperty          |Type                                   |Default Value|Description\n------------------|---------------------------------------|-------------|------------------------------------------------------------------------------\nhideBackgroundDots|boolean                                |`true`       |Hide all dots covered by the image\nimageSize         |number                                 |`0.4`        |Coefficient of the image size. Not recommended to use ove 0.5. Lower is better\nmargin            |number                                 |`0`          |Margin of the image in px\ncrossOrigin       |string(`'anonymous' 'use-credentials'`)|             |Set \"anonymous\" if you want to download QR code from other origins.\nsaveAsBlob        |boolean                                |`false`      |Saves image as base64 blob in svg type, see bellow\n\nWhen QR type is svg, the image may not load in certain applications as it is saved as a url, and some svg applications will not render url images for security reasons. Setting `saveAsBlob` to true will instead save the image as a blob, allowing it to render correctly in more places, but will also increase the file size.\n\n`options.dotsOptions` structure\n\nProperty|Type                                                                          |Default Value|Description\n--------|------------------------------------------------------------------------------|-------------|-------------------\ncolor   |string                                                                        |`'#000'`     |Color of QR dots\ngradient|object                                                                        |             |Gradient of QR dots\ntype    |string (`'rounded' 'dots' 'classy' 'classy-rounded' 'square' 'extra-rounded'`)|`'square'`   |Style of QR dots\n\n`options.backgroundOptions` structure\n\nProperty|Type  |Default Value\n--------|------|-------------\ncolor   |string|`'#fff'`\ngradient|object|\n\n`options.cornersSquareOptions` structure\n\nProperty|Type                                     |Default Value|Description\n--------|-----------------------------------------|-------------|-----------------\ncolor   |string                                   |             |Color of Corners Square\ngradient|object                                   |             |Gradient of Corners Square\ntype    |string (`'dot' 'square' 'extra-rounded'`)|             |Style of Corners Square\n\n`options.cornersDotOptions` structure\n\nProperty|Type                     |Default Value|Description\n--------|-------------------------|-------------|-----------------\ncolor   |string                   |             |Color of Corners Dot\ngradient|object                   |             |Gradient of Corners Dot\ntype    |string (`'dot' 'square'`)|             |Style of Corners Dot\n\nGradient structure\n\n`options.dotsOptions.gradient`\n\n`options.backgroundOptions.gradient`\n\n`options.cornersSquareOptions.gradient`\n\n`options.cornersDotOptions.gradient`\n\nProperty  |Type                        |Default Value|Description\n----------|----------------------------|-------------|---------------------------------------------------------\ntype      |string (`'linear' 'radial'`)|\"linear\"     |Type of gradient spread\nrotation  |number                      |0            |Rotation of gradient in radians (Math.PI === 180 degrees)\ncolorStops|array of objects            |             |Gradient colors. Example `[{ offset: 0, color: 'blue' }, {  offset: 1, color: 'red' }]`\n\nGradient colorStops structure\n\n`options.dotsOptions.gradient.colorStops[]`\n\n`options.backgroundOptions.gradient.colorStops[]`\n\n`options.cornersSquareOptions.gradient.colorStops[]`\n\n`options.cornersDotOptions.gradient.colorStops[]`\n\nProperty|Type            |Default Value|Description\n--------|----------------|-------------|-----------------------------------\noffset  |number (`0 - 1`)|             |Position of color in gradient range\ncolor   |string          |             |Color of stop in gradient range\n\n#### QRCodeStyling methods\n`QRCodeStyling.append(container) => void`\n\nParam    |Type       |Description\n---------|-----------|-----------\ncontainer|DOM element|This container will be used for appending of the QR code\n\n`QRCodeStyling.getRawData(extension) => Promise<Blob>`\n\nParam    |Type                                |Default Value|Description\n---------|------------------------------------|-------------|------------\nextension|string (`'png' 'jpeg' 'webp' 'svg'`)|`'png'`      |Blob type on browser, Buffer type on Node\n\n`QRCodeStyling.update(options) => void`\n\nParam  |Type  |Description\n-------|------|--------------------------------------\noptions|object|The same options as for initialization\n\n`QRCodeStyling.download(downloadOptions) => Promise<void>`\n\nParam          |Type  |Description\n---------------|------|------------\ndownloadOptions|object|Options with extension and name of file (not required)\n\nPromise returned will resolve into the data URI of the QR code image.\n\n`downloadOptions` structure\n\nProperty |Type                                |Default Value|Description\n---------|------------------------------------|-------------|-----------------------------------------------------\nname     |string                              |`'qr'`       |Name of the downloaded file\nextension|string (`'png' 'jpeg' 'webp' 'svg'`)|`'png'`      |File extension\n\n### Node Support\nYou can use this on a node server by passing through the node-canvas or jsdom object depending if your creating a non-svg or svg respectively. You must pass both if using `imageOptions.saveAsBlob`.\n\nCalling `getRawData` in node will return a Buffer instead of a Blob.\n\n```js\nconst { QRCodeStyling } = require(\"qr-code-styling/lib/qr-code-styling.common.js\");\nconst nodeCanvas = require(\"canvas\");\nconst { JSDOM } = require(\"jsdom\");\nconst fs = require(\"fs\");\n\nconst options = {\n    width: 300,\n    height: 300,\n    data: \"https://www.facebook.com/\",\n    image: \"https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg\",\n    dotsOptions: {\n        color: \"#4267b2\",\n        type: \"rounded\"\n    },\n    backgroundOptions: {\n        color: \"#e9ebee\",\n    },\n    imageOptions: {\n        crossOrigin: \"anonymous\",\n        margin: 20\n    }\n}\n\n// For canvas type\nconst qrCodeImage = new QRCodeStyling({\n    nodeCanvas, // this is required\n    ...options\n});\n\nqrCodeImage.getRawData(\"png\").then((buffer) => {\n  fs.writeFileSync(\"test.png\", buffer);\n});\n\n// For svg type\nconst qrCodeSvg = new QRCodeStyling({\n    jsdom: JSDOM, // this is required\n    type: \"svg\",\n    ...options\n});\n\nqrCodeSvg.getRawData(\"svg\").then((buffer) => {\n  fs.writeFileSync(\"test.svg\", buffer);\n});\n\n// For svg type with the inner-image saved as a blob\n// (inner-image will render in more places but file will be larger)\nconst qrCodeSvgWithBlobImage = new QRCodeStyling({\n    jsdom: JSDOM, // this is required\n    nodeCanvas, // this is required\n    type: \"svg\",\n    ...options,\n    imageOptions: {\n        saveAsBlob: true,\n        crossOrigin: \"anonymous\",\n        margin: 20\n    }\n});\n\nqrCodeSvgWithBlobImage.getRawData(\"svg\").then((buffer) => {\n  fs.writeFileSync(\"test_blob.svg\", buffer);\n});\n\n```\n\n### License\n\n[MIT License](https://raw.githubusercontent.com/kozakdenys/qr-code-styling/master/LICENSE). Copyright (c) 2021 Denys Kozak\n\n","readmeFilename":"README.md"}