项目
在 GitHub 查看
Shouheng88/Compressor
关于
一款易于使用的 Android 图像压缩库。
设计与媒体实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README-zh.md
原文一款易用的 Android 图片压缩框架
更高级的 Android 图片压缩库,支持自定义:
- 图片类型 (Uri/File/bitmap/Byte 数组/自定义)
- 结果类型 (Bitmap/File)
- 任务执行模式 (阻塞/RxJava/Kotlin 协程/AsyncTask)
- 压缩算法
要使用该库,首先添加 maven central 仓库,
repositories { mavenCentral() }
然后添加该项目的依赖,
implementation 'com.github.Shouheng88:compressor:latest-version'
示例:以压缩 Uri 图片、获取 File 类型的结果、在 Kotlin 协程中启动为例。整个代码是,
GlobalScope.launch {
val result = Compress.with(context, file.uri(context))
.setQuality(80)
.concrete {
withMaxWidth(100f)
withMaxHeight(100f)
withScaleMode(ScaleMode.SCALE_HEIGHT)
withIgnoreIfSmaller(true)
}
.get(Dispatchers.IO)
withContext(Dispatchers.Main) {
Glide.with(context).load(result).into(binding.iv6)
}
}
该库允许你对多个地方进行自定义,
License
Copyright (c) 2019-2021 Shouheng Wang.
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.
探索相关项目
加载中…