{"_id":"@ableroy1996/camera-js","name":"@ableroy1996/camera-js","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@ableroy1996/camera-js","version":"1.0.0","description":"@ableroy1996/camera-js is a lightweight JavaScript package that enables easy integration of camera functionality into any web application. It allows you to open the camera, take multiple photos, and retrieve them for use in your application.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":[],"author":"","license":"ISC","type":"module","_id":"@ableroy1996/camera-js@1.0.0","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-z2MDwrQ7+GRiLAwQkY4QunSquSWhdR0bXwRkztxZJS5d86ADGY5azm+X79KoL/gDru4mEDicqJUht0ggMx44Gg==","shasum":"9bb900196db68a477a272ef243f72854ab5e86dc","tarball":"https://registry.npmjs.org/@ableroy1996/camera-js/-/camera-js-1.0.0.tgz","fileCount":4,"unpackedSize":5411,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDsaGhe+Fn2zYPfdGOLtkUc8H7JVgX7GytPlIPITaGdLAIgHWAeFBNgnGgzXAUgoMHHOosC7YRg1thsB8+A6Wuw5Yw="}]},"_npmUser":{"name":"ableroy1996","email":"able@ableroy.co.in"},"directories":{},"maintainers":[{"name":"ableroy1996","email":"able@ableroy.co.in"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/camera-js_1.0.0_1737569165243_0.5103327195849083"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-22T18:06:05.060Z","1.0.0":"2025-01-22T18:06:05.404Z","modified":"2025-01-22T18:06:05.761Z"},"maintainers":[{"name":"ableroy1996","email":"able@ableroy.co.in"}],"description":"@ableroy1996/camera-js is a lightweight JavaScript package that enables easy integration of camera functionality into any web application. It allows you to open the camera, take multiple photos, and retrieve them for use in your application.","keywords":[],"license":"ISC","readme":"# **@ableroy1996/camera-js**\n\n@ableroy1996/camera-js is a lightweight JavaScript package that enables easy integration of camera functionality into any web application. It allows you to open the camera, take multiple photos, and retrieve them for use in your application.\n\n## **Installation**\n\nInstall the package using npm:\n\n```bash\nnpm install @ableroy1996/camera-js\n```\n\n## **Usage**\n\nFollow these steps to integrate @ableroy1996/camera-js into your web application:\n\n### 1. **Import the Package**\n\n```javascript\nimport Camera from '@ableroy1996/camera-js';\n```\n\n### 2. **Initialize the Camera**\n\nCreate a container in your HTML where the camera feed will be displayed:\n\n```html\n<div id=\"camera-container\" style=\"width: 100%; height: auto;\"></div>\n```\n\nThen, initialize the camera in your JavaScript:\n\n```javascript\nconst camera = new Camera();\n```\n\n### 3. **Open the Camera**\n\nCall the `openCamera` method to open the camera in the specified container:\n\n```javascript\nawait camera.openCamera('camera-container');\n```\n\n### 4. **Take Photos**\n\nUse the `clickPhoto` method to capture a photo. This will return a base64-encoded image string:\n\n```javascript\nconst photo = camera.clickPhoto();\nconsole.log(photo); // Logs the base64-encoded image data\n```\n\n### 5. **Retrieve All Photos**\n\nCall the `getPhotos` method to retrieve all photos taken in the current session:\n\n```javascript\nconst photos = camera.getPhotos();\nconsole.log(photos); // Array of base64-encoded images\n```\n\n### 6. **Stop the Camera**\n\nTo release the camera and stop the feed, use the `stopCamera` method:\n\n```javascript\ncamera.stopCamera();\n```\n\n## **Example Integration**\n\nHere’s a full example:\n\n```html\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <title>@ableroy1996/camera-js Example</title>\n</head>\n<body>\n  <div id=\"camera-container\" style=\"width: 100%; height: auto;\"></div>\n  <button id=\"take-photo\">Take Photo</button>\n  <button id=\"stop-camera\">Stop Camera</button>\n  <div id=\"photos\"></div>\n\n  <script type=\"module\">\n    import Camera from '@ableroy1996/camera-js';\n\n    const camera = new Camera();\n\n    // Open camera\n    await camera.openCamera('camera-container');\n\n    // Take photo\n    document.getElementById('take-photo').addEventListener('click', () => {\n      const photo = camera.clickPhoto();\n      const img = document.createElement('img');\n      img.src = photo;\n      document.getElementById('photos').appendChild(img);\n    });\n\n    // Stop camera\n    document.getElementById('stop-camera').addEventListener('click', () => {\n      camera.stopCamera();\n    });\n  </script>\n</body>\n</html>\n```\n\n## **API Reference**\n\n### `openCamera(containerId: string): Promise<void>`\nOpens the camera and displays the feed in the specified container.\n\n- **containerId**: ID of the HTML container where the camera feed will be displayed.\n\n---\n\n### `clickPhoto(): string`\nCaptures a photo from the camera feed and returns a base64-encoded image string.\n\n---\n\n### `getPhotos(): string[]`\nReturns an array of all photos taken during the current session.\n\n---\n\n### `stopCamera(): void`\nStops the camera feed and releases resources.\n\n---\n\n## **License**\n\nMIT\n\n","readmeFilename":"README.md"}