This repository has been archived by the owner on Apr 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11b6c56
commit 777b4f4
Showing
4 changed files
with
81 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: npm-publish | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
|
||
- name: 'Install dependencies' | ||
run: npm ci | ||
|
||
- name: 'Build typescript' | ||
run: npm run build | ||
|
||
- name: 'Publish library to NPM' | ||
run: npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,50 @@ | ||
# QR Image | ||
Simple library allowing you to generate an image in middle of an QR code. | ||
Simple library allowing you to generate an image in middle of an QR code or without it. | ||
|
||
This library contains only 1 method and that is `generateQRWithImage` | ||
This library contains only 1 method and that is `generateQRWithImage` and uses libraries | ||
[qrcode](https://www.npmjs.com/package/qrcode) and [canvas](https://www.npmjs.com/package/canvas) to generate the | ||
resulting image. | ||
|
||
## Quick Example | ||
|
||
```js | ||
|
||
const imageBuffer; | ||
|
||
// for option values please visit https://www.npmjs.com/package/qrcode#qr-code-options library | ||
const options = { | ||
errorCorrectionLevel: 'Q', | ||
color: { | ||
dark: '#0CC8A8' | ||
} | ||
}; | ||
|
||
|
||
// This will create QR with 'https://trisbee.com' encoded in it and with centered image also color will be #0CC8A8 | ||
const resultWithImage = generateQRWithImage('https://trisbee.com', 500, 100, imageBuffer, options) | ||
// This will create just QR code with 'https://trisbee.com' encoded in it in color #0CC8A8 | ||
const resultWithoutImage = generateQRWithImage('https://trisbee.com', 500, 100, null, options) | ||
// This will create classic B&W QR code with 'https://trisbee.com' encoded in it | ||
const resultWithoutImageAndOptions = generateQRWithImage('https://trisbee.com', 500, 100, null, null) | ||
|
||
// The buffer of outputed QR code | ||
const imageBuffer = resultWithImage.buffer; | ||
|
||
// The precentage of how much the inserted image area of QR code image covers | ||
// if 'errorCorrectionLevel' is not specified theoretical maxium of how much the image can cover is 30% | ||
// but we recommend to keep it under 20 and make sure the image doesn't touch the big rectangles in the corners | ||
// of QR | ||
const imageQRCoverage = resultWithImage.coverage | ||
|
||
|
||
|
||
``` | ||
|
||
### Typings | ||
```ts | ||
generateQRWithImage(qrCodeContent: string, width: number, margin: number, imageBuffer?: Buffer, options?: QRCodeToBufferOptions) | ||
``` | ||
|
||
### Options | ||
|
||
For options please visit documentation of [qrcode](https://www.npmjs.com/package/qrcode#qr-code-options) library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters