Closed davecoffin closed 7 years ago
Yes, it works.
@moritzvieli any chance you could post an example? I have not been able to get it to work at all (trying to use the camera plugin then crop that img)
@SamuelGRwebfab of course. We're using Angular:
import * as camera from 'nativescript-camera';
import {ImageCropper} from 'nativescript-imagecropper';
camera.takePicture()
.then((picture) => {
let cropper = new ImageCropper();
cropper.show(picture, { height: 800, width: 800 }).then((args) => {
if (args.image !== null) {
return args.image.toBase64String('jpeg');
}
return picture.toBase64String('jpeg');
})
}
@moritzvieli
Are you sure about that code? its throwing an error saying the image is null
Hmm... quite sure. We have some providers and wrappers around this code, but it should basically work like this. Do you have the camera permissions? Where is the error thrown exactly?
I added a .catch because it didnt seem to be working, so that is where the error is throwing. otherwise the code is exactly like you have above.
I did actually have to change a fewthings, return picture.toBase64String('jpeg');
throws an error and so does import {ImageCropper} from 'nativescript-imagecropper';
@moritzvieli so it works if i use the img selector plugin, but not the camera. maybe you are using an old version that sends different img data?
for those wondering how to get this right, i figured it out. after yo utake the picture send the results to this function ` public cropImg = (src) => { if (this.app.android) { var img = imageSource.fromFile(src.android); } else { var img = imageSource.fromFile(src.ios); }
console.dir(img)
var cropper = new icModule.ImageCropper();
cropper.show(img, { width: 300, height: 300 }).then( function (args) {
console.log(JSON.stringify(args));
})
.catch(function (e) {
console.log(e);
console.dir(e)
});
} `
I believe the new version of the camera plugin is the reason for this
Support for NS 3.3 added with today's release of version 0.1.0 :)
Is this plugin compatible?