在将每个图像添加到我的数据库之前,我一直在将其调整为固定分辨率。为此,我一直在使用 FileUpload 和以下代码:-
logo_name = System.currentTimeMillis() + ".png";
File uploadedFile = new File("/www/static.appcanvas.com/"+logo_name);
BufferedImage bi = ImageIO.read(item.getInputStream());
Image img = bi.getScaledInstance(125,125,Image.SCALE_SMOOTH);
BufferedImage img_logo = new BufferedImage(125,125,BufferedImage.TYPE_INT_RGB);
Graphics2D g = img_logo.createGraphics();
g.drawImage(img,0,0,null);
if(g != null) g.dispose();
ImageIO.write(img_logo,"png",uploadedFile)
我得到了所需分辨率的图像,但有一个我无法删除的不必要的黑色背景。前图:http ://www.rocketcampus.com/images/test.png 后图: http: //static.appcanvas.com/1334085929080.png