PhoneGap-Image-Resizer icon indicating copy to clipboard operation
PhoneGap-Image-Resizer copied to clipboard

Problem when image is stored on device (Android)

Open jonasrod opened this issue 9 years ago • 5 comments

When I select an image from gallery in android, cause app crash, or when I use cordova camera plugin and set savetophotoalbum, it's cause the same problem.

jonasrod avatar Feb 11 '16 01:02 jonasrod

Can you do a logcat to check the kind of exception you get? OutOfMemoryException is quite common when handling large images on Android. Maybe you can try importing a very small image.

Heshyo avatar Feb 11 '16 02:02 Heshyo

I assume you are using the base 64 variant? as Heshyo said, this could happen due to lack of memory. What device are you using? what is the image size?

RaananW avatar Feb 11 '16 09:02 RaananW

@Heshyo I don't get any exception in javascript console. I don't think this problem is OutOfMemoryException, because the same code works when set savetophotoalbum to false. The problem seems to occurs just when the image is stored in the gallery. @RaananW My device is LG G3, and the problem occur with both small image (e.g. 25k) or large image.

jonasrod avatar Feb 11 '16 12:02 jonasrod

Can you see the Java/Android log? there must be an exception thrown if the app crashes. Can you also paste the js code you are using?

RaananW avatar Feb 11 '16 22:02 RaananW

I didn't used the base64 variant. I changed to base64 and it works now. But, follow my original code:

var options = { quality: 30, destinationType: Camera.DestinationType.FILE_URI, sourceType: Camera.PictureSourceType.PHOTOLIBRARY, allowEdit: false, encodingType: Camera.EncodingType.JPEG, saveToPhotoAlbum: true, correctOrientation: true }

$cordovaCamera.getPicture(options).then(function(imageUrl) { console.log(imageUrl); var imageUri = imageUrl; var resizeOptions = { imageDataType: ImageResizer.IMAGE_DATA_TYPE_URL, resizeType: ImageResizer.RESIZE_TYPE_MIN_PIXEL, storeImage: false, photoAlbum: false, format: ImageResizer.FORMAT_JPG };

window.imageResizer.resizeImage(function(data) { FileService.storeImage("data:image/jpeg;base64," + data.imageData); resolve(); }, function (error) { console.log("Error : \r\n" + error); }, imageUri, 200, 0, resizeOptions);

The code above don't work.

jonasrod avatar Feb 11 '16 23:02 jonasrod