一个注册的实现问题~~~ 我在做一个注册的demo,但是现在想实现注册上传头像,并且头像可以剪裁,因为是限定大小的嘛。不知道这个功能怎么实现,,请做过的说说思路呗。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 头像问题?图片操作,使用jmagick进行图片处理。 jQuery剪切、裁剪插件(或者原生态JS实现) 给你一段代码,调用就OK/** * 创建缩略图 * @param OriFilePath 源图片路径 * @param TargetFilePath 生成缩略图路径 * @param height 缩略图高度 * @param width 缩略图宽度 */ public static void createFixedBoundImg(String OriFilePath, String TargetFilePath, int height, int width) throws Exception { double Ratio = 0.0; File f = new File(OriFilePath); Image src = ImageIO.read(f); int oriWidth = src.getWidth(null); int oriHeight = src.getHeight(null); int tagWidth, tagHeight; if (oriWidth > width || oriHeight > height) { if (oriHeight > oriWidth) { Ratio = (new Integer(height)).doubleValue() / oriHeight; tagHeight = height; tagWidth = (int) (oriWidth * Ratio); } else { Ratio = (new Integer(width)).doubleValue() / oriWidth; tagHeight = (int) (oriHeight * Ratio); tagWidth = width; } } else { tagHeight = oriHeight; tagWidth = oriWidth; } BufferedImage target = new BufferedImage(tagWidth, tagHeight, BufferedImage.TYPE_INT_RGB); target.getGraphics().drawImage(src, 0, 0, tagWidth, tagHeight, null); FileOutputStream out = new FileOutputStream(TargetFilePath); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); encoder.encode(target); out.close(); } 5楼的哥们,你直接给我搞个demo吧,我学习学习~~~~谢谢哦[email protected]分数会多多的 action 中dto对象为空 java通过流写一个(生成).txt的文件,不知道如何让txt文件中的内容与内容之间加上空格。 工作1.5年,3月份去杭州找工作,有人给我一个准备面试的技术列表吗? 在哪里可以下载bsf.jar的源代码? 今天高兴啊!再顺便问一丙个问题,送100分再加100分 installAnyWhere 如何读取属性文件? TOMCAT在大量访问后死机了(同时100个请求) 数据库连接的问题 JNDI有什么用? Struts搜索返回数据没反应! cxf webservice生成客户端的代理类 一个java读写文件的效率问题
/**
* 创建缩略图
* @param OriFilePath 源图片路径
* @param TargetFilePath 生成缩略图路径
* @param height 缩略图高度
* @param width 缩略图宽度
*/ public static void createFixedBoundImg(String OriFilePath, String TargetFilePath, int height, int width)
throws Exception {
double Ratio = 0.0;
File f = new File(OriFilePath);
Image src = ImageIO.read(f);
int oriWidth = src.getWidth(null);
int oriHeight = src.getHeight(null);
int tagWidth, tagHeight;
if (oriWidth > width || oriHeight > height) {
if (oriHeight > oriWidth) {
Ratio = (new Integer(height)).doubleValue() / oriHeight;
tagHeight = height;
tagWidth = (int) (oriWidth * Ratio);
}
else {
Ratio = (new Integer(width)).doubleValue() / oriWidth;
tagHeight = (int) (oriHeight * Ratio);
tagWidth = width;
}
}
else {
tagHeight = oriHeight;
tagWidth = oriWidth;
}
BufferedImage target = new BufferedImage(tagWidth, tagHeight, BufferedImage.TYPE_INT_RGB);
target.getGraphics().drawImage(src, 0, 0, tagWidth, tagHeight, null);
FileOutputStream out = new FileOutputStream(TargetFilePath);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(target);
out.close();
}
分数会多多的