# ImageTools.resize not working

**URL:** <https://forums.fusetools.com/t/imagetools-resize-not-working/4316>\
**Category:** Bug Reports\
**Created:** [March 8, 2017, 2:59pm UTC](https://forums.fusetools.com/t/imagetools-resize-not-working/4316 "2017-03-08T14:59:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wilton\_Augusto](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/wilton_augusto/32/336_2.png) [@Wilton\_Augusto](https://forums.fusetools.com/u/Wilton_Augusto)\
**Post date:** [March 8, 2017, 2:59pm UTC](https://forums.fusetools.com/t/imagetools-resize-not-working/4316/1 "2017-03-08T14:59:27Z")

</div>

Hello,  
I am having trouble resizing an image that I get from cameraRoll.  
When a call the function this way

````auto
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.
````

---

<div class="post-metadata">

**Author:** ![Wilton\_Augusto](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/wilton_augusto/32/336_2.png) [@Wilton\_Augusto](https://forums.fusetools.com/u/Wilton_Augusto)\
**Post date:** [March 21, 2017, 6:32pm UTC](https://forums.fusetools.com/t/imagetools-resize-not-working/4316/2 "2017-03-21T18:32:54Z")

</div>

So I tested a lot of things and found some odd behaviours that I thought woulb be good to add to this problem.

1. if I try to use the image from the camera, or it’s properties, to anything I get the error. like:

```auto
camera.takePicture().then(function(image) {
    var dh = image.height; //get the error
    var newImage = image; // get the error

     return ImageTools.resize(image, options);
})

```

1. if I do nothing with the image but I pass the same value to desiredWidth and desiredHeight I also get the error. Like:

```auto
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.

```auto
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.
