javascript - Save cropped image from ng-src -
i have been fooling around ngimgcrop , accept file post
the image cropper uses ng-src display example of cropped image:
ng-src="data:image/png;base64,...   i want save cropped image. problem in front-end, have no idea , how go here.
is there way save cropped image?
assuming know how upload file: convert base64 string blob. file using file uploader blob properties, uploading blob works same.
var file = datauritoblob(datauri, 'image/png');   function datauritoblob(datauri, type) {     // convert base64 raw binary data held in string     var bytestring = atob(datauri.split(',')[1]);      // separate out mime component     var mimestring = datauri.split(',')[0].split(':')[1].split(';')[0]      // write bytes of string arraybuffer     var ab = new arraybuffer(bytestring.length);     var ia = new uint8array(ab);     (var = 0; < bytestring.length; i++) {         ia[i] = bytestring.charcodeat(i);     }      // write arraybuffer blob, , you're done     var bb = new blob([ab], { type: type });     return bb; }      
Comments
Post a Comment