android - Android位图压缩webp到jpg不改变mime类型
问题描述
当我使用 compress(CompressFormat format, int quality, OutputStream stream) 函数将 webp 压缩为 jpg 时,它的后缀更改为 .jpg。
但它的 mimeType 没有改变,仍然是“image/webp”。
所以存在不支持webp的手机无法预览的问题。谁能给我答案?
webpBitmap.compress(Bitmap.CompressFormat.JPEG, 45, fos)
//get mime type from bitmap file
val options = BitmapFactory.Options()
options.inJustDecodeBounds = true
BitmapFactory.decodeFile(file.absolutePath, options)
return options.outMimeType
// it return "image/webp" not "image/jpg"
问题是为什么bitmap.compress不会改变文件 mime 类型
解决方案
推荐阅读
- javascript - 通过 Webpack Require Context 将查询参数传递给 Loader
- regex - 选择具有第一行条件的第 n 行
- marklogic - 服务器端 JavaScript 中的 MarkLogic search.search 是否支持 JSON 选项?
- excel - 在循环中将范围值增加 1
- android - 无法将 APK 安装到设备
- javascript - 使用 for 循环拼接数组中的多个元素
- reactjs - 仅在 React js 的 IE 11 中获取 componentStack 错误
- apdu - PDOL为EMV卡(APDU)生成“GET PROCESSING OPTIONS”(GPO)
- java - 读取 Json 对象并在 Map 中存储所需的值
- python - 使用列表理解生成字典列表的问题