このプロジェクトでは、いくつかのアバターのアップロード、画像切断機能を行う必要があります。
プラグインが必要です:jquery jcrop
バックエンドコード:
cash.awt.awt.image .imageio.imageio.imageio.imageareader; PARAM PATH2切断後に保存されたパス* @param xxシャフト* @param yy shaft* @param w* @param h*/ public static void cutimage(string path1、string path2、int x、int y、int w、int h) {fileinputStream fileinputStream = null; 「JPG」) ); edimage bi = reader.read(bi、jpg」、} catch(expert e){e.printstacktrace(); ( "切断障害");}最後に{try(file inputstream!= null){fileinputStream.close();} if(is!= null){iis.close();}} catch(ioexceation e){e){e){e) printstacktrace(}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
アクセスコード:
<%@page Language = "Java" Import = "Java.util。*、org.csg.upload。*" pageEncoding = "utf-8"%> <%// ;文字列Required.GetRealPath(// string path2 = relpath+"/images/"+newFileName; integer.parseint(request.getParameter( "w"); int h = integer.parseint(request.getParameter( "h"); try {upload.c.c utimage(path1、path2、x、y、y、w、h); .print( "<img src = 'images/"+newFileName+"'/>");} catch(Exconde e){e.printstacktrace();
JSPコード:
<%@ページ言語= "java" image = "java.util。*" pageencoding = "utf-8"%> <! JSP Develop Avatar Cotting </title> <meta http-equiv = "pragma" content = "no-cache"> <meta http-equiv = "cache-control" content = "no-cache"> <meta http-equiv = "content =" 0 "> <meta http-equiv =" keywords "content =" keyword2、keyword3 "> <meta http-equiv =" description ption "content ="これは私のページです "> <リンクrel = "styleSheet" href = "css/jquery.jcrop.css" type = "text/css"/> <script type = "text/javascript" src = "js/jquery.min.js"> </scrip <script type = "text/javascript" src = "js/jquery.jcrop.min.js"> </script> <all type = "text/css"> *{padding:0;} .cut {マージントップ:プレビューペイン:Z-Index; 0、.4) ) - モズボックスシャドウ:1px 5px 2px RGBA(0、0.2); } </style> <script type = "text/javascript"> nction(){var jcrop_api、boundx = ""、boundy = ""、$ preview = $( '#preview-pane')、$ pcnt = $( '#preview-pane .preview-container')、$ pimg = $( '#preview-pane .preview-controlainer img')、xsize = $ pcnt.width()、ysize = $ pcnt.head(); '#cutimage') (jcrop_api.ui.holder);}) $(Y1 ") ; var ry = ysize / ch; Math.Round(rx * cx) + 'px'、margintop: ' + math.round(ry * cy) +' px '};}}}); > Java開発QQアバター切断システム</h1> <img id = "cutimage" src = "images/1.jpg"> <div id = "preview-pane"> <div> <img src = "images/1。 jpg "/> </div> </div> </div> <form action =" success.jsp "method =" post "> <input type =" text "value =" images/1.jpg "name =" imgpath "> x axis:<input type =" text "size =" 4 "id =" x1 "name =" x " /> y axis:<input type =" text "size =" 4 "id =" y1 " name = "y"/> width:<input type = "text" size = "4" id = "w" w "/> heigh:<input type =" text "size =" 4 "id =" h "name =" h "/> <入力タイプ=" "value =" cut "/> </form> </body> </html> </html>
効果マップ:
上記は、この記事のすべての内容です。