{"_id":"@alonewarrior/ngx-webcam","name":"@alonewarrior/ngx-webcam","dist-tags":{"latest":"0.5.0"},"versions":{"0.5.0":{"name":"@alonewarrior/ngx-webcam","version":"0.5.0","author":{"name":"basst314"},"contributors":[{"name":"davidshen84"},{"name":"alonewarrior"}],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/basst314/ngx-webcam.git"},"keywords":["Webcam","Camera","Angular","Angular 13+","Smartphone","Phone","Tablet"],"private":false,"peerDependencies":{},"module":"fesm2015/alonewarrior-ngx-webcam.mjs","es2020":"fesm2020/alonewarrior-ngx-webcam.mjs","esm2020":"esm2020/alonewarrior-ngx-webcam.mjs","fesm2020":"fesm2020/alonewarrior-ngx-webcam.mjs","fesm2015":"fesm2015/alonewarrior-ngx-webcam.mjs","typings":"alonewarrior-ngx-webcam.d.ts","exports":{"./package.json":{"default":"./package.json"},".":{"types":"./alonewarrior-ngx-webcam.d.ts","esm2020":"./esm2020/alonewarrior-ngx-webcam.mjs","es2020":"./fesm2020/alonewarrior-ngx-webcam.mjs","es2015":"./fesm2015/alonewarrior-ngx-webcam.mjs","node":"./fesm2015/alonewarrior-ngx-webcam.mjs","default":"./fesm2020/alonewarrior-ngx-webcam.mjs"}},"sideEffects":false,"dependencies":{"tslib":"^2.3.0"},"gitHead":"217c50f65a90cb93352f34508173522a981bc5ef","description":"A simple Angular webcam component. Pure &amp; minimal, no Flash-fallback. <a href=\"https://basst314.github.io/ngx-webcam/?\" target=\"_blank\">See the Demo!</a>","bugs":{"url":"https://github.com/basst314/ngx-webcam/issues"},"homepage":"https://github.com/basst314/ngx-webcam#readme","_id":"@alonewarrior/ngx-webcam@0.5.0","_nodeVersion":"17.9.1","_npmVersion":"8.11.0","dist":{"integrity":"sha512-J7zk2Yjoqx27Bh8tg8IfJ4vR6wZ53XbJbPD8jxoEHUXE8icthHvPjYxNqYkEdClC+hSMkX6/7mwUh3pO6jlDFg==","shasum":"aa90c1cc868946d0f6daba7a1e1caa17c64c4a57","tarball":"https://registry.npmjs.org/@alonewarrior/ngx-webcam/-/ngx-webcam-0.5.0.tgz","fileCount":23,"unpackedSize":209661,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDCVHcveQViHUuu6kPUqiQ6R6EB8HOKeCS2YwnHOTQ/VgIhAPbN6bTLXtWhq6nAc0LPgfOjMzNW1InPnKnw0APBqW7S"}]},"_npmUser":{"name":"alonewarrior","email":"soranno.nicholas@gmail.com"},"directories":{},"maintainers":[{"name":"alonewarrior","email":"soranno.nicholas@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ngx-webcam_0.5.0_1730905821486_0.7125871669217252"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-06T15:10:21.327Z","0.5.0":"2024-11-06T15:10:21.714Z","modified":"2024-11-06T15:10:21.996Z"},"maintainers":[{"name":"alonewarrior","email":"soranno.nicholas@gmail.com"}],"description":"A simple Angular webcam component. Pure &amp; minimal, no Flash-fallback. <a href=\"https://basst314.github.io/ngx-webcam/?\" target=\"_blank\">See the Demo!</a>","homepage":"https://github.com/basst314/ngx-webcam#readme","keywords":["Webcam","Camera","Angular","Angular 13+","Smartphone","Phone","Tablet"],"repository":{"type":"git","url":"git+https://github.com/basst314/ngx-webcam.git"},"contributors":[{"name":"davidshen84"},{"name":"alonewarrior"}],"author":{"name":"basst314"},"bugs":{"url":"https://github.com/basst314/ngx-webcam/issues"},"license":"MIT","readme":"# ngx-webcam [![npm version](https://badge.fury.io/js/ngx-webcam.svg)](https://badge.fury.io/js/ngx-webcam) [![Build Status](https://api.travis-ci.com/basst314/ngx-webcam.svg?branch=master)](https://app.travis-ci.com/github/basst314/ngx-webcam)\n\nA simple Angular webcam component. Pure &amp; minimal, no\nFlash-fallback. <a href=\"https://basst314.github.io/ngx-webcam/?\" target=\"_blank\">See the Demo!</a>\n\n**Plug-and-play.** This library contains a single module which can be imported into every standard Angular 13+ project.\n\n**Simple to use.** The one component gives you full control and lets you take snapshots via actions and event bindings.\n\n**Minimal.** No unnecessary Flash-fallbacks, no bundle-size bloating.\n\n## Demo\n\nTry out the <a href=\"https://basst314.github.io/ngx-webcam/?\" target=\"_blank\">Live-Demo</a> or see\nthe <a href=\"https://github.com/basst314/ngx-webcam-demo\" target=\"_blank\">Demo-Project</a>.\n\n## Features\n\n- Webcam live view\n- Photo capturing\n- Smartphone compatibility for modern OS's (OS must\n  support [WebRTC/UserMedia API](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices))\n- Access to front- and back-camera, if multiple cameras exist\n- Portrait & Landscape mode on smartphones\n- Mirrored live-view for user-facing cameras - \"selfie view\" on phones\n- Capturing of lossless pixel image data for better post-processing.\n\n## Prerequisites\n\n### Runtime Dependencies\n\n**Note:** For older versions of Angular/TypeScript, please use previous releases of this library.\n\n- Angular: `>=13.0.0`\n- Typescript: `>=4.4.4`\n- RxJs: `>=6.6.0`\n- **Important:** Your app must be served on a secure context using `https://` or on localhost, for modern browsers to\n  permit WebRTC/UserMedia access.\n\n### Client\n\n- [Current browser](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Browser_compatibility) w/\n  HTML5 and WebRTC/UserMedia support (Chrome >53, Safari >11, Firefox >38, Edge)\n- Webcam / camera\n- User permissions to access the camera\n\n## Usage\n\n1. Install the library via standard npm command:\n\n`npm install --save ngx-webcam`\n\n2. Import the `WebcamModule` into your Angular module:\n\n```typescript\nimport {WebcamModule} from 'ngx-webcam';\n\n@NgModule({\n  imports: [\n    WebcamModule,\n    ...\n  ],\n  ...\n})\nexport class AppModule {\n}\n```\n\n3. Use the `WebcamComponent` on your pages:\n\n`<webcam></webcam>`\n\nAs simple as that.\n\nFor more examples, see the code in the <a href=\"https://github.com/basst314/ngx-webcam-demo\" target=\"_blank\">\nDemo-Project</a>.\n\n## Options and Events\n\nThis section describes the basic inputs/outputs of the component. All inputs are optional.\n\n### Inputs\n\n- `trigger: Observable<void>`: An `Observable` to trigger image capturing. When it fires, an image will be captured and\n  emitted (see Outputs).\n- `width: number`: The maximal video width of the webcam live view.\n- `height: number`: The maximal video height of the webcam live view. The actual view will be placed within these\n  boundaries, respecting the aspect ratio of the video stream.\n- `videoOptions: MediaTrackConstraints`: Defines\n  constraints ([MediaTrackConstraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints)) to apply\n  when requesting the video track.\n- `mirrorImage: string | WebcamMirrorProperties`: Flag to control image mirroring. If the attribute is missing or `null`\n  and the camera claims to be user-facing, the image will be mirrored (x-axis) to provide a better user experience (\"\n  selfie view\"). A string value of `\"never\"` will prevent mirroring, whereas a value of `\"always\"` will mirror every\n  camera stream, even if the camera cannot be detected as user-facing. For future extensions,\n  the `WebcamMirrorProperties` object can also be used to set these values.\n- `allowCameraSwitch: boolean`: Flag to enable/disable camera switch. If enabled, a switch icon will be displayed if\n  multiple cameras are found.\n- `switchCamera: Observable<boolean|string>`: Can be used to cycle through available cameras (true=forward,\n  false=backwards), or to switch to a specific device by deviceId (string).\n- `captureImageData: boolean = false`: Flag to enable/disable capturing of a lossless pixel ImageData object when a\n  snapshot is taken. ImageData will be included in the emitted `WebcamImage` object.\n- `imageType: string = 'image/jpeg'`: [Image type](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL)\n  to use when capturing snapshots. Default is 'image/jpeg'.\n- `imageQuality: number = 0.92`: [Image quality](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL)\n  to use when capturing snapshots. Must be a number between 0..1. Default is 0.92.\n\n### Outputs\n\n- `imageCapture: EventEmitter<WebcamImage>`: Whenever an image is captured (i.e. triggered by `[trigger]`), the image is\n  emitted via this `EventEmitter`. The image data is contained in the `WebcamImage` data structure as both, plain Base64\n  string and data-url.\n- `imageClick: EventEmitter<void>`: An `EventEmitter` to signal clicks on the webcam area.\n- `initError: EventEmitter<WebcamInitError>`: An `EventEmitter` to signal errors during the webcam initialization.\n- `cameraSwitched: EventEmitter<string>`: Emits the active deviceId after the active video device has been switched.\n\n## Good To Know\n\n### How to determine if a user has denied camera access\n\nWhen camera initialization fails for some reason, the component emits a `WebcamInitError` via the `initError`\nEventEmitter. If provided by the browser, this object contains a field `mediaStreamError: MediaStreamError` which\ncontains information about why UserMedia initialization failed. According\nto [Mozilla API docs](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia), this object contains\na `name` attribute which gives insight about the reason.\n> If the user denies permission, or matching media is not available, then the promise is rejected with NotAllowedError or NotFoundError respectively.\n\nDetermine if a user has denied permissions:\n\n```\n  <webcam (initError)=\"handleInitError($event)\"></webcam>\n```\n\n```\n  public handleInitError(error: WebcamInitError): void {\n    if (error.mediaStreamError && error.mediaStreamError.name === \"NotAllowedError\") {\n      console.warn(\"Camera access was not allowed by user!\");\n    }\n  }\n```\n\n## Development\n\nHere you can find instructions on how to start developing this library.\n\n### Build\n\nRun `npm run packagr` to build the library. The build artifacts will be stored in the `dist/` directory.\n\n### Start\n\nRun `npm start` to build and run the surrounding demo app with the `WebcamModule`. Essential for live-developing.\n\n### Generate docs/\n\nRun `npm run docs` to generate the live-demo documentation pages in the `docs/` directory.\n\n### Running Unit Tests\n\nRun `npm run test` to run unit-tests.\n","readmeFilename":"README.md"}