mirror of
https://github.com/gotson/komga.git
synced 2025-12-20 15:34:17 +01:00
refactor: drop native WebP library
TwelveMonkeys ImageIO now has support for WebP lossless and with alpha
This commit is contained in:
parent
08f53ec406
commit
f13ad926f3
3 changed files with 1 additions and 39 deletions
|
|
@ -98,7 +98,6 @@ dependencies {
|
|||
runtimeOnly("com.twelvemonkeys.imageio:imageio-tiff:3.9.3")
|
||||
runtimeOnly("com.twelvemonkeys.imageio:imageio-webp:3.9.3")
|
||||
runtimeOnly("com.github.gotson.nightmonkeys:imageio-jxl:0.4.0")
|
||||
implementation("com.github.gotson:webp-imageio:0.2.2")
|
||||
// support for jpeg2000
|
||||
runtimeOnly("com.github.jai-imageio:jai-imageio-jpeg2000:1.4.0")
|
||||
runtimeOnly("org.apache.pdfbox:jbig2-imageio:3.0.4")
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ class KomgaProperties {
|
|||
@DurationUnit(ChronoUnit.SECONDS)
|
||||
var sessionTimeout: Duration = Duration.ofMinutes(30)
|
||||
|
||||
var nativeWebp: Boolean = true
|
||||
|
||||
var oauth2AccountCreation: Boolean = false
|
||||
|
||||
var database = Database()
|
||||
|
|
|
|||
|
|
@ -1,23 +1,17 @@
|
|||
package org.gotson.komga.infrastructure.image
|
||||
|
||||
import com.luciad.imageio.webp.WebP
|
||||
import mu.KotlinLogging
|
||||
import net.coobird.thumbnailator.Thumbnails
|
||||
import org.gotson.komga.infrastructure.configuration.KomgaProperties
|
||||
import org.springframework.stereotype.Service
|
||||
import java.awt.Color
|
||||
import java.awt.image.BufferedImage
|
||||
import java.io.ByteArrayOutputStream
|
||||
import javax.imageio.ImageIO
|
||||
import javax.imageio.spi.IIORegistry
|
||||
import javax.imageio.spi.ImageReaderSpi
|
||||
|
||||
private val logger = KotlinLogging.logger {}
|
||||
|
||||
@Service
|
||||
class ImageConverter(
|
||||
private val komgaProperties: KomgaProperties,
|
||||
) {
|
||||
class ImageConverter {
|
||||
|
||||
val supportedReadFormats by lazy { ImageIO.getReaderFormatNames().toList() }
|
||||
val supportedReadMediaTypes by lazy { ImageIO.getReaderMIMETypes().toList() }
|
||||
|
|
@ -25,35 +19,6 @@ class ImageConverter(
|
|||
val supportedWriteMediaTypes by lazy { ImageIO.getWriterMIMETypes().toList() }
|
||||
|
||||
init {
|
||||
val registry = IIORegistry.getDefaultInstance()
|
||||
val nativeWebp = try {
|
||||
registry.getServiceProviderByClass(Class.forName("com.luciad.imageio.webp.WebPImageReaderSpi"))
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
} as ImageReaderSpi?
|
||||
val javaWebp = try {
|
||||
registry.getServiceProviderByClass(Class.forName("com.twelvemonkeys.imageio.plugins.webp.WebPImageReaderSpi"))
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
} as ImageReaderSpi?
|
||||
|
||||
if (nativeWebp != null) {
|
||||
when {
|
||||
!komgaProperties.nativeWebp -> {
|
||||
logger.warn { "Unloading native WebP library" }
|
||||
registry.deregisterServiceProvider(nativeWebp)
|
||||
}
|
||||
!WebP.loadNativeLibrary() -> {
|
||||
logger.warn { "Could not load native WebP library" }
|
||||
registry.deregisterServiceProvider(nativeWebp)
|
||||
}
|
||||
javaWebp != null -> {
|
||||
logger.info { "Using native WebP library" }
|
||||
registry.setOrdering(ImageReaderSpi::class.java, nativeWebp, javaWebp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.info { "Supported read formats: $supportedReadFormats" }
|
||||
logger.info { "Supported read mediaTypes: $supportedReadMediaTypes" }
|
||||
logger.info { "Supported write formats: $supportedWriteFormats" }
|
||||
|
|
|
|||
Loading…
Reference in a new issue