From f13ad926f334ca49f30496df66cd52dca0103405 Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Wed, 2 Nov 2022 17:30:19 +0800 Subject: [PATCH] refactor: drop native WebP library TwelveMonkeys ImageIO now has support for WebP lossless and with alpha --- komga/build.gradle.kts | 1 - .../configuration/KomgaProperties.kt | 2 - .../infrastructure/image/ImageConverter.kt | 37 +------------------ 3 files changed, 1 insertion(+), 39 deletions(-) diff --git a/komga/build.gradle.kts b/komga/build.gradle.kts index 265c583df..e96880b08 100644 --- a/komga/build.gradle.kts +++ b/komga/build.gradle.kts @@ -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") diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/configuration/KomgaProperties.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/configuration/KomgaProperties.kt index 4afa71703..3df0786af 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/configuration/KomgaProperties.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/configuration/KomgaProperties.kt @@ -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() diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/image/ImageConverter.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/image/ImageConverter.kt index 5d24ef01c..6b90e3a74 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/image/ImageConverter.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/image/ImageConverter.kt @@ -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" }