4

I try to understand events in camanjs, but I need some examples. Can everyone write me simple example about this:

1) load image in to canvas (done)

Caman("#canvas-img2", base64_or_path_to_image, function () {
    this.nostalgia();
    this.render();
});

2) listen to end filtering, for callback with this.toBase64()

In docs, I found event page, but don't understand how it works.

ptCoder
  • 2,229
  • 3
  • 24
  • 38
Max P
  • 1,439
  • 3
  • 15
  • 33

1 Answers1

5

It was simple! Put callback in render, like this (I need to send base64 data to backend):

Caman("#canvas-img2", base64_or_path_to_image, function () {
        this.vintage();
        this.render(function() {
            FACE.camanPhoto = this.toBase64();
            base64Data = FACE.camanPhoto.replace(/^data:image\/png;base64,/,"");
            sendDataToServer();
        });
    })
Max P
  • 1,439
  • 3
  • 15
  • 33
  • I had no idea I could pass a function into render, you made my day so much better! I haven't had any luck with their event registration system when re-using a canvas. – Lars Apr 13 '16 at 19:57