阿里巴巴SimpleImage图片压缩相关jar
图片压缩,阿里巴巴SimpleImage 相关jar文件。其中包含依赖jar: commons-io-2.4.jar;commons-lang.jar;commons-logging-1.1.1.jar jai_codec-1.1.3.jar;jai_core-1.1.3.jar; 包含jar:aliSimpleImage.jar。aliSimpleImage.jar是对SimpleImage中simpleimage.core\src\main\java文件打包。 SimpleImage github地址:https://github.com/alibaba/simpleimage 测试代码: public static void main(String[] args) { File in = new File("d:/desktop/c/1.jpg"); //原图片 File out = new File("d:/desktop/d/ali_bak_400.jpg"); //目的图片 File out1 = new File("d :/desktop/d/ali_bak_50.jpg"); //目的图片 ScaleParameter scaleParam = new ScaleParameter(400, 400); //将图像缩略到1024x1024以内,不足1024x1024则不做任何处理 FileInputStream inStream = null; FileOutputStream outStream = null; WriteRender wr = null; try { inStream = new FileInputStream(in); outStream = new FileOutputStream(out); ImageRender rr = new ReadRender(inStream); ImageRender sr = new ScaleRender(rr, scaleParam); wr = new WriteRender(sr, outStream); wr.render(); //触发图像处理 } catch(Exception e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(inStream); //图片文件输入输出流必须记得关闭 IOUtils.closeQuietly(outStream); if (wr != null) { try { wr.dispose(); //释放simpleImage的内部资源 } catch (SimpleImageException ignore) { // skip ... } } } } :/desktop/d/ali_bak_50.jpg"); //目的图片 ScaleParameter scaleParam = new ScaleParameter(400, 400); //将图像缩略到1024x1024以内,不足1024x1024则不做任何处理 FileInputStream inStream = null; FileOutputStream outStream = null; WriteRender wr = null; try { inStream = new FileInputStream(in); outStream = new FileOutputStream(out); ImageRender rr = new ReadRender(inStream); ImageRender sr = new ScaleRender(rr, scaleParam); wr = new WriteRender(sr, outStream); wr.render(); //触发图像处理 } catch(Exception e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(inStream); //图片文件输入输出流必须记得关闭 IOUtils.closeQuietly(outStream); if (wr != null) { try { wr.dispose(); //释放simpleImage的内部资源 } catch (SimpleImageException ignore) { // skip ... } } } }
用户评论
很实用,谢谢分享
帮别人下载的
很不错,能用
可惜maven不能是用了。
谢谢,用上了
还没试,正在尝试
好用,解决了一大难题
好用。配置简单,不过过大文件会上传失败,不知道为什么
非常好用,很方便