<%@ page session="false" isThreadSafe="true" %> <%@ page contentType="text/html;charset=euc-kr" %> <%@ page import="java.io.*,java.awt.*,javax.imageio.*,java.awt.image.*,java.awt.geom.*"%> <% System.setProperty( "java.awt.headless", "true" ); System.setProperty( "java.awt.headless","true"); System.setProperty( "awt.headless","true"); %> <%= peter.web.Gallery.createGallery(request.getRealPath(request.getContextPath())) %> <%-- //get this dir File dir = new File(request.getRealPath(request.getContextPath())); //create a directory for thumbnails File thumbDir = new File(dir.getPath()+File.separator+"thumbs"); thumbDir.mkdir(); //get the list of files File[] files = dir.listFiles(new peter.web.ImageFileFilter()); //create index files File index = new File(dir.getPath()+File.separator+"index.jsp"); String indexContents = "Photos"; int numPicsAcross = 5; int numPicsDown = 4; //create xml file displaying info about images File xml = new File(dir.getPath()+File.separator+"pics.xml"); for(int i=0;i <% File thumbFile = new File( thumbDir+File.separator+"t_"+file.getName() ); File scaledFile = new File( thumbDir+File.separator+"s_"+file.getName() ); if(!thumbFile.exists()) { //create the thumbnail BufferedImage original = ImageIO.read(file); BufferedImage thumbImage = null; BufferedImage scaleImage = null; RenderingHints hints = new RenderingHints(null); hints.put(RenderingHints.KEY_ALPHA_INTERPOLATION ,RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT); hints.put(RenderingHints.KEY_ANTIALIASING ,RenderingHints.VALUE_ANTIALIAS_DEFAULT ); hints.put(RenderingHints.KEY_COLOR_RENDERING ,RenderingHints.VALUE_COLOR_RENDER_DEFAULT); hints.put(RenderingHints.KEY_DITHERING ,RenderingHints.VALUE_DITHER_DEFAULT ); hints.put(RenderingHints.KEY_FRACTIONALMETRICS ,RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT); hints.put(RenderingHints.KEY_INTERPOLATION ,RenderingHints.VALUE_INTERPOLATION_BICUBIC ); hints.put(RenderingHints.KEY_RENDERING ,RenderingHints.VALUE_RENDER_DEFAULT ); hints.put(RenderingHints.KEY_STROKE_CONTROL ,RenderingHints.VALUE_STROKE_DEFAULT ); hints.put(RenderingHints.KEY_TEXT_ANTIALIASING ,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF ); float scaleHt = 0f; float scaleWt = 0f; float scaleH = 0f; float scaleW = 0f; int t_targetWidth = 0; int t_targetHeight = 0; int s_targetWidth = 0; int s_targetHeight = 0; if(original.getHeight() > original.getWidth()) { scaleWt = 150/(float)original.getWidth(); scaleHt = 200/(float)original.getHeight(); scaleW = 600/(float)original.getWidth(); scaleH = 800/(float)original.getHeight(); t_targetWidth = 150; t_targetHeight = 200; s_targetWidth = 600; s_targetHeight = 800; } else { scaleWt = 200/(float)original.getWidth(); scaleHt = 150/(float)original.getHeight(); scaleW = 800/(float)original.getWidth(); scaleH = 600/(float)original.getHeight(); t_targetWidth = 200; t_targetHeight = 150; s_targetWidth = 800; s_targetHeight = 600; } thumbImage = new BufferedImage( t_targetWidth, t_targetHeight, original.getType() ); scaleImage = new BufferedImage( s_targetWidth, s_targetHeight, original.getType() ); AffineTransform scale1 = AffineTransform.getScaleInstance(scaleHt, scaleWt); AffineTransform scale2 = AffineTransform.getScaleInstance(scaleH, scaleW); (new AffineTransformOp(scale1, hints)).filter(original, thumbImage); (new AffineTransformOp(scale2, hints)).filter(original, scaleImage); ImageIO.write(thumbImage, "jpg", thumbFile); ImageIO.write(scaleImage, "jpg", scaledFile); peter.util.FileWritingUtility.writeStringToFile( peter.web.Gallery.createImagePage(files, i, numPicsAcross*numPicsDown), dir+File.separator+file.getName().substring(0,file.getName().length()-4) + ".html" ); } } catch(Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } } String[] pages = peter.web.Gallery.createIndexPages(files,numPicsAcross,numPicsDown); for(int j=0;jPage <%=j+1%>
<% } %> --%>