for an app that I'm building, I'm using Capacitor's Camera plugin. When I click the button that launches the camera, it's asking me to first choose between Gallery and Camera.
I'd like to turn the "Pick from Gallery" feature off.
Is there any solution for this?
By default the Camera plugin prompts, but you can select Camera or Gallery by passing the source attribute
// The source to get the photo from. By default this prompts the user to select either the photo album or take a photo. Default: CameraSource.Prompt
source ?: CameraSource;
Full example:
const image = await Camera.getPhoto({
quality: 90,
resultType: CameraResultType.Uri,
source: CameraSource.Camera
});
Related
ElevatedButton(
onPressed: () async {
final XFile? image =
await picker.pickImage(source: ImageSource.gallery);
},
child: Text('Add photo'),
),
As described in the image_picker example this should work when the button is clicked but the app just crashes without any debug info.
After reading the image_picker docs it says that when using the iOS 14+ simulator. However they fail to mention that the app will also crash. In order for you to use this in the simulator you need give access to the image gallery to add this to your info.plist:
<key>NSPhotoLibraryUsageDescription</key>
<string>To chose a picture from the gallery</string>
From the Image Picker Docs:
Add the following keys to your Info.plist file, located in /ios/Runner/Info.plist:
NSPhotoLibraryUsageDescription- describe why your app needs permission for the photo library. This is called Privacy - Photo Library Usage Description in the visual editor.
NSCameraUsageDescription - describe why your app needs access to the camera. This is called Privacy - Camera Usage Description in the visual editor.
NSMicrophoneUsageDescription - describe why your app needs access to the microphone, if you intend to record videos. This is called Privacy - Microphone Usage Description in the visual editor.
If using Android Studio/ VS Code - goto ios/Runner/info.plist and add the following lines.
Note: You can add custom strings.
<key>NSCameraUsageDescription</key>
<string> App wants to access your camera</string>
<key>NSMicrophoneUsageDescription</key>
<string> App wants to access your gallery</string>
<key>NSPhotoLibraryUsageDescription</key>
<string> App wants to access your microphone</string>
Hi I am using the flutter camera plugin and it works fine, the main issue I am having is that I can't find a way to tell the plugin the image file name when taking the picturee, in android using Kotlin this would be something like:
photoUri = FileProvider.getUriForFile(requireActivity(), "io.awesomedomain", photoFile) // build uri on the app storage space and specific file name -> photoFile.
captureImageIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri) // define the pic name before picture is actually taken by the camera.
startActivityForResult(captureImageIntent, REQUEST_PHOTO) // start the camera
I am currently just renaming the picture file name after the picture XFile returns from the flutter camera plugin but this doesn't feel optimal so I am wondering if I am missing something. Is it possible to specify the file name in advance to the flutter camera plugin?
I am currently using the latest available version at the moment: camera: ^0.7.0+2
OK, it looks like I had a misunderstanding of the Camera plugin, I noticed that the returned XFile places the picture in the cache directory and actually provides a method to save the picture to a more definitive storage xfile.saveTo so I did:
var appDir = appDocDirectory.parent.path; // get app directory
file.saveTo('$appDir${Platform.pathSeparator}files${Platform.pathSeparator}${weightPicture.pictureFileName}');
So the picture is properly saved under $myAppDir/files/picName.jpg where the files is a directory I configured to have permission to write to and the picName is defined by the application as I wanted.
I'm working on a app where I would like to get the local path of the selected/picked image from my mobile gallery instead of image_picker path. I have used image _picker to pick an image from the gallery. When I print the path of the selected image it showing something like this /data/user/0/coffy.testapp/cache/image_picker5380473371212438250.jpg instead I need a path of the image like /data/emulated/downloads/021545.png (The path I can see in my mobile when I click the image details of a particular image);
You need to access local storage and select from there.
https://flutter.dev/docs/cookbook/persistence/reading-writing-files
https://pub.dev/packages/path_provider
I am using the Social Sharing plugin from https://ionicframework.com/docs/v3/native/social-sharing/ within my Ionic 3 app.
Within my code I have:
import { SocialSharing } from '#ionic-native/social-sharing';
And then ..
this.socialSharing.share('Check out Fanslide - In Play Fantasy Football! ' + this.myShareLink, '', 'https://www.fanslide.com/assets/images/appicon-small.png', '');
I am specifying the URL to an image as the third parameter.
If I then open the app and activate the share then I see the attached. There is a thumbnail a "T" and a cursor. This isn't my image so I am not sure where this is coming from.
How can I make sure that the image URL I specify is shown as the thumbnail?
Thank you
I am sorry if it is not the best english, I speak spanish. When I want to change the source of the image in a tapped event, the new image only can be seen when a zoom is applied or when the focus of the image (the part of the image that can be seen) is translating. Is there a solution? I am using this nuget https://github.com/daniel-luberda/DLToolkit.Forms.Controls/tree/master/ImageCropView
This is the code:
<imgcrop:ImageCropView HeightRequest="300" WidthRequest="300" x:Name="cropView">
<imgcrop:ImageCropView.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="1" Tapped="UpdateImage"></TapGestureRecognizer>
</imgcrop:ImageCropView.GestureRecognizers>
<imgcrop:ImageCropView.PreviewTransformations>
<FFTr:CircleTransformation />
</imgcrop:ImageCropView.PreviewTransformations>
</imgcrop:ImageCropView>
When a tapped is made the source of the image is change by an activity that returns a stream from a photo of the phone, but the new image can only be seen when the user is applying a zoom or a translation to the image