Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.Waterelone:WT_Compress:1.0.0'
}
dependencies {
implementation("com.github.Waterelone:WT_Compress:1.0.0")
}
<dependency>
<groupId>com.github.Waterelone</groupId>
<artifactId>WT_Compress</artifactId>
<version>1.0.0</version>
</dependency>
libraryDependencies += "com.github.Waterelone" % "WT_Compress" % "1.0.0"
:dependencies [[com.github.Waterelone/WT_Compress "1.0.0"]]
step1:在项目根目录build.grade文件中添加
<pre><code> allprojects { repositories { ... maven { url 'https://jitpack.io' } } } </code></pre>step2:在app项目下的build.grade文件中添加依赖
<pre><code> dependencies { compile 'com.github.Waterelone:WT_Compress:1.0.0' } </code></pre>step3:使用说明
<pre><code> public void compressImage(Uri uri) { Log.e("===compressImage===", "====开始传入原图uri==" + uri.getPath()); try { File saveFile = new File(getExternalCacheDir(), "compress_" + System.currentTimeMillis() + ".jpg"); Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri); Log.e("===compressImage===", "====开始==压缩==saveFile==" + saveFile.getAbsolutePath()); NativeUtil.compressBitmap(bitmap, saveFile.getAbsolutePath()); Log.e("===compressImage===", "====完成==压缩==saveFile==" + saveFile.getAbsolutePath()); imageView.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } </code></pre>