Skip to content

Commit

Permalink
change thumbnail format from PNG to JPEG to reduce size
Browse files Browse the repository at this point in the history
regenerate missing thumbnails on startup
one time force regeneration of all thumbnails
  • Loading branch information
gotson committed Oct 10, 2019
1 parent 0ff0eed commit c36e873
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BookParser(
private val natSortComparator: Comparator<String> = CaseInsensitiveSimpleNaturalComparator.getInstance()

private val thumbnailSize = 300
private val thumbnailFormat = "png"
private val thumbnailFormat = "jpeg"

@Throws(UnsupportedMediaTypeException::class)
fun parse(book: Book): BookMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,13 @@ class PeriodicScannerController(
logger.warn { "Another scan is already running, skipping" }
}
}
}

@EventListener(ApplicationReadyEvent::class)
fun regenerateMissingThumbnails() {
try {
asyncOrchestrator.regenerateMissingThumbnails()
} catch (e: RejectedExecutionException) {
logger.warn { "Thumbnail regeneration task is already running" }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class SeriesController(
): SeriesDto =
seriesRepository.findByIdOrNull(id)?.toDto() ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)

@GetMapping(value = ["{seriesId}/thumbnail"], produces = [MediaType.IMAGE_PNG_VALUE])
@GetMapping(value = ["{seriesId}/thumbnail"], produces = [MediaType.IMAGE_JPEG_VALUE])
fun getSeriesThumbnail(
@PathVariable seriesId: Long
): ByteArray {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
update book_metadata
set thumbnail = null;

0 comments on commit c36e873

Please sign in to comment.