Hello friends In my project, I'm able to capture the image via camera or gallery the size of the Image file vary to 5-6 MB based on the quality of camera or user selected image.Then I have to upload it on server.
The requirement is, before upload the file on remote server, I want to apply lossless compression on image to reduce the file size to 2-3MB so it will save internet cost of user & and my server space as well.
without using resize
image. how can I do this?.
I have the user upload a Image. This is my code.
$scope.addImage = function (source) {
$rootScope.ionPopup.close();
var src = Camera.PictureSourceType.CAMERA
if (source == 'PHOTOLIBRARY')
src = Camera.PictureSourceType.PHOTOLIBRARY
var options = {
quality: 100,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: src,
allowEdit: false,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 350,
targetHeight: 350,
//popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: true,
correctOrientation: true
};
$cordovaCamera.getPicture(options).then(function (imageData) {
uploadImage(imageData);
}, function (err) {
// error
});
};
var uploadImage = function (imageData) {
$scope.orderImages.push(imageData);
$scope.orderImagesList.push({ImageString: imageData});
};
imageData
is the base64 encoded image.
How can I compress that base64 encoded image ?
can someone help me !