Hello,
I am having trouble resizing an image that I get from cameraRoll.
When a call the function this way
cameraRoll.getImage().then(function(image) {
var options = {
mode : ImageTools.IGNORE_ASPECT,
desiredWidth : desiredW,
desiredHeight : desiredH,
performInPlace : false
};
return ImageTools.resize(image, options);
}).then(function(newImage){
console.log(JSON.stringify(newImage));
}).catch(function(error){
console.log("error: "+JSON.stringify(error));
});
```
I am getting the following error
```
LOG: error: "Can't compress a recycled bitmap"
```
My searchs in google returned me that this is a problem usually related with the command recycle in Android but I dont know how to get around this issue.
So I tested a lot of things and found some odd behaviours that I thought woulb be good to add to this problem.
- if I try to use the image from the camera, or it’s properties, to anything I get the error. like:
camera.takePicture().then(function(image) {
var dh = image.height; //get the error
var newImage = image; // get the error
return ImageTools.resize(image, options);
})
- if I do nothing with the image but I pass the same value to desiredWidth and desiredHeight I also get the error. Like:
camera.takePicture().then(function(image) {
return ImageTools.resize(image, {
mode: ImageTools.IGNORE_ASPECT,
desiredWidth: 720,
desiredHeight: 720
});
})
the only way that I found to get around this and do what I want was get all the values I needed from the image and fake a crop in it (cropping to the original values), then resizing the new image without manipulating it.
camera.takePicture().then(function(image){
postPic.value = image;
iniW = image.width;
iniH = image.height;
var options = {
x : 0,
y : 0,
width : iniW,
height : iniH,
performInPlace : false
};
return ImageTools.crop(image, options);
}).then(same=>{
return ImageTools.resize(same, optionsToResize(iniW,iniH));
})
Crop is a very slow process and doing this workaround took a lot of responsiveness from the app.