<%@ page contenttype= "text/html;charset=gb2312"%>
<%@ page language= "java" import= "java.util.*"%>
<%@ page language= "java" import= "java.io.*"%>
<%@ page language= "java" import= "java.awt.*"%>
<%@ page language= "java" import= "java.awt.image.*"%>
<%@ page language= "java" import= "com.sun.image.codec.jpeg.*"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title> </title>
<meta name= "generator" content= "EditPlus"/>
<meta name= "Author" content= "Wang Shiqiang"/>
<meta name= "keywords" content= "Wang Shiqiang"/>
<meta name= "description" content= ""/>
<body>
<%
Response.setcontenttype ("text/html;charset=gb2312");
Request.setcharacterencoding ("gb2312");
Out.print ("==================test for Thumbtail picture=============");
-----------------------upload completed, start generating thumbnails-------------------------
Java.io.File File = new Java.io.File ("e:\\1110168154_58348.jpg"); Saveurl); Read the file you just uploaded.
String newurl= "E:\\1110168154_58348_min.jpg"; Request.getrealpath ("/") +url+filename+ "_min." +ext; New thumbnail Save Address
Image src = javax.imageio.ImageIO.read (file); Constructing an Image Object
float tagsize=287;
int old_w=src.getwidth (NULL); Get Source image width
int old_h=src.getheight (NULL);
int new_w=0;
int new_h=0; Get source Diagram length
int tempsize;
Out.print ("<br/>the old", "+old_w+" "The Old," +old_h+ "<br/>");
float tempdouble;
if (Old_w>old_h) {
Tempdouble=old_w/tagsize;
}else{
Tempdouble=old_h/tagsize;
}
New_w=math.round (old_w/tempdouble);
New_h=math.round (old_h/tempdouble); To calculate the new graph's length and width
Out.print ("The new width is:" +new_w+ "The New" "+new_h+" <br/> ");
BufferedImage tag = new BufferedImage (NEW_W,NEW_H,BUFFEREDIMAGE.TYPE_INT_RGB);
Tag.getgraphics (). DrawImage (Src,0,0,new_w,new_h,null); Draw a smaller figure
FileOutputStream newimage=new FileOutputStream (Newurl); Output to file stream
JPEGImageEncoder encoder = Jpegcodec.createjpegencoder (newimage);
Encoder.encode (tag); Near-JPEG coding
Newimage.close ();
/*
*/
%>
</body>