Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving images after altering them by CamanJS plugin

So I have some images and I could sucessfuly apply effects to them by using the CamanJS plugin. But now I want to save these altered images and replace them with the original one.

The documentation (link) Provides information on saving images. but it is seen as a download prompt. I want the images to be saved at the server without a prompt and on the click of the "save" button.

The documentation also says something about base64 encoding which I dont understand. Could my problem be solved? thanks!.

like image 926
user1910290 Avatar asked Mar 27 '13 07:03

user1910290


1 Answers

CamanJS has a built-in function that helps you get the Base64 representation of the image. You can send that to the server via Ajax, decode the base64 string, and save it as a normal image.

Caman("#my-image", function () {
  this.brightness(10);
  this.render(function () {
    var image = this.toBase64();
    saveToServer(image); // your ajax function
  });
});
like image 58
Ryan LeFevre Avatar answered Sep 24 '22 06:09

Ryan LeFevre