Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

ngx-scanner-qrcode-single

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

ngx-scanner-qrcode-single

This library is built to provide a solution scanner QR code. This library takes in raw images and will locate, extract and parse any QR code found within.

unpublished
latest
Source
npmnpm
Version
1.0.0-beta.2
Version published
Maintainers
1
Created
Source

ngx-scanner-qrcode-single

This library is built to provide a solution scanner QR code.
This library takes in raw images and will locate, extract and parse any QR code found within.
This demo Github, Stackblitz.

Logo

Installation

Install ngx-scanner-qrcode-single from npm:

npm install ngx-scanner-qrcode-single@<version> --save

Add wanted package to NgModule imports:

import { NgxScannerQrcodeModule } from 'ngx-scanner-qrcode-single';
@NgModule({
    imports: [
        NgxScannerQrcodeModule
    ]
})

In the Component:

<!-- For camera -->
<ngx-scanner-qrcode-single #action="scanner"></ngx-scanner-qrcode-single>

<!-- data  -->
<span>{{ action.data.value | json }}</span><!-- value -->
<span>{{ action.data | async | json }}</span><!-- async -->

<!-- Loading -->
<p *ngIf="action.isLoading">⌛ Loading...</p>

<!-- start -->
<button (click)="action.isStart ? action.stop() : action.start()">{{action.isStart ? 'Stop' : 'Start'}}</button>
Image src
<!-- For image src -->
<ngx-scanner-qrcode-single #action="scanner" [src]="'https://domain.com/test.png'"></ngx-scanner-qrcode-single>

<span>{{ action.data.value | json }}</span><!-- value -->
<span>{{ action.data | async | json }}</span><!-- async -->
Select files
<!-- For select files -->
<input #file type="file" (change)="onSelects(file.files)" [multiple]="'multiple'" [accept]="'.jpg, .png, .gif, .jpeg'"/>

<div *ngFor="let item of qrCodeResult">
  <ngx-scanner-qrcode-single #actionFile="scanner" [src]="item.url" [config]="config"></ngx-scanner-qrcode-single>
  <p>{{ actionFile.data.value | json }}</p><!-- value -->
  <p>{{ actionFile.data | async | json }}</p><!-- async -->
</div>
import { Component } from '@angular/core';
import { NgxScannerQrcodeService, ScannerQRCodeSelectedFiles } from 'ngx-scanner-qrcode-single';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  public qrCodeResult: ScannerQRCodeSelectedFiles[] = [];

  public config: ScannerQRCodeConfig = {
    constraints: { 
      video: {
        width: window.innerWidth
      }
    } 
  };

  constructor(private qrcode: NgxScannerQrcodeService) { }

  public onSelects(files: any) {
    this.qrcode.loadFiles(files).subscribe((res: ScannerQRCodeSelectedFiles[]) => {
      this.qrCodeResult = res;
    });
  }
}
Select files to Scan
<!-- For select files -->
<input #file type="file" (change)="onSelects(file.files)" [multiple]="'multiple'" [accept]="'.jpg, .png, .gif, .jpeg'"/>

<div *ngFor="let item of qrCodeResult">
  <img [src]="item.url | safe: 'url'" [alt]="item.name" style="max-width: 100%"><!-- Need bypassSecurityTrustUrl -->
  <p>{{ item.data | json }}</p>
</div>
import { Component } from '@angular/core';
import { NgxScannerQrcodeService, ScannerQRCodeSelectedFiles } from 'ngx-scanner-qrcode-single';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  public qrCodeResult: ScannerQRCodeSelectedFiles[] = [];

  public config: ScannerQRCodeConfig = {
    constraints: { 
      video: {
        width: window.innerWidth
      }
    } 
  };

  constructor(private qrcode: NgxScannerQrcodeService) { }

  public onSelects(files: any) {
    this.qrcode.loadFilesToScan(files).subscribe((res: ScannerQRCodeSelectedFiles[]) => {
      this.qrCodeResult = res;
    });
  }
}

API Documentation

Input

FieldDescriptionTypeDefault
[src]image urlstring-
[fps]fps/msnumber30
[vibrate]vibrate for mobilenumber300
[isBeep]beepbooleantrue
[constraints]setting videoMediaStreamConstraints{audio:false,video:true}
[canvasStyles]setting canvasCanvasRenderingContext2D{font:'15px serif',lineWidth:1,strokeStyle:'green',fillStyle:'#55f02880'}
[config]configScannerQRCodeConfig{src:..,fps..,vibrate..,isBeep:..,config:..,constraints:..,canvasStyles:..}

Ouput

FieldDescriptionTypeDefault
(event)data responseBehaviorSubjectnull

Component exports

FieldDescriptionTypeDefault
isStartstatusbooleanfalse
isLoadingstatusbooleanfalse
isTorchtorchbooleanfalse
isPausestatusboolean-
isReadystatus wasmAsyncSubject-
datadata responseBehaviorSubjectnull
devicesdata devicesBehaviorSubject<ScannerQRCodeDevice[]>[]
deviceIndexActivedevice indexnumber0
------------
(start)start cameraAsyncSubject-
(stop)stop cameraAsyncSubject-
(play)play videoAsyncSubject-
(pause)pause videoAsyncSubject-
(torcher)toggle on/off flashlightAsyncSubject-
(applyConstraints)set media constraintsAsyncSubject-
(getConstraints)get media constraintsAsyncSubject-
(playDevice)play deviceIdAsyncSubject-
(loadImage)load image from srcAsyncSubject-
(download)download imageAsyncSubject<ScannerQRCodeSelectedFiles[]>-

Service

FieldDescriptionTypeDefault
(loadFiles)Convert filesAsyncSubject<ScannerQRCodeSelectedFiles[]>[]
(loadFilesToScan)Scanner filesAsyncSubject<ScannerQRCodeSelectedFiles[]>[]

Models

ScannerQRCodeConfig
interface ScannerQRCodeConfig {
  src?: string;
  fps?: number;
  vibrate?: number /** support mobile */;
  isBeep?: boolean;
  constraints?: MediaStreamConstraints;
  canvasStyles?: CanvasRenderingContext2D;
}
ScannerQRCodeDevice
interface ScannerQRCodeDevice {
  kind: string;
  label: string;
  groupId: string;
  deviceId: string;
}
ScannerQRCodeResult
class ScannerQRCodeResult {
  binaryData: number[];
  data: string;
  chunks: Chunks;
  version: number;
  location: {
    topRightCorner: Point;
    topLeftCorner: Point;
    bottomRightCorner: Point;
    bottomLeftCorner: Point;
    topRightFinderPattern: Point;
    topLeftFinderPattern: Point;
    bottomLeftFinderPattern: Point;
    bottomRightAlignmentPattern?: Point | undefined;
  };
}
interface Point {
  x: number;
  y: number;
}

declare type Chunks = Array<Chunk | ByteChunk | ECIChunk>;
ScannerQRCodeSelectedFiles
interface ScannerQRCodeSelectedFiles {
  url: string;
  name: string;
  file: File;
  data?: ScannerQRCodeResult;
  canvas?: HTMLCanvasElement;
}

Support versions

Support versions
Angular 61.0.0

Author Information

Author Information
AuthorDaiDH
Phone+84845882882
CountryVietnam

If you want donate for me!

Bitcoin

Vietnam

MIT License. Copyright (C) 2023.

Keywords

ng

FAQs

Package last updated on 03 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts