Giter Site home page Giter Site logo

compresshelper's Introduction

CompressHelper

压缩,图片压缩,压缩Bitmap,Compress,CompressImage,CompressFile,CompressBitmap

笔者从零搭建Retrofit+Rx+MVP框架APP,欢迎关注:https://github.com/nanchen2251/AiYaGirl

主要通过尺寸压缩和质量压缩,以达到清晰度最优,该项目参考了https://github.com/zetbaitsu/Compressor 的大部分代码,且在基础上修正了部分bug

效果图

⊙开源不易,希望给个star或者fork奖励

特点

1、支持压缩单张图片和多张图片

使用方法

1、添加依赖

Step 1. Add it in your root build.gradle at the end of repositories:
allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
Step 2. Add the dependency
dependencies {
	        compile 'com.github.nanchen2251:CompressHelper:1.0.2'
	}

2、在Activity里面使用

   File newFile = CompressHelper.getDefault(this).compressToFile(oldFile);

3、你也可以自定义属性

   File newFile = new CompressHelper.Builder(this)
                    .setMaxWidth(720)  // 默认最大宽度为720
                    .setMaxHeight(960) // 默认最大高度为960
                    .setQuality(80)    // 默认压缩质量为80
		    .setFileName(yourFileName) // 设置你需要修改的文件名
                    .setCompressFormat(CompressFormat.JPEG) // 设置默认压缩为jpg格式
                    .setDestinationDirectoryPath(Environment.getExternalStoragePublicDirectory(
                            Environment.DIRECTORY_PICTURES).getAbsolutePath())
                    .build()
                    .compressToFile(oldFile);

该项目参考了:

关于作者

   南尘
   四川成都
   其它开源
   博客园

compresshelper's People

Contributors

nanchen2251 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.