meltingice / CamanJS

Javascript HTML5 (Ca)nvas (Man)ipulation
http://camanjs.com
BSD 3-Clause "New" or "Revised" License
3.55k stars 404 forks source link

CamanJS + NodeJs imageBase64 #123

Open fukhaos opened 10 years ago

fukhaos commented 10 years ago

How pass the Image Base64 and get the return in base64 ?

Caman = require('caman').Caman;

//Caman("./path/to/file.jpg", function () {
Caman( imageBlob, function () {
  this.brightness(40);
  this.render(function () {
     //this.save("./output.png");
     return imageWithFilterBlob;
  });
});
bebraw commented 10 years ago

I would try converting Base64 to image before passing it to CamanJS. There's a SO thread that shows how to achieve that.

lukaszfiszer commented 10 years ago

And to get back the result in base64 you can access the standard canvas object in Caman instance:

Caman( imageBlob, function () {
  this.brightness(40);
  this.render(function () {
     var base64 = this.canvas.toDataURL("image/jpeg");
  });
});