压缩,图片压缩,压缩Bitmap,Compress,CompressImage,CompressFile,CompressBitmap
笔者从零搭建 Retrofit & RxJava & MVP 框架APP,欢迎关注:https://github.com/nanchen2251/AiYaGirl
笔者从零搭建 Retrofit & RxJava & MVP 框架APP,欢迎关注:https://github.com/nanchen2251/AiYaGirl
笔者从零搭建 Retrofit & RxJava & MVP 框架APP,欢迎关注:https://github.com/nanchen2251/AiYaGirl
主要通过尺寸压缩和质量压缩,以达到清晰度最优,该项目参考了https://github.com/zetbaitsu/Compressor 的部分代码,且在基础上修正了部分bug
1、支持压缩单张图片和多张图片
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.nanchen2251:CompressHelper:1.0.5'
}
File newFile = CompressHelper.getDefault(this).compressToFile(oldFile);
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);
该项目参考了:
1024 - 梦想,永不止步!
爱编程 不爱Bug
爱加班 不爱黑眼圈
固执 但不偏执
疯狂 但不疯癫
生活里的菜鸟
工作中的大神
身怀宝藏,一心憧憬星辰大海
追求极致,目标始于高山之巅
一群怀揣好奇,梦想改变世界的孩子
一群追日逐浪,正在改变世界的极客
你们用最美的语言,诠释着科技的力量
你们用极速的创新,引领着时代的变迁
------至所有正在努力奋斗的程序猿们!加油!!
Copyright 2017 nanchen(刘世麟)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.