Skip to content

Commit 3fc3b49

Browse files
committed
kobo cover in jpg
1 parent f418a41 commit 3fc3b49

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/KoboController.kt

+10-3
Original file line numberDiff line numberDiff line change
@@ -503,13 +503,20 @@ class KoboController(
503503
@PathVariable quality: String?,
504504
@PathVariable isGreyScale: String?,
505505
): ResponseEntity<Any> =
506-
if (!bookRepository.existsById(bookId) && koboProxy.isEnabled())
506+
if (!bookRepository.existsById(bookId) && koboProxy.isEnabled()) {
507507
ResponseEntity
508508
.status(HttpStatus.TEMPORARY_REDIRECT)
509509
.location(UriComponentsBuilder.fromHttpUrl(koboProxy.imageHostUrl).buildAndExpand(bookId, width, height).toUri())
510510
.build()
511-
else
512-
ResponseEntity.ok(bookLifecycle.getThumbnailBytes(bookId)?.bytes ?: throw ResponseStatusException(HttpStatus.NOT_FOUND))
511+
} else {
512+
val poster = bookLifecycle.getThumbnailBytes(bookId) ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
513+
val posterBytes =
514+
if (poster.mediaType != ImageType.JPEG.mediaType)
515+
imageConverter.convertImage(poster.bytes, ImageType.JPEG.imageIOFormat)
516+
else
517+
poster.bytes
518+
ResponseEntity.ok(posterBytes)
519+
}
513520

514521
@RequestMapping(
515522
value = ["{*path}"],

0 commit comments

Comments
 (0)