capacitor-plugins
capacitor-plugins copied to clipboard
bug: PWA Camera plugin cameraOptions ignored
Bug Report
Capacitor Version
npx cap doctor
output:
Capacitor Doctor
Latest Dependencies:
@capacitor/cli: 2.0.0
@capacitor/core: 2.0.0
@capacitor/android: 2.0.0
@capacitor/electron: 2.0.0
@capacitor/ios: 2.0.0
Installed Dependencies:
@capacitor/ios not installed
@capacitor/electron not installed
@capacitor/cli 2.0.0
@capacitor/core 2.0.0
@capacitor/android 2.0.0
[success] Android looking great! �👌
Affected Platform(s)
- Web
Current Behavior
it seems when I use the getPhoto
API with it's options quality, width and height those get ignored by the android camera. I recieve a big size image and the dimensions are not what I used regarding I expect a small image.
I was testing with my laptop camera and it was work Ok ( iI think is beacause is a VGA), and when I started to test on my phone (a huawei mate 10) I realized.
Expected Behaivor
It would be great that the camera method returns a image with the correct properties predifined.
I need this to get an image with at least 500kb size.
Sample Code or Sample Application Repo
image = await Camera.getPhoto({
quality: 10,
height: 1280,
width: 960,
allowEditing: false,
saveToGallery: true,
direction: CameraDirection.Rear,
source: CameraSource.Camera,
resultType: CameraResultType.DataUrl
});
but when I want to upload mi image to internet its weight is to big
Reproduction Steps
Other Technical Details
npm --version
output: 6.13.4
node --version
output:v 12.14.1
Is it when you run as web or as android? In the title you said pwa, but you checked android as platform and not web
Is it when you run as web or as android? In the title you said pwa, but you checked android as platform and not web
Sorry, is in the mobile browser. I'm using Chrome and my phone is Huawei mate 10. I supose it happens me now because my phone camera is powerful than my laptop camera.
yeah, web camera doesn't support all the native features
Can you tell me what file it needs to be updated?. maybe I can help with a PR.
could be https://github.com/ionic-team/capacitor/blob/master/core/src/web/camera.ts or could be this package the plugin uses for taking the pictures https://github.com/ionic-team/pwa-elements
Any chance to improve Camera capabilities to resolve this issue?
Thanks
Hello. In my case, always opens the front camera by default. Any workaround to open the rear camera by default? Thanks
I am having the same issue with PWA Camera on web app, but in mobile app, the same code took the options works very well.
Sorry @Duy-Nguyen-Globals, with "mobile app", are you meaning generating APK for Android, for example, aren't you? Because, If I run the PWA in Windows, Android or iOS like PWA or Web App, I allways get the front camera for default and the settings didn't work.
Yes, I deployed to Android, iOS by capacitor, and on mobile OS, Camera Plugin worked as expect. In case open using application on mobile Chrome or Safari, the Camera Plugin simply ignores all the options and turn on the Front facing Camera as default, even if I switch to Rear Camera, the plugin always picked the tele Camera or the super wide camera other than the main best quality Camera when using multi-cam Smartphone. Capacitor version: "@capacitor/android": "^2.4.6", "@capacitor/core": "^2.4.6", "@capacitor/ios": "^2.4.6",
My PWA is for a small bussiness and there is not chance (nor sense), to publish in app markets. I think this must be resolved (I don't know by who) ... but in PWAs the camera must work ok.
Would a PR be appreciated to enable setting width
and height
? As far as I can tell it's the file https://github.com/ionic-team/capacitor-plugins/blob/main/camera/src/web.ts. I would provide an implementation for the web using canvas.
Also, in case I create a PR, which version should it be based on?
My PWA is for a small bussiness and there is not chance (nor sense), to publish in app markets. I think this must be resolved (I don't know by who) ... but in PWAs the camera must work ok.
Yes, same problem and requirement. How to enable, by default, the rear camera on web/pwa application?
Hello. In my case, always opens the front camera by default. Any workaround to open the rear camera by default? Thanks
I was facing the same problem, and as a solution I changed the value of the facingMode variable in the constructor in the CameraPWA class. Module path: \node_modules@ionic\pwa-elements\dist\esm\pwa-camera.entry.js
With the file open, we should search for the CameraPWA class and let the variable initialize with the following value (facingMode = 'environment'). With that the smartphone camera started on the main.
The problem for options not being respected still exists. Web browsers seem to ignore the option of camera direction. This issue still needs attention.
Hello. Any advance or workarround? Thanks