Hi,
how can I check whether a photo was newly taken with the camera or a file was selected from the file system?
I use this example:
//https://capacitorjs.com/docs/apis/camera
public async selectAttachImage(): Promise<UserPhoto> {
const capturedPhoto = await Camera.getPhoto({
resultType: CameraResultType.Uri,
source: CameraSource.Camera, // Camera, Photos or Prompt!
quality: 50,
allowEditing: false});
// Use webPath to display the new image instead of base64 since it's
// already loaded into memory
return {
filepath: capturedPhoto.path || 'emptypath',
webviewPath: capturedPhoto.webPath || 'emptywebpath'
};
}
Is there no answer to this question, because the solution is too easy and I have a plank in front of my head? Or is it just not possible to check the source? For my project it very important to know if the photo was taken. I have to mark theses photos with additional text.
Or how much do I have to pay to get the selected source as a return value in a next camera version?
return {
filepath: capturedPhoto.path || 'emptypath',
webviewPath: capturedPhoto.webPath || 'emptywebpath'
selSource: capturedPhoto.selSource || 'Camera'
};
selSource = Camera or Photos
If you use CameraSource.Camera, then it opens the Camera to take a new picture, so the pictures should be taken, except on web platform where there is an icon to open the gallery.
Hi julio,
I only use my app as pwa. Yes, there is a button for photos. So I need to know which source the user selected.
It’s not possible to know.
You could fork pwa-elements, which is what provides the camera UI on web, remove the gallery button and use your fork
I dont want to remove the gallery button. Now I tried to limit the width and height of the taken photo with the ImageOptions width / height and an atypical resolution.
const capturedPhoto = await Camera.getPhoto({
resultType: CameraResultType.Uri,
source: CameraSource.Camera, // Camera, Photos or Prompt!
quality: 70,
width: 1921,
height: 1921,
allowEditing: false});
return {
filepath: capturedPhoto.path || 'emptypath',
webviewPath: capturedPhoto.webPath || 'emptywebpath',
};
Return values look like:
filepath webviewpath [“emptypath”,“blob:https://mytestdomain.tld/864096de-a21a-486f-9bec-0ed6e1cc574d”]
But the ImageOptions are being ignored and I still get the original geometry 2160x3840 of my device when uploading it to the server.
I find it very disappointing that even the geometry limitation does not work.