select multiple images from camera not working
**** working for single image capture and selection *****
imageCamera(){
this.setState({imageSourceText:'Camera'})
let imagearray ={}
ImagePicker.openCamera({compressImageMaxWidth:400,
compressImageMaxHeight:400,multiple: true
}).then(image => { .
here i get only single image in response
this.setState({ImageSource:image})
console.log("cameraimagearray======="+this.state.ImageSource)
imagearray = {uri:image.path}
let tempArray = []
tempArray.push(imagearray)
console.log("tempArray from Camera ============="+tempArray);
this.setState({ImageSourceviewarray:tempArray})
console.log("image from Camera ============="+image.path);
}
);
}
Read the documentation of this other component, it's suppose that does what you want and is similar to what you are using!
https://github.com/ivpusic/react-native-image-crop-picker
I don't think you can use openCamera and capture multiple photos. It works for a single photo only. One solution is to manually open camera, take as many photos as you need, and when you close it use openPicker and select multiple photos from there:
ImagePicker.openPicker({
multiple: true
}).then(images => {
console.log(images);
});
Related
From some research, I've figured out that expo libraries like takePicturesAsync() are able to take a picture and save it to the app's cache. However, the default state for libraries like these is to save the whole image. Is there any way for me to save a specific part of the image (e.g. the 2500 pixels at the center of the screen)?
Thanks!
You can use the onPictureSaved event to grab & manipulate the image.
takePicture = () => {
if (this.camera) {
this.camera.takePictureAsync({ onPictureSaved: this.onPictureSaved });
}
};
onPictureSaved = photo => {
console.log(photo);
}
I am using a react-native-image-crop-picker to choose multiple images and taking a photo using a native camera of the device. This code works for choosing multiple photos:
ImagePicker.openPicker({
multiple: true,
}).then(images => {
this.saveImages(images);
});
Now I want to take photo multiple times. I have the following code:
ImagePicker.openCamera({
width: 300,
height: 400,
multiple: true,
}).then(images => {
saveImages(images);
});
But it takes photo only one time. It has two button after taking photo "Повтор" (Repeat) and OK:
I can take multiple photos by clicking "Повтор" (Repeat) button. But after clicking OK
.then(images => {
saveImages(images);
});
it takes the last picture. How can I take multiple photos using ImagePicker.openPicker?
The current version of the cropper doesn't support taking multiple photos while in camera mode. https://github.com/ivpusic/react-native-image-crop-picker/issues/1374
I try to share multiple photos with other apps(telegram, Instagram,...)in react-native, but I don't know how to share more than one image at on call. any suggestion can be helpful,
thank you
I use this lib to share more than one image to another apps.react-native-share.
This is a simple way to do this on react native.
shareImage(images) {
const shareOptions = {
title: 'Share file',
urls:images,
};
return Share.open(shareOptions);
};
_renderShareIt(base64Items){
let selectedImages=[]
base64Items.map((images)=>{
// push selected images on an array
});
if(selectedImages.length > 0){
this.shareImage(selectedImages)
}else{
// show an alert, no image selected
}
}
hopefully it was useful :)
I am trying to show a message to the user after he captures an image and the image is saved in gallery. I have surfed through the net but can not find any solution. So far what I have tried the following code from here for capturing image-
takePicture = async function() {
if (this.camera) {
this.camera.takePicture().then(data => {
FileSystem.moveAsync({
from: data,
to: `${FileSystem.documentDirectory}photos/Photo_${this.state
.photoId}.jpg`,
}).then(() => {
this.setState({
photoId: this.state.photoId + 1,
});
Vibration.vibrate();
});
});
}
};
Now I want to know what should I do to get the completion event. Any help is highly appreciated.
I am not the best with what all to put in that code, but you can make a message show this way:
Toast.makeText(getApplicationContext(),"Picture taken!",Toast.LENGTH_SHORT).show();
Instead of Toast you can use a cross platform library : react-native-dropdown-alert
I have different albums, the contents of which I want to show in lightgallery.
My initial call goes like :
$('.dlCms_c_Carousel').lightGallery({
dynamic : true ,
dynamicEl : dlThis.LGDynEl ,
thumbnail : true ,
mode : 'lg-fade' ,
});
This works perfect, but then, when opening another album, I want the one or the other way to refresh such that the new content of dynamicEl is shown.
Is there a way to do it ?
I was trying a
$('.dlCms_c_Carousel').data("lightGallery").destroy(true)
before, but that messed up. I.e. there seemed to be some functionality, but it looked like the lightbox lost some styling and wasn't opaque any more.
Any hints ?
I'm using Waypoint.js for infinite scrolling with lightgallery.
The solution that I found for dynamic refresh was:
var gallery = $(".infinite-container").lightGallery({
selector: '.item'
});
var infinite = new Waypoint.Infinite({
element: document.querySelector('.infinite-container'),
onAfterPageLoad: () => {
gallery.data('lightGallery').destroy(true);
gallery = $(".infinite-container").lightGallery({
selector: '.item'
});
}
});
From my experience, the object returned from the lightgallery initialization has to be used on the destroy.
Hope it helps.