java image upload using html5 error "Invalid argument to native writeImage" -
i trying utilize html 5 image upload, problem i'm facing when trying decode 64 encoded image throws error ,here code
public string decodetoimage() throws ioexception { destpath = "/home/user/desktop"; byte[] imagebyte; string imagedata = request.getparameter("img"); string base64image = imagedata.split(",")[1]; base64decoder decoder = new base64decoder(); imagebyte = decoder.decodebuffer(base64image); bufferedimage img = imageio.read(new bytearrayinputstream(imagebyte)); file outputfile = new file(destpath, "11111.png"); seek { imageio.write(img, "jpg", outputfile); } catch(exception e) { e.printstacktrace(); } homecoming success; }
when trying write image in file buffer image throws error
"invalid argument native writeimage"
in forum people saying because of using open-jdk throwing error.
here javascriot..
crop = function() { //find part of image within crop box var crop_canvas, left = $('.imgoverlay').offset().left - $container.offset().left, top = $('.imgoverlay').offset().top - $container.offset().top, width = $('.imgoverlay').width(), height = $('.imgoverlay').height(); crop_canvas = document.createelement('canvas'); crop_canvas.width = width; crop_canvas.height = height; crop_canvas.getcontext('2d').drawimage(image_target, left, top, width, height, 0, 0, width, height); var onsuccesofupload = function(data) { alert(); }; var onerrorofupload = function(data) { alert(); }; var info = function(data) { alert(); }; var info = { 'img': crop_canvas.todataurl("image/png") }; calltodb('/canvasimageupload.action', 'post', data, onsuccesofupload, onerrorofupload); }
java
No comments:
Post a Comment