{"id":29354418,"url":"https://github.com/googlechromelabs/web-gphoto2","last_synced_at":"2025-07-09T03:14:42.129Z","repository":{"id":43704386,"uuid":"438607700","full_name":"GoogleChromeLabs/web-gphoto2","owner":"GoogleChromeLabs","description":"Running gPhoto2 to control DSLR cameras over USB on the Web","archived":false,"fork":false,"pushed_at":"2024-12-06T01:16:14.000Z","size":4595,"stargazers_count":129,"open_issues_count":6,"forks_count":21,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-07-03T11:06:00.057Z","etag":null,"topics":["camera-control","dslr","dslr-camera-control","gphoto","gphoto2","libusb","usb","webusb","webusb-demo"],"latest_commit_sha":null,"homepage":"https://web-gphoto2.rreverser.com/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GoogleChromeLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-12-15T11:40:32.000Z","updated_at":"2025-06-25T15:09:02.000Z","dependencies_parsed_at":"2024-10-04T09:32:18.103Z","dependency_job_id":"99e22393-19f9-49b3-a3bf-2bacbcb645d3","html_url":"https://github.com/GoogleChromeLabs/web-gphoto2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/GoogleChromeLabs/web-gphoto2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fweb-gphoto2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fweb-gphoto2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fweb-gphoto2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fweb-gphoto2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GoogleChromeLabs","download_url":"https://codeload.github.com/GoogleChromeLabs/web-gphoto2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fweb-gphoto2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264384459,"owners_count":23599619,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["camera-control","dslr","dslr-camera-control","gphoto","gphoto2","libusb","usb","webusb","webusb-demo"],"created_at":"2025-07-09T03:14:41.402Z","updated_at":"2025-07-09T03:14:42.110Z","avatar_url":"https://github.com/GoogleChromeLabs.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Web-gPhoto2\n\nA gPhoto2 implementation using WebAssembly to control DSLR cameras from the browser.\n\nPowered by a [custom fork](https://github.com/RReverser/libgphoto2) of [libgphoto2](https://github.com/gphoto/libgphoto2), the [WebUSB](https://github.com/WICG/webusb) backend of [libusb](https://github.com/libusb/libusb), and WebAssembly via [Emscripten](https://emscripten.org/).\n\n## Installation\n\n```bash\nnpm install web-gphoto2\n```\n\n## Usage\n\nA short example on how to use this package:\n\n```js\nimport { Camera } from \"web-gphoto2\";\n\nlet camera = new Camera();\n\n// Triggers the browser's native USB picker listing all connected cameras.\nawait Camera.showPicker();\n\n// Connects to the camera exposed in the previous step.\n// In the future we might allow to connect to multiple cameras by passing a specific instance.\nawait camera.connect();\n\nconsole.log(\"Operations supported by the camera:\", await camera.getSupportedOps());\n\nconsole.log(\"Current configuration tree:\", await camera.getConfig());\n\n// Update camera configuration by the setting's name.\nawait camera.setConfigValue(\"iso\", \"800\");\n\n// Capture a lower-quality preview frame, useful for high-FPS live view stream.\n// Returns a Blob with image mime type and contents.\nconst blob = await camera.capturePreviewAsBlob();\n// Use `URL.createObjectURL` to create an image URL from the blob or `createImageBitmap` to decode it directly.\nconst img = new Image();\nimg.src = URL.createObjectURL(blob);\n\n// Capture a full-resolution image in format currently selected on the camera (JPEG or RAW).\n// This can be used in the same way as Blob above, but also has extra information such as filename useful for download.\nconst file = await camera.captureImageAsFile();\nconst a = document.createElement(\"a\");\na.href = URL.createObjectURL(file);\na.download = file.name;\n```\n\n## Demo\n\nThis repository also contains a [demo app](https://web.dev/porting-libusb-to-webusb/) running gPhoto2 on the Web:\n![A picture of DSLR camera connected via a USB cable to a laptop. The laptop is running the Web demo mentioned in the article, which mirrors a live video feed from the camera as well as allows to tweak its settings via form controls.](https://web-dev.imgix.net/image/9oK23mr86lhFOwKaoYZ4EySNFp02/MR4YGRvl0Z9AWT6vv3sQ.jpg?auto=format\u0026w=1600)\n\nFor the detailed technical write-up, see [the official blog post](https://web.dev/porting-libusb-to-webusb/). To see the demo in action, visit the hosted version [here](https://web-gphoto2.rreverser.com/) (but make sure to read the [cross-platform compatibility notes](https://web.dev/porting-libusb-to-webusb/#important-cross-platform-compatibility-notes) first).\n\nIf you don't have a DSLR, you can check out a recording of the demo below:\n\n\u003chttps://user-images.githubusercontent.com/557590/152155035-a1664656-a7d9-411f-8cb3-5f04320f1391.mp4\u003e\n\n## Building\n\nTo build the WebAssembly part of the repo, you'll need Docker on Linux (WSL works too) or macOS machine. Then:\n\n```bash\nnpm run build:wasm # runs build in Docker\n```\n\nIf you are just updating the JS library (`src/camera.ts`), then it's enough to do\n\n```bash\nnpm run build:ts\n```\n\non any system as Wasm parts are committed to this repo.\n\nTo serve the demo, run:\n\n```bash\nnpx serve examples/preact # starts a local server with COOP/COEP\n```\n\nThen, navigate to \u003chttp://localhost:3000/\u003e in Chrome.\n\n## Common Issues\n\n\u003cdetails\u003e\n\u003csummary\u003e\nSharedArrayBuffer can not be found\n\u003c/summary\u003e\nSharedArrayBuffer has been disabled across all browsers due to the Spectre vulnerability. This package uses SharedArrayBuffer to communicate with the WebAssembly module. To work around this issue, you need to set two response headers for your document:\n\n```http\nCross-Origin-Opener-Policy: same-origin\nCross-Origin-Embedder-Policy: require-corp\n```\n\nInformation from [Stackoverflow](https://stackoverflow.com/questions/64650119/react-error-sharedarraybuffer-is-not-defined-in-firefox)\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\n Error: Not found: /node_modules/.vite/deps/libapi.wasm\n \u003c/summary\u003e\nVite tries to optimize the dependencies by default. This causes the WebAssembly module to be moved to a different location. To prevent this, you need to exclude the web-gphoto2 package from the optimization.\n\nIn vite, both of the above mentioned issues are solved by adding the following to your vite.config.js:\n\n```js\nimport { sveltekit } from \"@sveltejs/kit/vite\";\nimport { defineConfig } from \"vite\";\n\n/** @type {import('vite').Plugin} */\nconst viteServerConfig = {\n  name: \"add headers\",\n  configureServer: (server) =\u003e {\n    server.middlewares.use((req, res, next) =\u003e {\n      res.setHeader(\"Cross-Origin-Opener-Policy\", \"same-origin\");\n      res.setHeader(\"Cross-Origin-Embedder-Policy\", \"require-corp\");\n      next();\n    });\n  },\n};\n\nexport default defineConfig({\n  plugins: [sveltekit(), viteServerConfig],\n  optimizeDeps: {\n    exclude: [\"web-gphoto2\"],\n  },\n});\n```\n\n\u003c/details\u003e\n\n## See also\n\n[RReverser/eos-remote-web](https://github.com/RReverser/eos-remote-web) - my other project for controlling Canon cameras over Web Bluetooth.\n\n## License\n\nLike the dependencies, this demo is licensed under [LGPL v2.1](https://github.com/GoogleChromeLabs/web-gphoto2/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglechromelabs%2Fweb-gphoto2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgooglechromelabs%2Fweb-gphoto2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglechromelabs%2Fweb-gphoto2/lists"}