komga
komga copied to clipboard
Support AVIF images
Describe your suggested feature
I recently downloaded a manga with images in AVIF format. komga does not display thumbnails and it also does not display the images. It just prints "Page X" as text.
Other details
I put the images into a zip. The page count is displayed correctly.
Acknowledgements
- [X] I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open issue.
- [X] I have written a short but informative title.
- [X] I have updated the app to the latest version.
- [X] I will fill out all of the requested information in this form.
There are no Java library that support AVIF.
TwelveMonkeys has a request for it but given the complexity it will probably never happen.
I recently started NightMonkeys which aims at using native libraries directly, but there's no support for AVIF yet.
Hello, I understand that it is currently not possible to add support for avif. However, I wanted to ask if it would be possible to add some formal support for the client-side instead of native support?
The thing is, I use the Tachiyomi reader on Android for my Komga server, and it has avif support, which works perfectly for me... but for this, I need to download the files locally, which is not very convenient... Additionally, I not only cannot access chapter pages, but I also cannot download such chapters, I just get a 404 error...
I hope it's not a problem that I didn't open a new request, but wrote it here, because it's not quite the same thing...
Hello, I understand that it is currently not possible to add support for avif. However, I wanted to ask if it would be possible to add some formal support for the client-side instead of native support?
The thing is, I use the Tachiyomi reader on Android for my Komga server, and it has avif support, which works perfectly for me... but for this, I need to download the files locally, which is not very convenient... Additionally, I not only cannot access chapter pages, but I also cannot download such chapters, I just get a 404 error...
I hope it's not a problem that I didn't open a new request, but wrote it here, because it's not quite the same thing...
It would be as simple as adding avif here https://github.com/tachiyomiorg/tachiyomi-extensions/blob/3f1137cba5ff1acadf5304024663ea6b12eb0db0/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt#L631
You can open a PR or issue in the Tachiyomi extension repo, and tag me there.
Sorry to jump in, but the workaround I have been using to be able to use avif files from Komga to Tachiyomi (Android), Aidoku (iOS 16 added avif native support) and web browsers is this:
--- a/komga/src/main/kotlin/org/gotson/komga/domain/service/BookLifecycle.kt
+++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/BookLifecycle.kt
@@ -231,6 +231,10 @@ class BookLifecycle(
return BookPageContent(number, convertedPage, targetFormat.mediaType)
} else {
convertTo?.let {
+ if (pageMediaType == "image/avif") {
+ // logger.warn { "avif file, send as is" }
+ return@let
+ }
val msg = "Convert page #$number of book $book from $pageMediaType to ${it.mediaType}"
if (!imageConverter.supportedReadMediaTypes.contains(pageMediaType)) {
throw ImageConversionException("$msg: unsupported read format $pageMediaType")
With this, if the client supports avif, I believe it should work because komga will always send the avif file as is without trying to convert it.
One of the downsides is that you will need to add a external jpg file with the same name as the book, so this could be used for the cover since Komga will not be able to generate automatically from the book file.
Maybe this could cause more errors I didn't notice (maybe on file maintenance stuff?), so take with a grain of salt, but is a workaround I managed to find by trial and error a while back (zero experience with kotlin/java here) and had been using while there's no official support for avif.
Anyways, thank you very much gotson for your amazing work!
PS: if maybe the workaround snippet code is not allowed for any reason, feel free to let me know so I edit the post. Thanks!
With this, if the client supports avif, I believe it should work because komga will always send the avif file as is without trying to convert it.
the client needs to be configured so that avif is requested as not to be converted. I don't know the iOS app you mention, but for Tachiyomi this is a simple fix (see https://github.com/tachiyomiorg/tachiyomi-extensions/issues/16133)
I don't know the iOS app you mention
Just for the information, this is the app: https://github.com/Aidoku/Aidoku
And this is the extensions/sources: https://github.com/Skittyblock/aidoku-community-sources/
With the related Komga code being this: https://github.com/Skittyblock/aidoku-community-sources/blob/f100eb424c025bb3b1c672cc94d904051ac18c2d/src/rust/multi.komga/src/lib.rs#L222
I just tried adding "image/avif", to the list, recompile the source and it worked.
I will try to ask the extension dev once it's implemented on the Tachiyomi extension.
Thanks!
I have released NightMonkeys 0.5.0 which brings HEIF/AVIF support. It needs JDK21, once the Temurin build for Java 21 is available i will add this to Komga.
🎉 This issue has been resolved in 1.7.0 (Release Notes)