Piasy / BigImageViewer

Big image viewer supporting pan and zoom, with very little memory usage and full featured image loading choices. Powered by Subsampling Scale Image View, Fresco, Glide, and Picasso. Even with gif and webp support! 🍻
MIT License
3.98k stars 400 forks source link

Choose MIME type for saving image? #234

Open DaveMurchison83 opened 2 years ago

DaveMurchison83 commented 2 years ago

I came on here as my app was crashing on Android 11 due to the jpg/jpeg issue, but am I right in saying that ALL images are saved as jpeg? My app serves up images as either webp or animated gif images so would be good if I was able to save in these formats, either by auto-checking the filename, or forcefully choosing the mime type in the code.

Possible?

Thanks.

Piasy commented 2 years ago

PR is welcome!

stephenchowxingxing commented 1 year ago

Redmi K40S,Android 12, image 加载onSuccess后:/data/user/0/com.example.testapp/cache/1670055364173_1, 使用saveImageIntoGallery时, 报错:

java.lang.IllegalArgumentException: Unsupported MIME type image/jpg at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142) at android.content.ContentProviderProxy.insert(ContentProviderNative.java:557) at android.content.ContentResolver.insert(ContentResolver.java:2193) at android.content.ContentResolver.insert(ContentResolver.java:2155) at com.github.piasy.biv.view.BigImageView.saveImageIntoGallery(BigImageView.java:335)

大佬,这是bug, 还是我使用错误?

Piasy commented 1 year ago

应该还是新的 Android 系统存储权限相关的兼容性问题,我抽空看看更新一下吧

stephenchowxingxing commented 1 year ago

将mCurrentImageFile替换成外部私有目录下的图片(xxx.png),把saveImageIntoGallery中的方法拿出来使用并没有什么错误。但是在demo中直接使用saveImageIntoGallery方法就出错.

targetSdkVersion 29 没问题, targetSdk 32 报错。

Piasy commented 1 year ago

@WonderfulHotel 我在 API 32 的模拟器,以及 API 31 的小米真机上测试 demo 的 LongImageActivity 里的 saveImageIntoGallery,项目设置 target API 33,都没有问题。