java - Width and height information of uploaded image through servlet -
i'm new java servlets , stackoverflow. need store image in database blob-object. image must 300x300px , have size less 400kb. image uploaded html-form.
this code have far:
protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { request.setcharacterencoding("utf-8"); response.setcontenttype("text/html;charset=utf-8"); final printwriter writer = response.getwriter(); final part filepart = request.getpart("albumthumbnail"); imageinfo ii = new imageinfo(); ii.setinput(filepart.getinputstream()); if(filepart != null){ writer.println(ii.getformatname()); writer.println(ii.getheight()); writer.println(ii.getwidth()); writer.println("ok"); writer.println(filepart.getname()); writer.println(filepart.getsize()); writer.println(filepart.getcontenttype()); } when upload file output:
jpeg 0 0 ok albumthumbnail 1421773 image/png
it looks imageinfo class using default values instead of image parameters because uploaded png-file.
i don't know if right obtain width , height of uploaded image. better solutions welcome, thanks.
Comments
Post a Comment