Android图片压缩上传(二)

  之前有用到libjpeg,还是有一定的局限性,最近用了一个新的方式,效果还是挺不错,随着作者的版本更新,Bug也随之变少,目前项目中运用已上线。

1.之前的方式Android图片压缩,不失真,上线项目 ;

2.第二种方式:

      1)添加依赖:compile 'com.github.nanchen2251:CompressHelper:1.0.5'

      2)使用:File newFile = CompressHelper.getDefault(This).compressToFile(new File(oldPath + "test.jpg"));

           只需传入原图片,进行压缩,压缩后返回压缩后图片的对象。压缩后图片的路径:

    context.getCacheDir().getPath()+ File.pathSeparator +"CompressHelper"

 

posted @ 2017-11-01 10:41  我又不会乱来  阅读(442)  评论(0编辑  收藏  举报