From 3889a567518d34a6e2a16103e66ca1a606d4e15f Mon Sep 17 00:00:00 2001 From: Dhaval Patel Date: Sun, 2 Aug 2020 18:41:09 +0530 Subject: [PATCH 1/5] Get extention from File Added method to get extention from File --- .../dhaval2404/imagepicker/util/FileUriUtils.kt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/util/FileUriUtils.kt b/imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/util/FileUriUtils.kt index 8b81ab1e..bd13d8a5 100644 --- a/imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/util/FileUriUtils.kt +++ b/imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/util/FileUriUtils.kt @@ -180,7 +180,10 @@ object FileUriUtils { return if (success) file!!.path else null } - /** @return extension of image with dot, or default .jpg if it none. + /** + * Get Image Extension i.e. .png, .jpg + * + * @return extension of image with dot, or default .jpg if it none. */ fun getImageExtension(uriImage: Uri): String { var extension: String? = null @@ -202,6 +205,15 @@ object FileUriUtils { return ".$extension" } + /** + * Get Image Extension i.e. .png, .jpg + * + * @return extension of image with dot, or default .jpg if it none. + */ + fun getImageExtension(file: File): String { + return getImageExtension(Uri.fromFile(file)) + } + /** * @param uri The Uri to check. * @return Whether the Uri authority is ExternalStorageProvider. From c1b20594dc93b0381763a8a9f1736b9274e0f1cb Mon Sep 17 00:00:00 2001 From: Dhaval Patel Date: Sun, 2 Aug 2020 18:42:36 +0530 Subject: [PATCH 2/5] Fixed image extention change to PNG on Compress Fixed image extention change to PNG on Compress issue #105 --- .../dhaval2404/imagepicker/provider/CompressionProvider.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/provider/CompressionProvider.kt b/imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/provider/CompressionProvider.kt index afa6cbf2..3fee3fe0 100644 --- a/imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/provider/CompressionProvider.kt +++ b/imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/provider/CompressionProvider.kt @@ -6,6 +6,7 @@ import android.graphics.BitmapFactory import android.os.AsyncTask import com.github.dhaval2404.imagepicker.ImagePicker import com.github.dhaval2404.imagepicker.ImagePickerActivity +import com.github.dhaval2404.imagepicker.util.FileUriUtils import com.github.dhaval2404.imagepicker.util.FileUtil import com.github.dhaval2404.imagepicker.util.ImageUtil import java.io.File @@ -175,7 +176,8 @@ class CompressionProvider(activity: ImagePickerActivity) : BaseProvider(activity quality = 100 } - val compressFile: File? = FileUtil.getImageFile(dir = mFileDir) + val extension = FileUriUtils.getImageExtension(file) + val compressFile: File? = FileUtil.getImageFile(dir = mFileDir, extension = extension) return if (compressFile != null) { ImageUtil.compressImage( file, maxWidth.toFloat(), maxHeight.toFloat(), From d2fbd948d6f8a314fb45ddabd0189bd92d0b521f Mon Sep 17 00:00:00 2001 From: Dhaval Patel Date: Sun, 2 Aug 2020 18:45:27 +0530 Subject: [PATCH 3/5] Set default compression quality as 100 Set default compression quality as 100 #93 --- .../dhaval2404/imagepicker/provider/CompressionProvider.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/provider/CompressionProvider.kt b/imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/provider/CompressionProvider.kt index 3fee3fe0..05dc72cb 100644 --- a/imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/provider/CompressionProvider.kt +++ b/imagepicker/src/main/kotlin/com/github/dhaval2404/imagepicker/provider/CompressionProvider.kt @@ -170,7 +170,7 @@ class CompressionProvider(activity: ImagePickerActivity) : BaseProvider(activity // Check file format var format = Bitmap.CompressFormat.JPEG - var quality = 90 + var quality = 100 if (file.absolutePath.endsWith(".png")) { format = Bitmap.CompressFormat.PNG quality = 100 From ff29d7208aaee09c5fa5c81a8ad56985cafcd60f Mon Sep 17 00:00:00 2001 From: Dhaval Patel Date: Sun, 2 Aug 2020 18:52:53 +0530 Subject: [PATCH 4/5] Update ChangeLog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a915d3a..5aab6a51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [1.7.4] - 2020-08-02 +### Changed + * Fixed PNG image saved as JPG after compress issue [#105](https://github.com/Dhaval2404/ImagePicker/issues/105) ## [1.7.3] - 2020-07-18 ### Changed @@ -73,6 +76,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Retrieve Image Result as File, File Path as String or Uri object [Unreleased]: https://github.com/Dhaval2404/ImagePicker/compare/v2.0...HEAD +[1.7.4]: https://github.com/Dhaval2404/ImagePicker/compare/v1.7.3...v1.7.4 [1.7.3]: https://github.com/Dhaval2404/ImagePicker/compare/v1.7.2...v1.7.3 [1.7.2]: https://github.com/Dhaval2404/ImagePicker/compare/v1.7.1...v1.7.2 [1.7.1]: https://github.com/Dhaval2404/ImagePicker/compare/v1.7...v1.7.1 From 422a949171108a69af1359a1b00e9c4a1cacc4d7 Mon Sep 17 00:00:00 2001 From: Dhaval Patel Date: Sun, 2 Aug 2020 18:54:37 +0530 Subject: [PATCH 5/5] v1.7.4 Released Change Log: - Fixed PNG image saved as JPG after compress issue --- README.md | 7 ++++--- imagepicker/build.gradle | 6 +++--- sample/build.gradle | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a6bcf119..5bdccc8e 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Almost 90% of the app that I have developed has an Image upload feature. Along w ``` ```groovy - implementation 'com.github.dhaval2404:imagepicker:1.7.3' + implementation 'com.github.dhaval2404:imagepicker:1.7.4' ``` **If you are yet to Migrate on AndroidX, Use support build artifact:** @@ -116,10 +116,10 @@ Almost 90% of the app that I have developed has an Image upload feature. Along w imgProfile.setImageURI(fileUri) //You can get File object from intent - val file:File = ImagePicker.getFile(data) + val file:File = ImagePicker.getFile(data)!! //You can also get File Path from intent - val filePath:String = ImagePicker.getFilePath(data) + val filePath:String = ImagePicker.getFilePath(data)!! } else if (resultCode == ImagePicker.RESULT_ERROR) { Toast.makeText(this, ImagePicker.getError(data), Toast.LENGTH_SHORT).show() } else { @@ -276,6 +276,7 @@ Almost 90% of the app that I have developed has an Image upload feature. Along w * Fixed NullPointerException in FileUriUtils.getPathFromRemoteUri() [#61](https://github.com/Dhaval2404/ImagePicker/issues/61) (Special Thanks to [himphen](https://github.com/himphen)) * Fixed UCropActivity Crash Android 4.4 (KiKat) [#82](https://github.com/Dhaval2404/ImagePicker/issues/82) * Fixed PNG image saved as JPG after crop issue [#94](https://github.com/Dhaval2404/ImagePicker/issues/94) + * Fixed PNG image saved as JPG after compress issue [#105](https://github.com/Dhaval2404/ImagePicker/issues/105) ### Version: 1.6 diff --git a/imagepicker/build.gradle b/imagepicker/build.gradle index 19cadbe8..8476a7d1 100644 --- a/imagepicker/build.gradle +++ b/imagepicker/build.gradle @@ -13,8 +13,8 @@ android { defaultConfig { minSdkVersion 19 targetSdkVersion 28 - versionCode 11 - versionName "1.7.3" + versionCode 12 + versionName "1.7.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -72,7 +72,7 @@ ext { siteUrl = 'https://github.com/Dhaval2404/ImagePicker/' gitUrl = 'https://github.com/Dhaval2404/ImagePicker.git' - libraryVersion = '1.7.3' + libraryVersion = '1.7.4' //If you are uploading new library try : gradlew install //If you are updating existing library then execute: gradlew bintrayUpload //In both the case don't forgot to put bintray credentials in local.properties file. diff --git a/sample/build.gradle b/sample/build.gradle index d8f76a47..c43f75e1 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -12,8 +12,8 @@ android { applicationId "com.github.dhaval2404.imagepicker.sample" minSdkVersion 19 targetSdkVersion 28 - versionCode 11 - versionName "1.7.3" + versionCode 12 + versionName "1.7.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true }