mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 15:21:51 +01:00
Add MIME type mapping for image/jxl (fixes #7117)
(cherry picked from commit 591df8abcc
)
This commit is contained in:
parent
c01df7f0a1
commit
71e31e6c03
@ -1,7 +1,6 @@
|
|||||||
package eu.kanade.tachiyomi.data.download
|
package eu.kanade.tachiyomi.data.download
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.webkit.MimeTypeMap
|
|
||||||
import com.hippo.unifile.UniFile
|
import com.hippo.unifile.UniFile
|
||||||
import com.jakewharton.rxrelay.BehaviorRelay
|
import com.jakewharton.rxrelay.BehaviorRelay
|
||||||
import com.jakewharton.rxrelay.PublishRelay
|
import com.jakewharton.rxrelay.PublishRelay
|
||||||
@ -472,7 +471,7 @@ class Downloader(
|
|||||||
// Else read magic numbers.
|
// Else read magic numbers.
|
||||||
?: ImageUtil.findImageType { file.openInputStream() }?.mime
|
?: ImageUtil.findImageType { file.openInputStream() }?.mime
|
||||||
|
|
||||||
return MimeTypeMap.getSingleton().getExtensionFromMimeType(mime) ?: "jpg"
|
return ImageUtil.getExtensionFromMimeType(mime)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,6 +10,7 @@ import android.graphics.drawable.ColorDrawable
|
|||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.graphics.drawable.GradientDrawable
|
import android.graphics.drawable.GradientDrawable
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.webkit.MimeTypeMap
|
||||||
import androidx.core.graphics.alpha
|
import androidx.core.graphics.alpha
|
||||||
import androidx.core.graphics.applyCanvas
|
import androidx.core.graphics.applyCanvas
|
||||||
import androidx.core.graphics.blue
|
import androidx.core.graphics.blue
|
||||||
@ -56,6 +57,12 @@ object ImageUtil {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getExtensionFromMimeType(mime: String?): String {
|
||||||
|
return MimeTypeMap.getSingleton().getExtensionFromMimeType(mime)
|
||||||
|
?: SUPPLEMENTARY_MIMETYPE_MAPPING[mime]
|
||||||
|
?: "jpg"
|
||||||
|
}
|
||||||
|
|
||||||
fun isAnimatedAndSupported(stream: InputStream): Boolean {
|
fun isAnimatedAndSupported(stream: InputStream): Boolean {
|
||||||
try {
|
try {
|
||||||
val type = getImageType(stream) ?: return false
|
val type = getImageType(stream) ?: return false
|
||||||
@ -392,4 +399,10 @@ object ImageUtil {
|
|||||||
|
|
||||||
private fun Int.isWhite(): Boolean =
|
private fun Int.isWhite(): Boolean =
|
||||||
red + blue + green > 740
|
red + blue + green > 740
|
||||||
|
|
||||||
|
// Android doesn't include some mappings
|
||||||
|
private val SUPPLEMENTARY_MIMETYPE_MAPPING = mapOf(
|
||||||
|
// https://issuetracker.google.com/issues/182703810
|
||||||
|
"image/jxl" to "jxl",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user