Hello
I get image using image picker plugin, then I saved it to firebase storage.
but when I save image of 1.8Mb but stored image is about 700kb…
is it possible to keep file quality?
code to get image is
getPhoto(){
console.log("get photo come ");
const options = {
maximumImagesCount: 100,
width: 1000,
height: 1000,
quality:100,
outputType:1
// quality of resized image, defaults to 100
};
setTimeout(()=>{
this.ip.getPictures(options).then((results) => {
console.log(results);
for (var i = 0; i < results.length; i++) {
console.log('Image URI: ' + results[i]);
}
this.viewCtrl.dismiss({"flag":"multi","data":results});
}, (err) => { console.log(err)});
},1000)
}
code to save to firebase storage is
console.log("retrieved image is : ");
if(imagedata!=undefined){
console.log(imagedata);
if(imagedata.flag=="multi"){
console.log(imagedata.data);
this.totalnum=imagedata.data.length;
if(imagedata.data!=undefined){
for(var i=0; i<imagedata.data.length; i++){
console.log("uploading........"+i);
this.picdata=imagedata.data[i];
this.uploadImageToFirebase(imagedata.data[i],i);
}
}
}
}
uploadImageToFirebase(image,index){
console.log("upload iamge to firebase");
console.log(image);
this.uploadImage(image,index)
}
uploadImage(imageURI,index){
let storageRef = firebase.storage().ref();
var result="design"+(index+1);
console.log(imageURI);
imageURI= "data:image/jpeg;base64," + imageURI;
console.log("sssssssssss : "+result);
console.log(imageURI);
var a = this.mypicref.child(this.key).child(result)
this.encodeImageUri(imageURI, (image64)=>{
console.log("image64 converted done");
a.putString(image64, 'data_url',{contentType:'image/jpeg'})
.then(snapshot => {
this.mypicref.child(this.key).child(result).getDownloadURL().then((url)=>{
....
....