bthurlow / nativescript-imagecropper

A nativescript image cropping plugin.
Other
49 stars 35 forks source link

{N} 3.0 support #7

Closed davecoffin closed 7 years ago

davecoffin commented 7 years ago

Is this plugin compatible?

moritzvieli commented 7 years ago

Yes, it works.

ButterMeWaffle commented 7 years ago

@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)

moritzvieli commented 7 years ago

@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');
  })
}
ButterMeWaffle commented 7 years ago

@moritzvieli

Are you sure about that code? its throwing an error saying the image is null

moritzvieli commented 7 years ago

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?

ButterMeWaffle commented 7 years ago

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.

ButterMeWaffle commented 7 years ago

I did actually have to change a fewthings, return picture.toBase64String('jpeg'); throws an error and so does import {ImageCropper} from 'nativescript-imagecropper';

ButterMeWaffle commented 7 years ago

@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?

ButterMeWaffle commented 7 years ago

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

shiv19 commented 7 years ago

Support for NS 3.3 added with today's release of version 0.1.0 :)