Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

压缩无效,返回原图片的相对路径 #397

Open
oudengding opened this issue Oct 11, 2021 · 1 comment
Open

压缩无效,返回原图片的相对路径 #397

oudengding opened this issue Oct 11, 2021 · 1 comment

Comments

@oudengding
Copy link

android 11, 没有使用setTargetDir()方法,压缩后返回原图片的相对路径

代码:
Luban.with(context)
.load(uri)
.ignoreBy(100)
//.setTargetDir(dir.getAbsolutePath())
.filter(path -> {
return !(TextUtils.isEmpty(path));
})
.setCompressListener(onCompressCallback)
.launch();

压缩后的图片:/camera_photos/Pictures/JPEG_20211011_140125.jpg

@Muran-Hu
Copy link

@Luban Hey guys, hope everything going well! That would be nice if you have time to look into this problem, thanks in advance! 🙏🏾

I encountered the same problem when I was testing on the Android 12 emulator and set back camera from VirtualScene to Emulated(#430 and #428), as the following code shows:

Luban.with(mContext)
    .load(file)
    .ignoreBy(100)
    .setTargetDir(getPath())
    .setCompressListener(object : OnCompressListener {
        override fun onStart() {}
        override fun onSuccess(compressedFile: File) {
            refreshDataSource(compressedFile.path)
        }
  
        override fun onError(e: Throwable) {
            e.printStackTrace()
        }
    })
    .launch()
}

Although I invoked the setTargetDir() method to set the compressed file directory, the original image path returned in the callback method onSuccess().

  1. Before compression:/storage/emulated/0/Android/data/com.xxx.test/files/Pictures/JPEG_20220310_2140888612150486718.jpg
  2. After compression:/storage/emulated/0/Android/data/com.xxx.test/files/Pictures/JPEG_20220310_2140888612150486718.jpg
  3. getPath - /storage/emulated/0/Android/data/com.xxx.test/files/compress/

Thank you again and best regards. Looking forward to the fix! 🤝

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants