ImagePicker icon indicating copy to clipboard operation
ImagePicker copied to clipboard

Image type change from jpg to png if compress in enabled

Open build3r opened this issue 3 years ago • 0 comments

Summary

If we set the compress option or maxResultSize option, the file extension changes to PNG from anyother type

Code to reproduce

The issue is because of this line

fun getTempFile(context: Context, uri: Uri): File? {
        try {
            val destination = File(context.cacheDir, "image_picker.png")

            val parcelFileDescriptor = context.contentResolver.openFileDescriptor(uri, "r")
            val fileDescriptor = parcelFileDescriptor?.fileDescriptor ?: return null
            ....

We should consider uri field type before creating temp file.

Android version

All versions

Impacted devices

All

Installation method

Gradle

SDK version

n/a

build3r avatar Mar 04 '22 11:03 build3r